Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -364,17 +364,22 @@ async def crear_video_async(prompt_type, input_text, selected_voice, musica_file
|
|
| 364 |
|
| 365 |
# 2. Generar audio de voz
|
| 366 |
voz_path = os.path.join(temp_dir_intermediate, "voz.mp3")
|
| 367 |
-
tts_voices_to_try = [selected_voice] #
|
| 368 |
tts_success = False
|
| 369 |
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
|
| 376 |
if not tts_success or not os.path.exists(voz_path) or os.path.getsize(voz_path) <= 100:
|
| 377 |
-
raise ValueError(f"Error generando voz. Intentos con
|
| 378 |
|
| 379 |
temp_intermediate_files.append(voz_path)
|
| 380 |
audio_tts_original = AudioFileClip(voz_path)
|
|
|
|
| 364 |
|
| 365 |
# 2. Generar audio de voz
|
| 366 |
voz_path = os.path.join(temp_dir_intermediate, "voz.mp3")
|
| 367 |
+
tts_voices_to_try = [selected_voice, "es-MX-DaliaNeural"] # Cambi茅 fallback a una voz m谩s estable
|
| 368 |
tts_success = False
|
| 369 |
|
| 370 |
+
for current_voice in tts_voices_to_try:
|
| 371 |
+
logger.info(f"Intentando TTS con voz: {current_voice}")
|
| 372 |
+
try:
|
| 373 |
+
tts_success = await text_to_speech(guion, voz_path, current_voice)
|
| 374 |
+
if tts_success and os.path.exists(voz_path) and os.path.getsize(voz_path) > 100:
|
| 375 |
+
logger.info(f"TTS exitoso con voz: {current_voice}")
|
| 376 |
+
break
|
| 377 |
+
logger.warning(f"TTS fall贸 o archivo inv谩lido con voz: {current_voice}")
|
| 378 |
+
except Exception as e:
|
| 379 |
+
logger.error(f"Error en TTS con voz '{current_voice}': {str(e)}")
|
| 380 |
|
| 381 |
if not tts_success or not os.path.exists(voz_path) or os.path.getsize(voz_path) <= 100:
|
| 382 |
+
raise ValueError(f"Error generando voz. Intentos con {tts_voices_to_try} fallaron.")
|
| 383 |
|
| 384 |
temp_intermediate_files.append(voz_path)
|
| 385 |
audio_tts_original = AudioFileClip(voz_path)
|