利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(voice): exclude separator lines from estimated subtitle timelines
Rudy Celeklic6d0af917af8
diff --git a/app/services/voice.py b/app/services/voice.pyindex 5f4344e0..995f9959 100644--- a/app/services/voice.py+++ b/app/services/voice.py@@ -1259,7 +1259,10 @@ def populate_legacy_submaker_with_full_text(sub_maker.subs = []sub_maker.offset = []- normalized_text = (text or "").strip()+ # 与 create_subtitle() 使用同一套脚本清理:`---`、`***` 这类 Markdown+ # 分隔行不会被朗读,若参与按字符比例分配,会占用一段音频时长,导致+ # 后续字幕提前出现,或最后一句字幕在音频结束前就消失。+ normalized_text = utils.normalize_script_for_subtitle_matching(text or "").strip()if not normalized_text:return sub_makerdiff --git a/test/services/test_legacy_timeline_separators.py b/test/services/test_legacy_timeline_separators.pynew file mode 100644index 00000000..a511ce44--- /dev/null+++ b/test/services/test_legacy_timeline_separators.py@@ -0,0 +1,36 @@+from edge_tts import SubMaker++from app.services import subtitle, voice+++def _timeline(script, duration=10.0):+ sub_maker = voice.ensure_legacy_submaker_fields(SubMaker())+ return voice.populate_legacy_submaker_with_full_text(sub_maker, script, duration)+++def test_trailing_markdown_separator_does_not_end_last_caption_early(tmp_path):+ # Providers without word boundaries split the audio by sentence length.+ # A separator line is never spoken, so it must not take the last slice.+ script = "Only one sentence is spoken here.\n***"+ sub_maker = _timeline(script)++ assert sub_maker.subs == ["Only one sentence is spoken here"]+ assert sub_maker.offset == [(0, 100_000_000)]++ subtitle_file = tmp_path / "subtitle.srt"+ voice.create_subtitle(sub_maker, script, str(subtitle_file))+ items = subtitle.file_to_subtitles(str(subtitle_file))+ assert [(item[1], item[2]) for item in items] == [+ ("00:00:00,000 --> 00:00:10,000", "Only one sentence is spoken here")+ ]+++def test_middle_markdown_separator_does_not_delay_following_caption():+ first = "This is the first narrated sentence"+ second = "This is the second one"++ with_separator = _timeline(f"{first}.\n---\n{second}.")+ without_separator = _timeline(f"{first}.\n{second}.")++ assert with_separator.subs == [first, second]+ assert with_separator.offset == without_separator.offset