Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -854,39 +854,29 @@ def generate_video(user_input, resolution, caption_option):
|
|
854 |
|
855 |
|
856 |
|
857 |
-
|
858 |
-
def save_as_music(file):
|
859 |
-
if file is None:
|
860 |
-
return "No file uploaded!"
|
861 |
-
|
862 |
-
new_filename = "music.mp3"
|
863 |
-
shutil.copy(file, new_filename)
|
864 |
-
return f"File saved as {new_filename}"
|
865 |
-
|
866 |
-
def generate_video(concept, resolution, captions):
|
867 |
-
# Dummy response — replace this with your real video generation code!
|
868 |
-
return "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
|
869 |
-
|
870 |
-
with gr.Blocks() as demo:
|
871 |
-
with gr.Tab("Upload MP3"):
|
872 |
-
mp3_input = gr.File(label="Upload MP3", file_types=[".mp3"])
|
873 |
-
mp3_output = gr.Textbox(label="Status")
|
874 |
-
upload_btn = gr.Button("Save as music.mp3")
|
875 |
-
upload_btn.click(save_as_music, inputs=mp3_input, outputs=mp3_output)
|
876 |
-
|
877 |
-
with gr.Tab("AI Video Generator"):
|
878 |
-
concept_input = gr.Textbox(label="Video Concept", placeholder="Enter your video concept here...")
|
879 |
-
resolution_input = gr.Radio(["Full", "Short"], label="Resolution", value="Full")
|
880 |
-
captions_input = gr.Radio(["Yes", "No"], label="Captions", value="Yes")
|
881 |
-
video_output = gr.Video(label="Generated Video")
|
882 |
-
generate_btn = gr.Button("Generate Video")
|
883 |
-
generate_btn.click(generate_video,
|
884 |
-
inputs=[concept_input, resolution_input, captions_input],
|
885 |
-
outputs=video_output)
|
886 |
-
|
887 |
-
demo.launch(share=True)
|
888 |
-
|
889 |
-
|
890 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
891 |
|
|
|
892 |
|
|
|
854 |
|
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(
|
869 |
+
fn=generate_video_with_music,
|
870 |
+
inputs=[
|
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 |
|