check changelog tab for new update
Browse files
app.py
CHANGED
@@ -194,6 +194,31 @@ def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration,
|
|
194 |
time.sleep(2)
|
195 |
return "Process done successfully! Check below for zipped files!", zip_file_name
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
198 |
gr.HTML(
|
199 |
"<h1> Welcome to the GDMGS! (GlobalDatasetMaker Gradio Space) </h1>"
|
@@ -286,7 +311,21 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
286 |
[ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files],
|
287 |
[gr.Text(label="Result"), gr.File(label="Zipped files")]
|
288 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
with gr.TabItem("Changelog"):
|
|
|
290 |
gr.Markdown("v0.93 - Removed obsolete warnings and fixed issue with all-in-one if output.mp3 or output.wav doesnt exist.")
|
291 |
gr.Markdown("v0.92 - Added all-in-one tab under Misc Tools.")
|
292 |
gr.Markdown("v0.91 - Added mp3 file support for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
|
|
|
194 |
time.sleep(2)
|
195 |
return "Process done successfully! Check below for zipped files!", zip_file_name
|
196 |
|
197 |
+
def download_video_as_audio_only(yt_video, audio_output_format):
|
198 |
+
try:
|
199 |
+
yt = YouTube(yt_video)
|
200 |
+
except pytube.exceptions.RegexMatchError:
|
201 |
+
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
202 |
+
video = yt.streams.get_highest_resolution()
|
203 |
+
video.download()
|
204 |
+
video_path = f"{video.default_filename}"
|
205 |
+
video_clip = VideoFileClip(video_path)
|
206 |
+
audio_clip = video_clip.audio
|
207 |
+
if audio_output_format == "wav":
|
208 |
+
audio_clip.write_audiofile("output.wav")
|
209 |
+
elif audio_output_format == "mp3":
|
210 |
+
audio_clip.write_audiofile("output.mp3")
|
211 |
+
audio_clip.close()
|
212 |
+
video_clip.close()
|
213 |
+
for mp4remove in glob.glob("*.mp4"):
|
214 |
+
os.remove(mp4remove)
|
215 |
+
single_zip_name = "only_audio.zip"
|
216 |
+
audio_files = glob.glob("*.wav")
|
217 |
+
with zipfile.ZipFile(single_zip_name, 'w') as zip_file:
|
218 |
+
for audio_file in audio_files:
|
219 |
+
zip_file.write(audio_file, os.path.basename(audio_file))
|
220 |
+
return "Done! Download the zip file below! This only contains the audio file.", single_zip_name
|
221 |
+
|
222 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
223 |
gr.HTML(
|
224 |
"<h1> Welcome to the GDMGS! (GlobalDatasetMaker Gradio Space) </h1>"
|
|
|
311 |
[ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files],
|
312 |
[gr.Text(label="Result"), gr.File(label="Zipped files")]
|
313 |
)
|
314 |
+
with gr.Tab("Audio only download"):
|
315 |
+
gr.Markdown("If you want to download only the audio (to isolate bgm using UVR, etc), use this method, which will only extract audio and not split the audio.")
|
316 |
+
with gr.Row():
|
317 |
+
with gr.Column():
|
318 |
+
with gr.Row():
|
319 |
+
yt_video = gr.Textbox(label="URL")
|
320 |
+
audio_output_format = gr.Radio(["wav", "mp3"], value="wav", label="Download audio as:")
|
321 |
+
commence_download = gr.Button("Download", variant='primary')
|
322 |
+
commence_download.click(
|
323 |
+
download_video_as_audio_only,
|
324 |
+
[yt_video, audio_output_format],
|
325 |
+
[gr.Text(label="Output"), gr.File(label="Zipped audio file")]
|
326 |
+
)
|
327 |
with gr.TabItem("Changelog"):
|
328 |
+
gr.Markdown("v0.94 - Added new tool: YouTube-to-audio.")
|
329 |
gr.Markdown("v0.93 - Removed obsolete warnings and fixed issue with all-in-one if output.mp3 or output.wav doesnt exist.")
|
330 |
gr.Markdown("v0.92 - Added all-in-one tab under Misc Tools.")
|
331 |
gr.Markdown("v0.91 - Added mp3 file support for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
|