testdeep123 commited on
Commit
f4cac3a
Β·
verified Β·
1 Parent(s): 2052adf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -4
app.py CHANGED
@@ -855,14 +855,58 @@ def generate_video(user_input, resolution, caption_option):
855
 
856
 
857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
858
  def handle_music_upload(music_file):
859
  if music_file is not None:
860
  target_path = "music.mp3"
861
  shutil.copy(music_file, target_path)
862
  print(f"Uploaded music saved as: {target_path}")
863
 
864
- def generate_video_with_music(user_input, resolution, caption_option, music_file):
865
  handle_music_upload(music_file)
 
 
 
 
 
 
 
866
  return generate_video(user_input, resolution, caption_option)
867
 
868
  iface = gr.Interface(
@@ -871,12 +915,13 @@ iface = gr.Interface(
871
  gr.Textbox(label="Video Concept", placeholder="Enter your video concept here..."),
872
  gr.Radio(["Full", "Short"], label="Resolution", value="Full"),
873
  gr.Radio(["Yes", "No"], label="Captions", value="Yes"),
874
- gr.File(label="Upload Background Music (MP3)", file_types=[".mp3"])
 
 
875
  ],
876
  outputs=gr.Video(label="Generated Video"),
877
  title="AI Documentary Video Generator",
878
- description="Upload your background music and create a funny documentary-style video."
879
  )
880
 
881
  iface.launch(share=True)
882
-
 
855
 
856
 
857
 
858
+ import gradio as gr
859
+ import shutil
860
+ import os
861
+ import random
862
+
863
+ # Human-friendly voice list
864
+ VOICE_CHOICES = {
865
+ 'Emma (Female)': 'af_heart',
866
+ 'Bella (Female)': 'af_bella',
867
+ 'Nicole (Female)': 'af_nicole',
868
+ 'Aoede (Female)': 'af_aoede',
869
+ 'Kore (Female)': 'af_kore',
870
+ 'Sarah (Female)': 'af_sarah',
871
+ 'Nova (Female)': 'af_nova',
872
+ 'Sky (Female)': 'af_sky',
873
+ 'Alloy (Female)': 'af_alloy',
874
+ 'Jessica (Female)': 'af_jessica',
875
+ 'River (Female)': 'af_river',
876
+ 'Michael (Male)': 'am_michael',
877
+ 'Fenrir (Male)': 'am_fenrir',
878
+ 'Puck (Male)': 'am_puck',
879
+ 'Echo (Male)': 'am_echo',
880
+ 'Eric (Male)': 'am_eric',
881
+ 'Liam (Male)': 'am_liam',
882
+ 'Onyx (Male)': 'am_onyx',
883
+ 'Santa (Male)': 'am_santa',
884
+ 'Adam (Male)': 'am_adam',
885
+ 'Emma πŸ‡¬πŸ‡§ (Female)': 'bf_emma',
886
+ 'Isabella πŸ‡¬πŸ‡§ (Female)': 'bf_isabella',
887
+ 'Alice πŸ‡¬πŸ‡§ (Female)': 'bf_alice',
888
+ 'Lily πŸ‡¬πŸ‡§ (Female)': 'bf_lily',
889
+ 'George πŸ‡¬πŸ‡§ (Male)': 'bm_george',
890
+ 'Fable πŸ‡¬πŸ‡§ (Male)': 'bm_fable',
891
+ 'Lewis πŸ‡¬πŸ‡§ (Male)': 'bm_lewis',
892
+ 'Daniel πŸ‡¬πŸ‡§ (Male)': 'bm_daniel'
893
+ }
894
+
895
  def handle_music_upload(music_file):
896
  if music_file is not None:
897
  target_path = "music.mp3"
898
  shutil.copy(music_file, target_path)
899
  print(f"Uploaded music saved as: {target_path}")
900
 
901
+ def generate_video_with_music(user_input, resolution, caption_option, music_file, voice, video_clip_probability):
902
  handle_music_upload(music_file)
903
+
904
+ # Set global or pass values to your other functions as needed:
905
+ selected_voice = VOICE_CHOICES[voice]
906
+ print(f"Selected Voice: {selected_voice}")
907
+ print(f"Video Clip Probability: {video_clip_probability}%")
908
+
909
+ # Your existing generate_video() call β€” you might want to pass the voice and clip probability
910
  return generate_video(user_input, resolution, caption_option)
911
 
912
  iface = gr.Interface(
 
915
  gr.Textbox(label="Video Concept", placeholder="Enter your video concept here..."),
916
  gr.Radio(["Full", "Short"], label="Resolution", value="Full"),
917
  gr.Radio(["Yes", "No"], label="Captions", value="Yes"),
918
+ gr.File(label="Upload Background Music (MP3)", file_types=[".mp3"]),
919
+ gr.Dropdown(choices=list(VOICE_CHOICES.keys()), label="Choose Voice", value="Emma (Female)"),
920
+ gr.Slider(0, 100, value=25, step=1, label="Video Clip Usage Probability (%)")
921
  ],
922
  outputs=gr.Video(label="Generated Video"),
923
  title="AI Documentary Video Generator",
924
+ description="Upload your background music, choose a voice, set video clip ratio, and create a funny AI documentary!"
925
  )
926
 
927
  iface.launch(share=True)