Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -441,7 +441,7 @@ def apply_kenburns_effect(clip, target_resolution, effect_type=None):
|
|
441 |
elif effect_type == "up-left":
|
442 |
start_zoom = 1.0
|
443 |
end_zoom = 1.0
|
444 |
-
start_center = (max_offset_x + target_w / 2, max_offset_y + target_h / 2)
|
445 |
end_center = (target_w / 2, target_h / 2)
|
446 |
else:
|
447 |
raise ValueError(f"Unsupported effect_type: {effect_type}")
|
@@ -627,7 +627,7 @@ def handle_music_upload(music_file):
|
|
627 |
|
628 |
def generate_video(user_input, resolution, caption_option, voice_option, voice_speed, music_file, caption_color, caption_font_size, fps, preset, transition_effect, bitrate):
|
629 |
global TARGET_RESOLUTION, CAPTION_COLOR, CAPTION_FONT_SIZE, TEMP_FOLDER
|
630 |
-
import
|
631 |
# Set resolution
|
632 |
if resolution == "Full":
|
633 |
TARGET_RESOLUTION = (1920, 1080)
|
@@ -731,62 +731,53 @@ iface = gr.Interface(
|
|
731 |
gr.Dropdown(
|
732 |
["af_heart", "en_male", "en_female", "en_neutral"],
|
733 |
label="Voice Option",
|
734 |
-
value="af_heart"
|
735 |
-
info="Select the narration voice."
|
736 |
),
|
737 |
gr.Slider(
|
738 |
minimum=0.5,
|
739 |
maximum=1.5,
|
740 |
step=0.1,
|
741 |
label="Voice Speed",
|
742 |
-
value=0.9
|
743 |
-
info="Adjust the speed of the narration."
|
744 |
),
|
745 |
gr.File(
|
746 |
label="Upload Background Music (MP3)",
|
747 |
-
file_types=[".mp3"]
|
748 |
-
info="Upload an MP3 file for background music. It will be renamed to music.mp3."
|
749 |
),
|
750 |
gr.ColorPicker(
|
751 |
label="Caption Color",
|
752 |
-
value="#FFFFFF"
|
753 |
-
info="Choose the color for captions (used if Captions is Yes)."
|
754 |
),
|
755 |
gr.Slider(
|
756 |
minimum=20,
|
757 |
maximum=60,
|
758 |
step=1,
|
759 |
label="Caption Font Size",
|
760 |
-
value=45
|
761 |
-
info="Set the font size for captions."
|
762 |
),
|
763 |
gr.Slider(
|
764 |
minimum=24,
|
765 |
maximum=60,
|
766 |
step=1,
|
767 |
label="FPS",
|
768 |
-
value=30
|
769 |
-
info="Set the frames per second for the video."
|
770 |
),
|
771 |
gr.Dropdown(
|
772 |
["ultrafast", "veryfast", "fast", "medium", "slow"],
|
773 |
label="Encoding Preset",
|
774 |
-
value="veryfast"
|
775 |
-
info="Choose the encoding speed vs quality tradeoff."
|
776 |
),
|
777 |
gr.Dropdown(
|
778 |
["fade", "slide", "none"],
|
779 |
label="Transition Effect",
|
780 |
-
value="fade"
|
781 |
-
info="Select the transition effect between clips."
|
782 |
),
|
783 |
gr.Slider(
|
784 |
minimum=1000,
|
785 |
maximum=8000,
|
786 |
step=500,
|
787 |
label="Bitrate (kbps)",
|
788 |
-
value=4000
|
789 |
-
info="Set the video bitrate for quality control."
|
790 |
)
|
791 |
],
|
792 |
outputs=gr.Video(label="Generated Video"),
|
|
|
441 |
elif effect_type == "up-left":
|
442 |
start_zoom = 1.0
|
443 |
end_zoom = 1.0
|
444 |
+
start_center = (max_offset_x + target start_center = (max_offset_x + target_w / 2, max_offset_y + target_h / 2)
|
445 |
end_center = (target_w / 2, target_h / 2)
|
446 |
else:
|
447 |
raise ValueError(f"Unsupported effect_type: {effect_type}")
|
|
|
627 |
|
628 |
def generate_video(user_input, resolution, caption_option, voice_option, voice_speed, music_file, caption_color, caption_font_size, fps, preset, transition_effect, bitrate):
|
629 |
global TARGET_RESOLUTION, CAPTION_COLOR, CAPTION_FONT_SIZE, TEMP_FOLDER
|
630 |
+
import Shri
|
631 |
# Set resolution
|
632 |
if resolution == "Full":
|
633 |
TARGET_RESOLUTION = (1920, 1080)
|
|
|
731 |
gr.Dropdown(
|
732 |
["af_heart", "en_male", "en_female", "en_neutral"],
|
733 |
label="Voice Option",
|
734 |
+
value="af_heart"
|
|
|
735 |
),
|
736 |
gr.Slider(
|
737 |
minimum=0.5,
|
738 |
maximum=1.5,
|
739 |
step=0.1,
|
740 |
label="Voice Speed",
|
741 |
+
value=0.9
|
|
|
742 |
),
|
743 |
gr.File(
|
744 |
label="Upload Background Music (MP3)",
|
745 |
+
file_types=[".mp3"]
|
|
|
746 |
),
|
747 |
gr.ColorPicker(
|
748 |
label="Caption Color",
|
749 |
+
value="#FFFFFF"
|
|
|
750 |
),
|
751 |
gr.Slider(
|
752 |
minimum=20,
|
753 |
maximum=60,
|
754 |
step=1,
|
755 |
label="Caption Font Size",
|
756 |
+
value=45
|
|
|
757 |
),
|
758 |
gr.Slider(
|
759 |
minimum=24,
|
760 |
maximum=60,
|
761 |
step=1,
|
762 |
label="FPS",
|
763 |
+
value=30
|
|
|
764 |
),
|
765 |
gr.Dropdown(
|
766 |
["ultrafast", "veryfast", "fast", "medium", "slow"],
|
767 |
label="Encoding Preset",
|
768 |
+
value="veryfast"
|
|
|
769 |
),
|
770 |
gr.Dropdown(
|
771 |
["fade", "slide", "none"],
|
772 |
label="Transition Effect",
|
773 |
+
value="fade"
|
|
|
774 |
),
|
775 |
gr.Slider(
|
776 |
minimum=1000,
|
777 |
maximum=8000,
|
778 |
step=500,
|
779 |
label="Bitrate (kbps)",
|
780 |
+
value=4000
|
|
|
781 |
)
|
782 |
],
|
783 |
outputs=gr.Video(label="Generated Video"),
|