feat: Create FastAPI service for generating TTS with word-level synchronized subtitles, robust font handling, and FFmpeg diagnostics.

This commit is contained in:
Michael committed 2026-03-03 18:19:52 +01:00
1 parent 0fd7812b05
commit 64969b17b5
1 file changed
+4 -3
+4 -3
View File
@@ -197,6 +197,7 @@ async def generate_tts_with_subs(
audio_path: Path, audio_path: Path,
ass_path: Path, ass_path: Path,
display_text: Optional[str] = None, display_text: Optional[str] = None,
delay: float = 0.0,
): ):
"""Generate TTS audio with word-level synchronized subtitles. """Generate TTS audio with word-level synchronized subtitles.
@@ -291,13 +292,13 @@ async def generate_tts_with_subs(
if word_boundaries: if word_boundaries:
# Precise synchronization using real word timings # Precise synchronization using real word timings
# Add 2 seconds delay to TTS start # Add delay to TTS start
generate_ass_from_word_boundaries( generate_ass_from_word_boundaries(
word_boundaries, word_boundaries,
text_to_display, text_to_display,
ass_path, ass_path,
total_duration=audio_duration, total_duration=audio_duration,
delay=2.0, delay=delay,
) )
else: else:
# Fallback to linear estimation if no boundaries captured # Fallback to linear estimation if no boundaries captured
@@ -305,7 +306,7 @@ async def generate_tts_with_subs(
"⚠️ No word boundaries captured, falling back to linear timing" "⚠️ No word boundaries captured, falling back to linear timing"
) )
generate_simple_ass( generate_simple_ass(
text_to_display, ass_path, total_duration=audio_duration, delay=2.0 text_to_display, ass_path, total_duration=audio_duration, delay=delay
) )
print(f"✅ TTS success with voice: {attempt_voice}") print(f"✅ TTS success with voice: {attempt_voice}")