@ww_nero/media 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/index.js +16 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -217,29 +217,27 @@ const runAsrScript = (audioPath, outputPath, uploadUrl, apiKey) => {
217
217
  const wslAudioPath = toWslPath(audioPath);
218
218
  const wslOutputPath = toWslPath(outputPath);
219
219
 
220
+ // 构建 python 命令字符串
221
+ const pythonCommand = [
222
+ 'python',
223
+ `"${wslScriptPath}"`,
224
+ '--audio', `"${wslAudioPath}"`,
225
+ '--output', `"${wslOutputPath}"`,
226
+ '--upload-url', `"${uploadUrl}"`,
227
+ '--api-key', `"${apiKey}"`
228
+ ].join(' ');
229
+
220
230
  const isWsl = isWslEnvironment();
221
231
 
232
+ // 参考 bash.js 的调用方式,通过 bash -ic 执行命令
222
233
  let cmd, args;
223
234
  if (isWsl || process.platform === 'linux') {
224
- cmd = 'python3';
225
- args = [
226
- wslScriptPath,
227
- '--audio', wslAudioPath,
228
- '--output', wslOutputPath,
229
- '--upload-url', uploadUrl,
230
- '--api-key', apiKey
231
- ];
235
+ cmd = 'bash';
236
+ args = ['-ic', pythonCommand];
232
237
  } else {
233
- // Windows 环境,通过 wsl 调用
238
+ // Windows 环境,通过 wsl 调用 bash
234
239
  cmd = 'wsl';
235
- args = [
236
- '-e', 'python3',
237
- wslScriptPath,
238
- '--audio', wslAudioPath,
239
- '--output', wslOutputPath,
240
- '--upload-url', uploadUrl,
241
- '--api-key', apiKey
242
- ];
240
+ args = ['-e', 'bash', '-ic', pythonCommand];
243
241
  }
244
242
 
245
243
  const child = spawn(cmd, args, {
@@ -329,7 +327,7 @@ const asr = async ({ working_directory, audio_file }) => {
329
327
  const server = new Server(
330
328
  {
331
329
  name: 'media',
332
- version: '1.0.0',
330
+ version: '1.0.1',
333
331
  },
334
332
  {
335
333
  capabilities: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/media",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for media processing, including ASR speech recognition",
5
5
  "main": "index.js",
6
6
  "bin": {