Spaces:
Sleeping
Sleeping
Commit ·
983a76a
1
Parent(s): 1ab91a2
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from moviepy.editor import vfx
|
|
| 9 |
from streamlit_option_menu import option_menu
|
| 10 |
from youtube import youtube, download_youtube
|
| 11 |
from moviepy.video.io.VideoFileClip import VideoFileClip
|
| 12 |
-
from dub import
|
| 13 |
|
| 14 |
def session(info_list):
|
| 15 |
st.video(info_list[1])
|
|
@@ -17,7 +17,7 @@ def session(info_list):
|
|
| 17 |
if len(info_list) == 5:
|
| 18 |
st.text(f"Duration: {info_list[3]} - {info_list[4]} seconds")
|
| 19 |
|
| 20 |
-
dub_segments = st.checkbox("
|
| 21 |
|
| 22 |
def random_cuts_dubbed(video_file, title, num_cuts=1, duration=60, speed_factor=1.0, mute_audio=False, use_9_16=False, dub_segments=False):
|
| 23 |
clip = VideoFileClip(video_file)
|
|
@@ -63,12 +63,12 @@ def random_cuts_dubbed(video_file, title, num_cuts=1, duration=60, speed_factor=
|
|
| 63 |
|
| 64 |
with st.spinner(f'Processing video {i+1} of {num_cuts}...'):
|
| 65 |
if dub_segments:
|
| 66 |
-
#
|
| 67 |
dubbed_info = transcribe_and_dub(output_file)
|
| 68 |
st.write(dubbed_info)
|
| 69 |
output_files.append(dubbed_info.split(":")[-1].strip())
|
| 70 |
else:
|
| 71 |
-
#
|
| 72 |
clipped_clip.write_videofile(output_file, codec="libx264", audio_codec="aac", verbose=False)
|
| 73 |
output_files.append(output_file)
|
| 74 |
|
|
@@ -117,16 +117,4 @@ if choice == 'Cut Video':
|
|
| 117 |
if st.button(f"Download and Cut {seleccionado}"):
|
| 118 |
video_file, title_video, video_info, thumbnail_file = funcion(video_link)
|
| 119 |
|
| 120 |
-
cut_files, cuts = random_cuts_dubbed(video_file, title_video, num_cuts=num_cuts, duration=duration_slider, speed_factor=speed_factor, mute_audio=mute_audio, use_9_16=
|
| 121 |
-
|
| 122 |
-
for i, cut_file in enumerate(cut_files):
|
| 123 |
-
file_size = os.path.getsize(cut_file)
|
| 124 |
-
info_list = [f"{title_video}_cut_{i+1}", cut_file, thumbnail_file, cuts[i][0], cuts[i][1]]
|
| 125 |
-
session(info_list)
|
| 126 |
-
|
| 127 |
-
if dub_segments:
|
| 128 |
-
st.write("Dubbing dubbed segments...")
|
| 129 |
-
download_all_button(cut_files)
|
| 130 |
-
else:
|
| 131 |
-
st.write("Downloading original segments...")
|
| 132 |
-
download_all_button(cut_files)
|
|
|
|
| 9 |
from streamlit_option_menu import option_menu
|
| 10 |
from youtube import youtube, download_youtube
|
| 11 |
from moviepy.video.io.VideoFileClip import VideoFileClip
|
| 12 |
+
from dub import transcribe_and_dub, text_to_speech, play_audio
|
| 13 |
|
| 14 |
def session(info_list):
|
| 15 |
st.video(info_list[1])
|
|
|
|
| 17 |
if len(info_list) == 5:
|
| 18 |
st.text(f"Duration: {info_list[3]} - {info_list[4]} seconds")
|
| 19 |
|
| 20 |
+
dub_segments = st.checkbox("Dub Segments")
|
| 21 |
|
| 22 |
def random_cuts_dubbed(video_file, title, num_cuts=1, duration=60, speed_factor=1.0, mute_audio=False, use_9_16=False, dub_segments=False):
|
| 23 |
clip = VideoFileClip(video_file)
|
|
|
|
| 63 |
|
| 64 |
with st.spinner(f'Processing video {i+1} of {num_cuts}...'):
|
| 65 |
if dub_segments:
|
| 66 |
+
# Transcribe and dub the segment
|
| 67 |
dubbed_info = transcribe_and_dub(output_file)
|
| 68 |
st.write(dubbed_info)
|
| 69 |
output_files.append(dubbed_info.split(":")[-1].strip())
|
| 70 |
else:
|
| 71 |
+
# Use the original file
|
| 72 |
clipped_clip.write_videofile(output_file, codec="libx264", audio_codec="aac", verbose=False)
|
| 73 |
output_files.append(output_file)
|
| 74 |
|
|
|
|
| 117 |
if st.button(f"Download and Cut {seleccionado}"):
|
| 118 |
video_file, title_video, video_info, thumbnail_file = funcion(video_link)
|
| 119 |
|
| 120 |
+
cut_files, cuts = random_cuts_dubbed(video_file, title_video, num_cuts=num_cuts, duration=duration_slider, speed_factor=speed_factor, mute_audio=mute_audio, use_9_16=use_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|