gnosticdev commited on
Commit
cb92089
verified
1 Parent(s): 5ca1550

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
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] # Solo intentar la voz seleccionada
368
  tts_success = False
369
 
370
- logger.info(f"Intentando TTS con voz seleccionada: {selected_voice}")
371
- tts_success = await text_to_speech(guion, voz_path, selected_voice)
372
- if not tts_success:
373
- logger.warning(f"Fallo con voz '{selected_voice}'. Intentando voz por defecto: {DEFAULT_VOICE_ID}")
374
- tts_success = await text_to_speech(guion, voz_path, DEFAULT_VOICE_ID)
 
 
 
 
 
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 '{selected_voice}' y '{DEFAULT_VOICE_ID}' fallaron.")
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)