@ww_nero/media 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/index.js +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const ASR_UPLOAD_URL = 'http://fsheep.com:10808/upload';
|
|
|
14
14
|
const ASR_SERVICE_URL = 'https://dashscope.aliyuncs.com/api/v1/services/audio/asr/transcription';
|
|
15
15
|
|
|
16
16
|
const SUPPORTED_AUDIO_TYPES = ['.mp3', '.wav'];
|
|
17
|
-
const MAX_FILE_SIZE_BYTES =
|
|
17
|
+
const MAX_FILE_SIZE_BYTES = 120 * 1024 * 1024; // 120MB
|
|
18
18
|
const LANGUAGE_HINTS = ['zh', 'en', 'ja'];
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -302,7 +302,7 @@ const asr = async ({ working_directory, audio_file }) => {
|
|
|
302
302
|
const fileSize = fs.statSync(audioPath).size;
|
|
303
303
|
if (fileSize > MAX_FILE_SIZE_BYTES) {
|
|
304
304
|
throw new Error(
|
|
305
|
-
`音频文件大小 ${(fileSize / 1024 / 1024).toFixed(2)}MB 超过限制(最大
|
|
305
|
+
`音频文件大小 ${(fileSize / 1024 / 1024).toFixed(2)}MB 超过限制(最大 120MB)。` +
|
|
306
306
|
`请先对音频进行分段处理后再逐段识别。`
|
|
307
307
|
);
|
|
308
308
|
}
|
|
@@ -328,16 +328,17 @@ const asr = async ({ working_directory, audio_file }) => {
|
|
|
328
328
|
|
|
329
329
|
// 6. 转换为 SRT 格式并保存
|
|
330
330
|
const srtContent = asrToSrt(transcriptions);
|
|
331
|
-
const
|
|
331
|
+
const filename = `asr_${Date.now()}.srt`;
|
|
332
|
+
const outputPath = path.join(workingDir, filename);
|
|
332
333
|
fs.writeFileSync(outputPath, srtContent, 'utf-8');
|
|
333
334
|
|
|
334
|
-
return
|
|
335
|
+
return filename;
|
|
335
336
|
};
|
|
336
337
|
|
|
337
338
|
const server = new Server(
|
|
338
339
|
{
|
|
339
340
|
name: 'media',
|
|
340
|
-
version: '1.0.
|
|
341
|
+
version: '1.0.9',
|
|
341
342
|
},
|
|
342
343
|
{
|
|
343
344
|
capabilities: {
|
|
@@ -356,11 +357,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
356
357
|
properties: {
|
|
357
358
|
working_directory: {
|
|
358
359
|
type: 'string',
|
|
359
|
-
description: '
|
|
360
|
+
description: '工作目录的绝对路径,识别结果将保存到此目录',
|
|
360
361
|
},
|
|
361
362
|
audio_file: {
|
|
362
363
|
type: 'string',
|
|
363
|
-
description: '音频文件的相对路径(相对于工作目录),支持 mp3/wav 格式,音频长度限制
|
|
364
|
+
description: '音频文件的相对路径(相对于工作目录),支持 mp3/wav 格式,音频长度限制 30 分钟以内,文件大小不超过 120MB',
|
|
364
365
|
},
|
|
365
366
|
},
|
|
366
367
|
required: ['working_directory', 'audio_file'],
|