Commit aefd22b2 by wangzhiyang Committed by 胡悦

fix(meeting-minutes): 修复媒体URL被包裹时无法正常处理的问题

添加_sanitize_media_url函数清理URL前后的引号、反引号和尖括号
在音频转写函数中调用该函数处理输入的文件URL
更新媒体时长探测的错误提示,补充纯URL格式要求
1 parent 99f44882
......@@ -31,6 +31,15 @@ _MAX_MEDIA_DURATION_SECONDS = 12 * 60 * 60
_MEDIA_PROBE_TIMEOUT_SECONDS = 20
def _sanitize_media_url(url: str) -> str:
s = (url or "").strip()
if len(s) >= 2 and s[0] == s[-1] and s[0] in ("`", '"', "'"):
s = s[1:-1].strip()
if len(s) >= 2 and s[0] == "<" and s[-1] == ">":
s = s[1:-1].strip()
return s
def _http_open(url: str, *, method: str = "GET", headers: Optional[dict] = None):
req_headers = {"User-Agent": "agent-admin/meeting-minutes"}
if headers:
......@@ -126,7 +135,7 @@ def _probe_media_limits(url: str) -> dict:
if duration_seconds is None:
return {
"success": False,
"error": "无法获取音视频时长(请 pip install imageio-ffmpeg,或在系统安装 ffmpeg,并确保 URL 可被探测)",
"error": "无法获取音视频时长(请确认传入的是纯 URL,不要带反引号/引号/空格;并确保 URL 可被探测。也可在系统安装 ffmpeg 作为兜底)",
}
if duration_seconds > _MAX_MEDIA_DURATION_SECONDS:
......@@ -154,6 +163,7 @@ def transcribe_audio(
diarization_enabled: bool = True,
) -> dict:
"""使用 Fun-ASR 异步转写音视频文件。"""
file_url = _sanitize_media_url(file_url)
try:
import dashscope
except ImportError:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!