fix(ffmpeg): fallback to ffsubsync when edge_tts emits no word boundaries

Some voices/texts do not produce WordBoundary events from edge_tts.
When word_boundaries is empty, generate_ass_from_word_boundaries returns
without writing the ASS file, causing FFmpeg to fail with ENOENT.

Fallback to the old ffsubsync path when no boundaries are captured.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.7 committed 2026-05-04 14:34:20 +02:00
1 parent d763be6322
commit 9e6fe9fe31
1 file changed
+10
+10
View File
@@ -291,6 +291,16 @@ async def generate_tts_with_subs(
# Use display_text for subtitle content if provided
text_to_display = display_text if display_text else text
if len(word_boundaries) == 0:
print("⚠️ No word boundaries captured, falling back to ffsubsync")
unsynced_srt_path = audio_path.with_suffix(".unsynced.srt")
synced_srt_path = audio_path.with_suffix(".synced.srt")
generate_unsynced_srt(text_to_display, unsynced_srt_path, total_duration=audio_duration)
run_ffsubsync(audio_path, unsynced_srt_path, synced_srt_path)
convert_srt_to_ass(synced_srt_path, ass_path, font_size=65, delay=delay)
print(f"✅ TTS synchronisation completed with ffsubsync fallback")
return
print("🎯 Using precise word-boundary timing from TTS engine")
generate_ass_from_word_boundaries(
word_boundaries,