Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -855,12 +855,18 @@ def generate_video(user_input, resolution, caption_option):
|
|
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',
|
@@ -892,36 +898,47 @@ VOICE_CHOICES = {
|
|
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
|
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 |
-
#
|
910 |
return generate_video(user_input, resolution, caption_option)
|
911 |
|
912 |
iface = gr.Interface(
|
913 |
-
fn=
|
914 |
inputs=[
|
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
|
925 |
)
|
926 |
|
927 |
iface.launch(share=True)
|
|
|
|
855 |
|
856 |
|
857 |
|
858 |
+
|
859 |
+
|
860 |
+
|
861 |
+
|
862 |
+
|
863 |
+
|
864 |
+
|
865 |
+
|
866 |
import gradio as gr
|
867 |
import shutil
|
868 |
import os
|
|
|
869 |
|
|
|
870 |
VOICE_CHOICES = {
|
871 |
'Emma (Female)': 'af_heart',
|
872 |
'Bella (Female)': 'af_bella',
|
|
|
898 |
'Daniel 🇬🇧 (Male)': 'bm_daniel'
|
899 |
}
|
900 |
|
901 |
+
|
902 |
def handle_music_upload(music_file):
|
903 |
if music_file is not None:
|
904 |
target_path = "music.mp3"
|
905 |
shutil.copy(music_file, target_path)
|
906 |
print(f"Uploaded music saved as: {target_path}")
|
907 |
|
908 |
+
def generate_video_with_options(user_input, resolution, caption_option, music_file, voice, video_clip_probability, bg_music_volume, fps, preset, voice_speed, font_size):
|
909 |
handle_music_upload(music_file)
|
910 |
|
|
|
911 |
selected_voice = VOICE_CHOICES[voice]
|
912 |
print(f"Selected Voice: {selected_voice}")
|
913 |
print(f"Video Clip Probability: {video_clip_probability}%")
|
914 |
+
print(f"Music Volume: {bg_music_volume}")
|
915 |
+
print(f"FPS: {fps}")
|
916 |
+
print(f"Preset: {preset}")
|
917 |
+
print(f"Voice Speed: {voice_speed}")
|
918 |
+
print(f"Caption Font Size: {font_size}")
|
919 |
|
920 |
+
# Pass these to your video generator as needed
|
921 |
return generate_video(user_input, resolution, caption_option)
|
922 |
|
923 |
iface = gr.Interface(
|
924 |
+
fn=generate_video_with_options,
|
925 |
inputs=[
|
926 |
gr.Textbox(label="Video Concept", placeholder="Enter your video concept here..."),
|
927 |
gr.Radio(["Full", "Short"], label="Resolution", value="Full"),
|
928 |
gr.Radio(["Yes", "No"], label="Captions", value="Yes"),
|
929 |
gr.File(label="Upload Background Music (MP3)", file_types=[".mp3"]),
|
930 |
gr.Dropdown(choices=list(VOICE_CHOICES.keys()), label="Choose Voice", value="Emma (Female)"),
|
931 |
+
gr.Slider(0, 100, value=25, step=1, label="Video Clip Usage Probability (%)"),
|
932 |
+
gr.Slider(0.0, 1.0, value=0.08, step=0.01, label="Background Music Volume"),
|
933 |
+
gr.Slider(10, 60, value=30, step=1, label="Video FPS"),
|
934 |
+
gr.Dropdown(choices=["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow"], value="veryfast", label="Export Preset"),
|
935 |
+
gr.Slider(0.5, 1.5, value=0.9, step=0.05, label="Voice Speed"),
|
936 |
+
gr.Slider(20, 100, value=45, step=1, label="Caption Font Size")
|
937 |
],
|
938 |
outputs=gr.Video(label="Generated Video"),
|
939 |
title="AI Documentary Video Generator",
|
940 |
+
description="Upload music, choose voice, control video clips, volume, FPS, speed, captions."
|
941 |
)
|
942 |
|
943 |
iface.launch(share=True)
|
944 |
+
|