Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
182 |
-
|
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 |
-
#
|
189 |
-
|
190 |
-
|
191 |
-
tts_model = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
|
192 |
-
logger.info("Modelo Coqui XTTS v2 cargado exitosamente")
|
193 |
|
194 |
-
#
|
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
|
205 |
return True
|
206 |
else:
|
207 |
-
logger.error(
|
208 |
return False
|
209 |
|
210 |
except Exception as e:
|
211 |
-
logger.error(f"Error
|
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:
|