gnosticdev commited on
Commit
699f300
·
verified ·
1 Parent(s): 762f22c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -178,26 +178,34 @@ 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
- 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
 
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=None): # Eliminamos el parámetro voice no utilizado
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
+
187
  try:
188
+ # Usar modelo TTS explícitamente soportado
189
+ tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False)
 
190
 
191
+ # Verificar si el texto es válido y no excede límites
192
+ if len(text) > 500: # Límite típico para TTS
193
+ logger.warning("Texto demasiado largo, truncando a 500 caracteres")
194
+ text = text[:500]
195
+
196
+ # Generar audio
197
+ tts.tts_to_file(text=text, file_path=output_path, language="es")
198
+
199
+ # Verificar archivo generado
200
+ if os.path.exists(output_path) and os.path.getsize(output_path) > 1000:
201
+ logger.info(f"Audio creado: {output_path} | Tamaño: {os.path.getsize(output_path)} bytes")
202
  return True
203
  else:
204
+ logger.error("Archivo de audio vacío o no creado")
205
  return False
206
 
207
  except Exception as e:
208
+ logger.error(f"Error TTS: {str(e)}", exc_info=True)
209
  return False
210
 
211
  #FIN DE ESTA MIERDA