Update app.py
Browse files
app.py
CHANGED
@@ -474,12 +474,12 @@ def generate_voiceover_clone(translated_json, desired_duration, target_language,
|
|
474 |
logger.error(msg)
|
475 |
return None, msg, msg
|
476 |
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
|
484 |
speed_tts = calculate_speed(full_text, desired_duration)
|
485 |
tts.tts_to_file(
|
|
|
474 |
logger.error(msg)
|
475 |
return None, msg, msg
|
476 |
|
477 |
+
# Truncate text based on max token assumption (~60 tokens)
|
478 |
+
MAX_TTS_TOKENS = 60
|
479 |
+
tokens = full_text.split() # crude token count
|
480 |
+
if len(tokens) > MAX_TTS_TOKENS:
|
481 |
+
logger.warning(f"⚠️ Text too long for TTS model ({len(tokens)} tokens). Truncating to {MAX_TTS_TOKENS} tokens.")
|
482 |
+
full_text = " ".join(tokens[:MAX_TTS_TOKENS])
|
483 |
|
484 |
speed_tts = calculate_speed(full_text, desired_duration)
|
485 |
tts.tts_to_file(
|