Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
188 |
-
tts = TTS(model_name="tts_models/
|
189 |
-
tts.tts_to_file(text=text, file_path=output_path)
|
190 |
|
191 |
-
# Verificar
|
192 |
-
if
|
193 |
-
logger.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|