gnosticdev commited on
Commit
762f22c
verified
1 Parent(s): c6e67aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -178,38 +178,29 @@ def generate_script(prompt, max_length=150):
178
  logger.warning("Usando prompt original como guion debido al error de generaci贸n.")
179
  return prompt.strip()
180
 
181
- async def text_to_speech(text, output_path, voice):
182
- global tts_model
183
- logger.info(f"Convirtiendo texto a voz | Caracteres: {len(text)} | Voz: {voice} | Salida: {output_path}")
184
  if not text or not text.strip():
185
  logger.warning("Texto vac铆o para TTS")
186
  return False
187
  try:
188
- # Inicializar el modelo TTS si no est谩 cargado
189
- if 'tts_model' not in globals() or tts_model is None:
190
- logger.info("Inicializando modelo Coqui XTTS v2...")
191
- tts_model = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
192
- logger.info("Modelo Coqui XTTS v2 cargado exitosamente")
193
 
194
- # Generar el audio
195
- logger.info("Generando audio con Coqui XTTS v2...")
196
- tts_model.tts_to_file(
197
- text=text,
198
- file_path=output_path,
199
- language="es"
200
- )
201
-
202
- # Verificar que el archivo se cre贸 correctamente
203
  if os.path.exists(output_path) and os.path.getsize(output_path) > 100:
204
- logger.info(f"Audio guardado exitosamente en: {output_path} | Tama帽o: {os.path.getsize(output_path)} bytes")
205
  return True
206
  else:
207
- logger.error(f"TTS guard贸 un archivo peque帽o o vac铆o en: {output_path}")
208
  return False
209
 
210
  except Exception as e:
211
- logger.error(f"Error en TTS con Coqui: {str(e)}", exc_info=True)
212
  return False
 
 
213
 
214
  def download_video_file(url, temp_dir):
215
  if not url:
 
178
  logger.warning("Usando prompt original como guion debido al error de generaci贸n.")
179
  return prompt.strip()
180
 
181
+ def text_to_speech(text, output_path, voice):
182
+ logger.info(f"Convirtiendo texto a voz | Caracteres: {len(text)} | Salida: {output_path}")
 
183
  if not text or not text.strip():
184
  logger.warning("Texto vac铆o para TTS")
185
  return False
186
  try:
187
+ # Usar modelo simple que funciona
188
+ tts = TTS(model_name="tts_models/es/css10/vits")
189
+ tts.tts_to_file(text=text, file_path=output_path)
 
 
190
 
191
+ # Verificar archivo
 
 
 
 
 
 
 
 
192
  if os.path.exists(output_path) and os.path.getsize(output_path) > 100:
193
+ logger.info(f"Audio creado: {output_path}")
194
  return True
195
  else:
196
+ logger.error("Archivo de audio vac铆o")
197
  return False
198
 
199
  except Exception as e:
200
+ logger.error(f"Error TTS: {str(e)}")
201
  return False
202
+
203
+ #FIN DE ESTA MIERDA
204
 
205
  def download_video_file(url, temp_dir):
206
  if not url: