@ww_nero/media 1.0.1 → 1.0.2
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/index.js +2 -5
- package/package.json +1 -1
- package/scripts/asr_srt.py +4 -10
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
} = require('@modelcontextprotocol/sdk/types.js');
|
|
12
12
|
|
|
13
13
|
const ASR_API_KEY = process.env.ASR_API_KEY || '';
|
|
14
|
-
const ASR_UPLOAD_URL =
|
|
14
|
+
const ASR_UPLOAD_URL = 'http://fsheep.com:10808/upload';
|
|
15
15
|
|
|
16
16
|
const SUPPORTED_AUDIO_TYPES = ['.mp3', '.wav'];
|
|
17
17
|
const MAX_AUDIO_DURATION_SECONDS = 60;
|
|
@@ -299,9 +299,6 @@ const asr = async ({ working_directory, audio_file }) => {
|
|
|
299
299
|
if (!ASR_API_KEY) {
|
|
300
300
|
throw new Error('请配置 ASR_API_KEY 环境变量');
|
|
301
301
|
}
|
|
302
|
-
if (!ASR_UPLOAD_URL) {
|
|
303
|
-
throw new Error('请配置 ASR_UPLOAD_URL 环境变量(完整的上传接口 URL,如 http://server.domain.com/upload)');
|
|
304
|
-
}
|
|
305
302
|
|
|
306
303
|
const workingDir = resolveWorkingDirectory(working_directory);
|
|
307
304
|
const audioPath = resolveAudioFile(workingDir, audio_file);
|
|
@@ -327,7 +324,7 @@ const asr = async ({ working_directory, audio_file }) => {
|
|
|
327
324
|
const server = new Server(
|
|
328
325
|
{
|
|
329
326
|
name: 'media',
|
|
330
|
-
version: '1.0.
|
|
327
|
+
version: '1.0.2',
|
|
331
328
|
},
|
|
332
329
|
{
|
|
333
330
|
capabilities: {
|
package/package.json
CHANGED
package/scripts/asr_srt.py
CHANGED
|
@@ -88,22 +88,16 @@ def upload_audio(upload_url: str, audio_path: str) -> str:
|
|
|
88
88
|
files = {'file': (audio_path.name, f)}
|
|
89
89
|
response = requests.post(upload_url, files=files, timeout=60)
|
|
90
90
|
|
|
91
|
-
if response.status_code == 409:
|
|
92
|
-
# 文件已存在,从响应中获取文件名或根据原文件名推断
|
|
93
|
-
data = response.json()
|
|
94
|
-
if 'fileName' in data:
|
|
95
|
-
return data['fileName']
|
|
96
|
-
# 如果没有返回文件名,使用原始文件名的扩展名
|
|
97
|
-
raise Exception(f"文件已存在: {data.get('message', '未知错误')}")
|
|
98
|
-
|
|
99
91
|
if response.status_code != 200:
|
|
100
92
|
raise Exception(f"上传失败: {response.status_code} - {response.text}")
|
|
101
93
|
|
|
102
94
|
data = response.json()
|
|
103
|
-
|
|
95
|
+
|
|
96
|
+
# 响应格式: {'success': True, 'data': {'path': '/tmp/xxx.wav'}}
|
|
97
|
+
if not data.get('success') or 'data' not in data or 'path' not in data['data']:
|
|
104
98
|
raise Exception(f"上传响应格式错误: {data}")
|
|
105
99
|
|
|
106
|
-
return data['
|
|
100
|
+
return Path(data['data']['path']).name
|
|
107
101
|
|
|
108
102
|
|
|
109
103
|
def get_static_url(upload_url: str, filename: str) -> str:
|