Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,11 +106,20 @@ def get_kw_model():
|
|
| 106 |
kw_model = KeyBERT("paraphrase-multilingual-MiniLM-L12-v2")
|
| 107 |
return kw_model
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
def get_tts_interface():
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
|
| 115 |
# ------------------- Funciones del Pipeline de Vídeo -------------------
|
| 116 |
def update_task_progress(task_id, message):
|
|
@@ -271,13 +280,12 @@ def worker(task_id: str, mode: str, topic: str, user_script: str, music: str | N
|
|
| 271 |
|
| 272 |
try:
|
| 273 |
text = topic if mode == "Generar Guion con IA" else user_script
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
raise NotImplementedError("La integración del motor TTS autocontenido requiere refactorización que no se ha completado.")
|
| 281 |
|
| 282 |
except Exception as e:
|
| 283 |
logger.error(f"Error en el worker para la tarea {task_id}: {e}", exc_info=True)
|
|
|
|
| 106 |
kw_model = KeyBERT("paraphrase-multilingual-MiniLM-L12-v2")
|
| 107 |
return kw_model
|
| 108 |
|
| 109 |
+
class DummyTTS:
|
| 110 |
+
def read(self, text, language="spa", accent="spa"):
|
| 111 |
+
sr = 22050
|
| 112 |
+
dur = max(2.0, min(20.0, len(text) / 10)) # 2–20s según el texto
|
| 113 |
+
t = np.linspace(0, dur, int(sr * dur), False)
|
| 114 |
+
freq = 200.0
|
| 115 |
+
wav = 0.2 * np.sin(2 * np.pi * freq * t).astype(np.float32)
|
| 116 |
+
return sr, wav
|
| 117 |
+
|
| 118 |
def get_tts_interface():
|
| 119 |
+
global tts_interface
|
| 120 |
+
if tts_interface is None:
|
| 121 |
+
tts_interface = DummyTTS()
|
| 122 |
+
return tts_interface
|
| 123 |
|
| 124 |
# ------------------- Funciones del Pipeline de Vídeo -------------------
|
| 125 |
def update_task_progress(task_id, message):
|
|
|
|
| 280 |
|
| 281 |
try:
|
| 282 |
text = topic if mode == "Generar Guion con IA" else user_script
|
| 283 |
+
result_tmp_path = build_video(text, mode == "Generar Guion con IA", music, task_id)
|
| 284 |
+
final_path = os.path.join(RESULTS_DIR, f"{task_id}.mp4")
|
| 285 |
+
shutil.copy2(result_tmp_path, final_path)
|
| 286 |
+
TASKS[task_id].update({"status": "done", "result": final_path})
|
| 287 |
+
shutil.rmtree(os.path.dirname(result_tmp_path))
|
| 288 |
+
|
|
|
|
| 289 |
|
| 290 |
except Exception as e:
|
| 291 |
logger.error(f"Error en el worker para la tarea {task_id}: {e}", exc_info=True)
|