Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,6 @@ import math
|
|
32 |
import shutil
|
33 |
import json
|
34 |
from collections import Counter
|
35 |
-
import time
|
36 |
|
37 |
# Configuración de logging
|
38 |
logging.basicConfig(
|
@@ -495,8 +494,7 @@ async def crear_video_async(prompt_type, input_text, selected_voice, musica_file
|
|
495 |
if not moviepy:
|
496 |
logger.warning("MoviePy no disponible, retornando placeholder...")
|
497 |
output_filename = f"video_{int(datetime.now().timestamp())}.mp4"
|
498 |
-
persistent_path = os.path.join(
|
499 |
-
os.makedirs("/data", exist_ok=True)
|
500 |
open(persistent_path, 'a').close() # Crea archivo vacío como placeholder
|
501 |
download_url = f"https://gnosticdev-invideo-basic.hf.space/file={persistent_path}"
|
502 |
return persistent_path, download_url
|
@@ -565,9 +563,6 @@ async def crear_video_async(prompt_type, input_text, selected_voice, musica_file
|
|
565 |
video_final = video_base.set_audio(final_audio)
|
566 |
output_filename = f"video_{int(datetime.now().timestamp())}.mp4"
|
567 |
output_path = os.path.join(temp_dir_intermediate, output_filename)
|
568 |
-
persistent_dir = "/data"
|
569 |
-
os.makedirs(persistent_dir, exist_ok=True)
|
570 |
-
persistent_path = os.path.join(persistent_dir, output_filename)
|
571 |
|
572 |
video_final.write_videofile(
|
573 |
output_path,
|
@@ -580,13 +575,12 @@ async def crear_video_async(prompt_type, input_text, selected_voice, musica_file
|
|
580 |
logger='bar'
|
581 |
)
|
582 |
|
583 |
-
|
584 |
-
|
585 |
-
logger.info(f"Video guardado en: {persistent_path}")
|
586 |
logger.info(f"URL de descarga: {download_url}")
|
587 |
total_time = (datetime.now() - start_time).total_seconds()
|
588 |
logger.info(f"Video generado en {total_time:.2f}s")
|
589 |
-
return
|
590 |
|
591 |
except ValueError as ve:
|
592 |
logger.error(f"Error controlado: {str(ve)}")
|
@@ -626,16 +620,11 @@ async def crear_video_async(prompt_type, input_text, selected_voice, musica_file
|
|
626 |
except:
|
627 |
pass
|
628 |
for path in temp_intermediate_files:
|
629 |
-
if os.path.isfile(path) and path !=
|
630 |
try:
|
631 |
os.remove(path)
|
632 |
except:
|
633 |
logger.warning(f"No se pudo eliminar {path}")
|
634 |
-
try:
|
635 |
-
if os.path.exists(temp_dir_intermediate):
|
636 |
-
shutil.rmtree(temp_dir_intermediate)
|
637 |
-
except:
|
638 |
-
logger.warning(f"No se pudo eliminar directorio temporal {temp_dir_intermediate}")
|
639 |
|
640 |
async def run_app_async(prompt_type, prompt_ia, prompt_manual, musica_file, selected_voice):
|
641 |
logger.info("="*80)
|
@@ -668,7 +657,7 @@ async def run_app_async(prompt_type, prompt_ia, prompt_manual, musica_file, sele
|
|
668 |
if video_path and os.path.exists(video_path):
|
669 |
output_video = video_path
|
670 |
output_file = video_path
|
671 |
-
status_msg = gr.update(value=f"✅ Video generado exitosamente. Descarga: {download_url}")
|
672 |
logger.info(f"Retornando video_path: {video_path}, URL: {download_url}")
|
673 |
return output_video, gr.File(value=output_file, label="Descargar Video"), status_msg
|
674 |
else:
|
@@ -785,7 +774,7 @@ with gr.Blocks(title="Generador de Videos con IA", theme=gr.themes.Soft()) as ap
|
|
785 |
3. Sube música (opcional).
|
786 |
4. Selecciona la voz.
|
787 |
5. Haz clic en "✨ Generar Video".
|
788 |
-
6. Revisa el estado. Si el video se genera, estará disponible en /
|
789 |
7. Consulta `video_generator_full.log` para detalles.
|
790 |
""")
|
791 |
|
|
|
32 |
import shutil
|
33 |
import json
|
34 |
from collections import Counter
|
|
|
35 |
|
36 |
# Configuración de logging
|
37 |
logging.basicConfig(
|
|
|
494 |
if not moviepy:
|
495 |
logger.warning("MoviePy no disponible, retornando placeholder...")
|
496 |
output_filename = f"video_{int(datetime.now().timestamp())}.mp4"
|
497 |
+
persistent_path = os.path.join(temp_dir_intermediate, output_filename)
|
|
|
498 |
open(persistent_path, 'a').close() # Crea archivo vacío como placeholder
|
499 |
download_url = f"https://gnosticdev-invideo-basic.hf.space/file={persistent_path}"
|
500 |
return persistent_path, download_url
|
|
|
563 |
video_final = video_base.set_audio(final_audio)
|
564 |
output_filename = f"video_{int(datetime.now().timestamp())}.mp4"
|
565 |
output_path = os.path.join(temp_dir_intermediate, output_filename)
|
|
|
|
|
|
|
566 |
|
567 |
video_final.write_videofile(
|
568 |
output_path,
|
|
|
575 |
logger='bar'
|
576 |
)
|
577 |
|
578 |
+
download_url = f"https://gnosticdev-invideo-basic.hf.space/file={output_path}"
|
579 |
+
logger.info(f"Video guardado en: {output_path}")
|
|
|
580 |
logger.info(f"URL de descarga: {download_url}")
|
581 |
total_time = (datetime.now() - start_time).total_seconds()
|
582 |
logger.info(f"Video generado en {total_time:.2f}s")
|
583 |
+
return output_path, download_url
|
584 |
|
585 |
except ValueError as ve:
|
586 |
logger.error(f"Error controlado: {str(ve)}")
|
|
|
620 |
except:
|
621 |
pass
|
622 |
for path in temp_intermediate_files:
|
623 |
+
if os.path.isfile(path) and path != output_path:
|
624 |
try:
|
625 |
os.remove(path)
|
626 |
except:
|
627 |
logger.warning(f"No se pudo eliminar {path}")
|
|
|
|
|
|
|
|
|
|
|
628 |
|
629 |
async def run_app_async(prompt_type, prompt_ia, prompt_manual, musica_file, selected_voice):
|
630 |
logger.info("="*80)
|
|
|
657 |
if video_path and os.path.exists(video_path):
|
658 |
output_video = video_path
|
659 |
output_file = video_path
|
660 |
+
status_msg = gr.update(value=f"✅ Video generado exitosamente. Descarga: {download_url} (Nota: Archivos en /tmp son temporales, descárgalo pronto)")
|
661 |
logger.info(f"Retornando video_path: {video_path}, URL: {download_url}")
|
662 |
return output_video, gr.File(value=output_file, label="Descargar Video"), status_msg
|
663 |
else:
|
|
|
774 |
3. Sube música (opcional).
|
775 |
4. Selecciona la voz.
|
776 |
5. Haz clic en "✨ Generar Video".
|
777 |
+
6. Revisa el estado. Si el video se genera, estará disponible en /tmp (descárgalo pronto, es temporal).
|
778 |
7. Consulta `video_generator_full.log` para detalles.
|
779 |
""")
|
780 |
|