Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
from tts_module import get_voices, text_to_speech
|
3 |
from pexels_api import search_pexels
|
4 |
-
from moviepy.editor import AudioFileClip, VideoFileClip, CompositeAudioClip, concatenate_audioclips
|
5 |
|
6 |
-
|
7 |
-
import os
|
8 |
-
import requests
|
9 |
-
import tempfile
|
10 |
-
|
11 |
-
# Forzar instalación de moviepy si no está disponible
|
12 |
def install(package):
|
13 |
import subprocess
|
14 |
import sys
|
@@ -27,6 +21,11 @@ except ImportError:
|
|
27 |
except ImportError:
|
28 |
raise ImportError("Error crítico: No se pudo instalar moviepy.editor. Verifica las dependencias.")
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
# Ajustar música de fondo
|
31 |
def adjust_background_music(video_duration, music_file):
|
32 |
music = AudioFileClip(music_file)
|
@@ -61,12 +60,12 @@ def process_input(text, txt_file, mp3_file, prompt, selected_voice):
|
|
61 |
else:
|
62 |
return "No input provided", None
|
63 |
|
64 |
-
voices = asyncio.run(get_voices())
|
65 |
if selected_voice not in voices:
|
66 |
return f"La voz '{selected_voice}' no es válida. Por favor, seleccione una de las siguientes voces: {', '.join(voices.keys())}", None
|
67 |
|
68 |
try:
|
69 |
-
audio_file = asyncio.run(text_to_speech(final_text, selected_voice))
|
70 |
except Exception as e:
|
71 |
return f"Error con la voz seleccionada: {e}", None
|
72 |
|
@@ -103,7 +102,7 @@ with gr.Blocks() as demo:
|
|
103 |
txt_file_input = gr.File(label="Or upload a .txt file", file_types=[".txt"])
|
104 |
mp3_file_input = gr.File(label="Upload background music (.mp3)", file_types=[".mp3"])
|
105 |
prompt_input = gr.Textbox(label="Or enter a prompt to generate text")
|
106 |
-
voices = asyncio.run(get_voices())
|
107 |
voice_dropdown = gr.Dropdown(choices=list(voices.keys()), label="Select Voice")
|
108 |
|
109 |
with gr.Column():
|
|
|
1 |
import gradio as gr
|
2 |
+
from tts_module import get_voices, text_to_speech
|
3 |
from pexels_api import search_pexels
|
|
|
4 |
|
5 |
+
# Forzar instalación de paquetes si no están disponibles
|
|
|
|
|
|
|
|
|
|
|
6 |
def install(package):
|
7 |
import subprocess
|
8 |
import sys
|
|
|
21 |
except ImportError:
|
22 |
raise ImportError("Error crítico: No se pudo instalar moviepy.editor. Verifica las dependencias.")
|
23 |
|
24 |
+
import asyncio
|
25 |
+
import os
|
26 |
+
import requests
|
27 |
+
import tempfile
|
28 |
+
|
29 |
# Ajustar música de fondo
|
30 |
def adjust_background_music(video_duration, music_file):
|
31 |
music = AudioFileClip(music_file)
|
|
|
60 |
else:
|
61 |
return "No input provided", None
|
62 |
|
63 |
+
voices = asyncio.run(get_voices())
|
64 |
if selected_voice not in voices:
|
65 |
return f"La voz '{selected_voice}' no es válida. Por favor, seleccione una de las siguientes voces: {', '.join(voices.keys())}", None
|
66 |
|
67 |
try:
|
68 |
+
audio_file = asyncio.run(text_to_speech(final_text, selected_voice))
|
69 |
except Exception as e:
|
70 |
return f"Error con la voz seleccionada: {e}", None
|
71 |
|
|
|
102 |
txt_file_input = gr.File(label="Or upload a .txt file", file_types=[".txt"])
|
103 |
mp3_file_input = gr.File(label="Upload background music (.mp3)", file_types=[".mp3"])
|
104 |
prompt_input = gr.Textbox(label="Or enter a prompt to generate text")
|
105 |
+
voices = asyncio.run(get_voices())
|
106 |
voice_dropdown = gr.Dropdown(choices=list(voices.keys()), label="Select Voice")
|
107 |
|
108 |
with gr.Column():
|