@ww_nero/media 1.0.2 → 1.0.4

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 CHANGED
@@ -324,7 +324,7 @@ const asr = async ({ working_directory, audio_file }) => {
324
324
  const server = new Server(
325
325
  {
326
326
  name: 'media',
327
- version: '1.0.2',
327
+ version: '1.0.4',
328
328
  },
329
329
  {
330
330
  capabilities: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/media",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "MCP server for media processing, including ASR speech recognition",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -97,26 +97,28 @@ def upload_audio(upload_url: str, audio_path: str) -> str:
97
97
  if not data.get('success') or 'data' not in data or 'path' not in data['data']:
98
98
  raise Exception(f"上传响应格式错误: {data}")
99
99
 
100
- return Path(data['data']['path']).name
100
+ # 返回完整的相对路径,用于拼接到服务器地址后面
101
+ return data['data']['path']
101
102
 
102
103
 
103
- def get_static_url(upload_url: str, filename: str) -> str:
104
+ def get_static_url(upload_url: str, file_path: str) -> str:
104
105
  """
105
- 根据上传接口 URL 和文件名构建静态资源 URL
106
+ 根据上传接口 URL 和文件路径构建静态资源 URL
106
107
 
107
108
  Args:
108
109
  upload_url: 上传接口的完整 URL (如 http://server.domain.com/upload)
109
- filename: 上传后的文件名
110
+ file_path: 上传后返回的文件路径 (如 /tmp/xxx.wav)
110
111
 
111
112
  Returns:
112
113
  静态资源的完整 URL
113
114
  """
114
115
  # 从上传 URL 中提取基础 URL
115
- # 例如: http://server.domain.com/upload -> http://server.domain.com/
116
+ # 例如: http://server.domain.com/upload -> http://server.domain.com
116
117
  from urllib.parse import urlparse, urlunparse
117
118
  parsed = urlparse(upload_url)
118
- base_url = urlunparse((parsed.scheme, parsed.netloc, '/', '', '', ''))
119
- return f"{base_url.rstrip('/')}/{filename}"
119
+ base_url = urlunparse((parsed.scheme, parsed.netloc, '', '', '', ''))
120
+ # file_path 已经是以 / 开头的完整相对路径,直接拼接
121
+ return f"{base_url}{file_path}"
120
122
 
121
123
 
122
124
  def transcribe_audio(audio_url: str, api_key: str) -> list:
@@ -193,11 +195,11 @@ def main():
193
195
  try:
194
196
  # 1. 上传音频文件
195
197
  print(f"正在上传音频文件: {args.audio}")
196
- filename = upload_audio(args.upload_url, args.audio)
197
- print(f"上传成功: {filename}")
198
+ file_path = upload_audio(args.upload_url, args.audio)
199
+ print(f"上传成功: {file_path}")
198
200
 
199
201
  # 2. 构建静态资源 URL
200
- audio_url = get_static_url(args.upload_url, filename)
202
+ audio_url = get_static_url(args.upload_url, file_path)
201
203
  print(f"音频 URL: {audio_url}")
202
204
 
203
205
  # 3. 调用 ASR 识别