Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -168,11 +168,15 @@ async def process_video(voice, video_url, text, progress=gr.Progress()):
|
|
168 |
os.remove(f"temp_video_{session_id}.mp4")
|
169 |
|
170 |
def create_interface():
|
|
|
|
|
|
|
|
|
171 |
with gr.Blocks() as app:
|
172 |
gr.Markdown("# JSON Train")
|
173 |
with gr.Row():
|
174 |
with gr.Column():
|
175 |
-
voice_dropdown = gr.Dropdown(label="Select Voice")
|
176 |
video_url_input = gr.Textbox(label="Enter Video URL")
|
177 |
text_input = gr.Textbox(label="Enter text", lines=3)
|
178 |
generate_btn = gr.Button("Generate Video")
|
@@ -187,12 +191,6 @@ def create_interface():
|
|
187 |
return None, "Invalid voice selected."
|
188 |
return await process_video(voice_id, video_url, text)
|
189 |
|
190 |
-
async def populate_voices():
|
191 |
-
voices = await get_voices()
|
192 |
-
return gr.Dropdown.update(choices=[v[1] for v in voices], value=voices[0][1] if voices else None)
|
193 |
-
|
194 |
-
app.load(populate_voices, outputs=[voice_dropdown])
|
195 |
-
|
196 |
generate_btn.click(
|
197 |
fn=on_generate,
|
198 |
inputs=[voice_dropdown, video_url_input, text_input],
|
@@ -203,4 +201,4 @@ def create_interface():
|
|
203 |
|
204 |
if __name__ == "__main__":
|
205 |
app = create_interface()
|
206 |
-
app.launch(
|
|
|
168 |
os.remove(f"temp_video_{session_id}.mp4")
|
169 |
|
170 |
def create_interface():
|
171 |
+
async def populate_voices():
|
172 |
+
voices = await get_voices()
|
173 |
+
return [v[1] for v in voices]
|
174 |
+
|
175 |
with gr.Blocks() as app:
|
176 |
gr.Markdown("# JSON Train")
|
177 |
with gr.Row():
|
178 |
with gr.Column():
|
179 |
+
voice_dropdown = gr.Dropdown(label="Select Voice", choices=asyncio.run(populate_voices()))
|
180 |
video_url_input = gr.Textbox(label="Enter Video URL")
|
181 |
text_input = gr.Textbox(label="Enter text", lines=3)
|
182 |
generate_btn = gr.Button("Generate Video")
|
|
|
191 |
return None, "Invalid voice selected."
|
192 |
return await process_video(voice_id, video_url, text)
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
generate_btn.click(
|
195 |
fn=on_generate,
|
196 |
inputs=[voice_dropdown, video_url_input, text_input],
|
|
|
201 |
|
202 |
if __name__ == "__main__":
|
203 |
app = create_interface()
|
204 |
+
app.launch()
|