Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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):
|
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
|
189 |
-
tts = TTS(model_name="tts_models/
|
190 |
|
191 |
-
#
|
192 |
-
|
|
|
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 |
|