sheikhed commited on
Commit
2ab6277
·
verified ·
1 Parent(s): bda2d20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -172,6 +172,12 @@ def create_interface():
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():
@@ -180,13 +186,17 @@ def create_interface():
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")
183
- return None, "Invalid voice selected."
184
- return await process_video(voice_id, video_url, text)
185
 
186
  generate_btn.click(
187
  fn=on_generate,
188
  inputs=[voice_dropdown, video_url_input, text_input],
 
 
 
 
189
 
190
  if __name__ == "__main__":
191
  app = create_interface()
 
192
  app.launch()
 
172
  voices = await get_voices()
173
  return [v[1] for v in voices]
174
 
175
+ async def on_generate(voice, video_url, text):
176
+ if not voice:
177
+ return None, "Invalid voice selected."
178
+ voice_id = next(v[0] for v in await get_voices() if v[1] == voice)
179
+ return await process_video(voice_id, video_url, text)
180
+
181
  with gr.Blocks() as app:
182
  gr.Markdown("# JSON Train")
183
  with gr.Row():
 
186
  video_url_input = gr.Textbox(label="Enter Video URL")
187
  text_input = gr.Textbox(label="Enter text", lines=3)
188
  generate_btn = gr.Button("Generate Video")
189
+ output = gr.Textbox(label="Output")
 
190
 
191
  generate_btn.click(
192
  fn=on_generate,
193
  inputs=[voice_dropdown, video_url_input, text_input],
194
+ outputs=[output]
195
+ )
196
+
197
+ return app
198
 
199
  if __name__ == "__main__":
200
  app = create_interface()
201
+ app.queue(concurrency_count=5) # Allow 5 concurrent tasks
202
  app.launch()