Dy commited on
Commit
cdf6325
1 Parent(s): 5f8b70a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -309,10 +309,16 @@ def process_video(uploaded_file, prompt_user, prompt_input, voice_type="feminine
309
 
310
  # Rest of your imports and functions remain the same
311
 
312
- def regenerate(uploaded_file, edited_script):
 
 
 
 
 
 
313
 
314
  # Generate audio from text
315
- audio_filename = text_to_speech(edited_script, video_filename)
316
  print("audio", audio_filename)
317
 
318
  # Merge audio and video
@@ -324,7 +330,7 @@ def regenerate(uploaded_file, edited_script):
324
  os.unlink(video_filename)
325
  os.unlink(audio_filename)
326
 
327
- return final_video_filename, text
328
 
329
  with gr.Blocks() as demo:
330
 
@@ -352,7 +358,8 @@ with gr.Blocks() as demo:
352
 
353
 
354
  generate_btn.click(process_video, inputs=[video_input, prompt_user, prompt_input, voice_type], outputs=[output_file,output_voiceover])
355
- regenerate_btn.click(regenerate, inputs=[video_input, output_voiceover], outputs=[output_file,output_voiceover])
 
356
 
357
 
358
  demo.launch(auth=("admin", PASSWORD_AUTH))
 
309
 
310
  # Rest of your imports and functions remain the same
311
 
312
+ def regenerate(uploaded_file, edited_script, voice_type="feminine-american"):
313
+
314
+ if type(uploaded_file) == str:
315
+ video_filename = uploaded_file
316
+ else:
317
+ video_filename = uploaded_file.name
318
+ print("video", video_filename)
319
 
320
  # Generate audio from text
321
+ audio_filename = text_to_speech(edited_script, video_filename, voice_type)
322
  print("audio", audio_filename)
323
 
324
  # Merge audio and video
 
330
  os.unlink(video_filename)
331
  os.unlink(audio_filename)
332
 
333
+ return final_video_filename, edited_script
334
 
335
  with gr.Blocks() as demo:
336
 
 
358
 
359
 
360
  generate_btn.click(process_video, inputs=[video_input, prompt_user, prompt_input, voice_type], outputs=[output_file,output_voiceover])
361
+ regenerate_btn.click(regenerate, inputs=[video_input, output_voiceover, voice_type], outputs=[output_file,output_voiceover])
362
+
363
 
364
 
365
  demo.launch(auth=("admin", PASSWORD_AUTH))