diff --git a/apps/api/app/services/lipsync_service.py b/apps/api/app/services/lipsync_service.py index 9fed8efd6..a24019fe3 100644 --- a/apps/api/app/services/lipsync_service.py +++ b/apps/api/app/services/lipsync_service.py @@ -189,7 +189,9 @@ class LipsyncService: audio_duration = probe_audio_duration(audio_data) if audio_duration <= 0 and supplied_duration and supplied_duration > 0: audio_duration = supplied_duration - logger.info("[lipsync] ffprobe 失败,使用前端传入的预合成时长: job_id=%s duration=%.2f", job.id, audio_duration) + logger.info( + "[lipsync] ffprobe 失败,使用前端传入的预合成时长: job_id=%s duration=%.2f", job.id, audio_duration + ) # 3. 句子时间戳:优先用前端预合成传入的 timings(后端预合成接口已经算过,可信); # 否则若音频下载成功则重算;否则不设置(不阻塞主流程) @@ -274,7 +276,7 @@ class LipsyncService: """ # 0. 输入校验 is_pre_synth = bool(audio_url) and bool(sentence_timings) - is_direct_audio = bool(audio_url) and not is_pre_synth + bool(audio_url) and not is_pre_synth is_tts_mode = not bool(audio_url) if is_tts_mode: diff --git a/apps/api/app/tasks/lipsync_tts.py b/apps/api/app/tasks/lipsync_tts.py index ee78a2bab..2f75e9b41 100644 --- a/apps/api/app/tasks/lipsync_tts.py +++ b/apps/api/app/tasks/lipsync_tts.py @@ -26,11 +26,9 @@ from urllib.parse import urlparse from celery import shared_task # 复用共享的句子时间戳工具(#1845 配音前置) +from packages.domain.sentence_timings import compute_sentence_timings as _compute_sentence_timings from packages.domain.sentence_timings import ( - compute_sentence_timings as _compute_sentence_timings, - estimate_sentence_timings_by_chars as _estimate_sentence_timings_by_chars, probe_audio_duration, - split_script_into_sentences as _split_script_into_sentences, ) logger = logging.getLogger(__name__) diff --git a/apps/web/src/pages/ai-avatar/AiAvatarPage.tsx b/apps/web/src/pages/ai-avatar/AiAvatarPage.tsx index 4d111f924..1e9fb4759 100644 --- a/apps/web/src/pages/ai-avatar/AiAvatarPage.tsx +++ b/apps/web/src/pages/ai-avatar/AiAvatarPage.tsx @@ -157,8 +157,8 @@ const AiAvatarPage: React.FC = () => { } catch (err) { _clearTtsProgressTimer() const errMsg = - (err as { response?: { data?: { message?: string; detail?: unknown } } })?.response?.data?.message || - (err instanceof Error ? err.message : "配音合成失败,请重试") + (err as { response?: { data?: { message?: string; detail?: unknown } } })?.response?.data + ?.message || (err instanceof Error ? err.message : "配音合成失败,请重试") setTtsErrorMessage(typeof errMsg === "string" ? errMsg : "配音合成失败,请重试") state.setTtsPreview({ audioUrl: null, @@ -298,7 +298,14 @@ const AiAvatarPage: React.FC = () => { message.error(err instanceof Error ? err.message : "对口型任务提交失败,请重试") } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [state.selectedVideo, state.selectedVoice, state.scriptText, state.speed, state.emotion, state.ttsPreview]) + }, [ + state.selectedVideo, + state.selectedVoice, + state.scriptText, + state.speed, + state.emotion, + state.ttsPreview, + ]) // 取消对口型生成 const handleCancelLipsync = useCallback(() => { @@ -744,7 +751,8 @@ const AiAvatarPage: React.FC = () => { 配音合成完成,点击下一步继续