Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
import asyncio
|
| 3 |
import logging
|
| 4 |
import tempfile
|
| 5 |
import requests
|
|
@@ -37,7 +36,6 @@ logger.info("="*80)
|
|
| 37 |
PEXELS_API_KEY = os.environ.get("PEXELS_API_KEY")
|
| 38 |
if not PEXELS_API_KEY:
|
| 39 |
logger.critical("NO SE ENCONTR脫 PEXELS_API_KEY EN VARIABLES DE ENTORNO")
|
| 40 |
-
# raise ValueError("API key de Pexels no configurada")
|
| 41 |
|
| 42 |
# Inicializaci贸n de modelos
|
| 43 |
MODEL_NAME = "datificate/gpt2-small-spanish"
|
|
@@ -746,14 +744,24 @@ def crear_video(prompt_type, input_text, musica_file=None):
|
|
| 746 |
output_path = os.path.join(temp_dir_intermediate, output_filename)
|
| 747 |
logger.info(f"Escribiendo video final a: {output_path}")
|
| 748 |
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 757 |
|
| 758 |
total_time = (datetime.now() - start_time).total_seconds()
|
| 759 |
logger.info(f"PROCESO DE VIDEO FINALIZADO | Output: {output_path} | Tiempo total: {total_time:.2f}s")
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import logging
|
| 3 |
import tempfile
|
| 4 |
import requests
|
|
|
|
| 36 |
PEXELS_API_KEY = os.environ.get("PEXELS_API_KEY")
|
| 37 |
if not PEXELS_API_KEY:
|
| 38 |
logger.critical("NO SE ENCONTR脫 PEXELS_API_KEY EN VARIABLES DE ENTORNO")
|
|
|
|
| 39 |
|
| 40 |
# Inicializaci贸n de modelos
|
| 41 |
MODEL_NAME = "datificate/gpt2-small-spanish"
|
|
|
|
| 744 |
output_path = os.path.join(temp_dir_intermediate, output_filename)
|
| 745 |
logger.info(f"Escribiendo video final a: {output_path}")
|
| 746 |
|
| 747 |
+
# Verificar que output_path sea v谩lido
|
| 748 |
+
if not output_path or not isinstance(output_path, str):
|
| 749 |
+
logger.critical(f"output_path no es v谩lido: {output_path}")
|
| 750 |
+
raise ValueError("El nombre del archivo de salida no es v谩lido.")
|
| 751 |
+
|
| 752 |
+
try:
|
| 753 |
+
video_final.write_videofile(
|
| 754 |
+
filename=output_path, # Usar argumento nombrado para claridad
|
| 755 |
+
fps=24,
|
| 756 |
+
threads=4,
|
| 757 |
+
codec="libx264",
|
| 758 |
+
audio_codec="aac",
|
| 759 |
+
preset="medium",
|
| 760 |
+
logger='bar'
|
| 761 |
+
)
|
| 762 |
+
except Exception as e:
|
| 763 |
+
logger.critical(f"Error al escribir el video final: {str(e)}", exc_info=True)
|
| 764 |
+
raise ValueError(f"Fallo al escribir el video final: {str(e)}")
|
| 765 |
|
| 766 |
total_time = (datetime.now() - start_time).total_seconds()
|
| 767 |
logger.info(f"PROCESO DE VIDEO FINALIZADO | Output: {output_path} | Tiempo total: {total_time:.2f}s")
|