gnosticdev commited on
Commit
6ba3337
·
verified ·
1 Parent(s): 699f300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -178,18 +178,19 @@ 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=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
 
 
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):
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 un modelo ligero compatible con CPU
189
+ tts = TTS(model_name="tts_models/es/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)
190
 
191
+ # Limpiar y truncar texto
192
+ text = re.sub(r'[^\w\s.,!?áéíóúñÁÉÍÓÚÑ]', '', text)
193
+ if len(text) > 500:
194
  logger.warning("Texto demasiado largo, truncando a 500 caracteres")
195
  text = text[:500]
196