auto-save 2026-05-17 13:56 (~4)
This commit is contained in:
@@ -12,6 +12,10 @@ WEB_AUTH_COOKIE_SECURE=false
|
||||
# 模型分工
|
||||
ASR_MODEL=whisper-1
|
||||
ASR_FALLBACK_MODEL=gemini-2.5-flash
|
||||
ASR_TIMEOUT_SECONDS=45
|
||||
LOCAL_ASR_BIN=/opt/homebrew/bin/mlx_whisper
|
||||
LOCAL_ASR_MODEL=mlx-community/whisper-tiny
|
||||
LOCAL_ASR_TIMEOUT_SECONDS=180
|
||||
TRANSLATE_MODEL=gemini-2.5-flash
|
||||
REWRITE_MODEL=gemini-2.5-pro
|
||||
IMAGE_MODEL=gemini-3-pro-image-preview
|
||||
|
||||
@@ -1793,6 +1793,8 @@ def _validate_asr_segments(segments: list[dict], duration: float, source: str) -
|
||||
raise TranscriptionUnavailable(f"{source} returned timestamps outside audio duration")
|
||||
if duration > 10 and last_end < duration * 0.45 and words < 20:
|
||||
raise TranscriptionUnavailable(f"{source} returned too little transcript coverage")
|
||||
for item in clean:
|
||||
item["_source"] = source
|
||||
return clean
|
||||
|
||||
|
||||
@@ -2064,6 +2066,7 @@ def _audio_profile_model_sync(wav: Path, segments: list[TranscriptSegment], targ
|
||||
response_format={"type": "json_object"},
|
||||
temperature=0.1,
|
||||
max_tokens=900,
|
||||
timeout=ASR_TIMEOUT_SECONDS,
|
||||
)
|
||||
content = (resp.choices[0].message.content or "").strip()
|
||||
data = json.loads(content)
|
||||
@@ -2322,6 +2325,7 @@ def pipeline_transcribe(job_id: str, manage_job_status: bool = True) -> None:
|
||||
segments = _transcribe_sync(wav)
|
||||
if not segments:
|
||||
raise TranscriptionUnavailable("ASR 未返回可用字幕段")
|
||||
asr_source = str(segments[0].get("_source") or ASR_MODEL)
|
||||
|
||||
# 先把英文段落落到 job 上(让 UI 提前看到,翻译再补 zh)
|
||||
en_only = [
|
||||
@@ -2368,7 +2372,7 @@ def pipeline_transcribe(job_id: str, manage_job_status: bool = True) -> None:
|
||||
if manage_job_status:
|
||||
update(job, transcript=full, status="transcribed", progress=100,
|
||||
audio_script=audio_script,
|
||||
message=f"音频解析完成 · {len(full)} 段({ASR_MODEL} + {TRANSLATE_MODEL} + {ASR_FALLBACK_MODEL} 音频分析)")
|
||||
message=f"音频解析完成 · {len(full)} 段({asr_source} + {TRANSLATE_MODEL} + {ASR_FALLBACK_MODEL} 音频分析)")
|
||||
else:
|
||||
update(job, transcript=full, audio_script=audio_script)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user