check changelog tab
Browse files
app.py
CHANGED
@@ -1,30 +1,48 @@
|
|
1 |
-
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, librosa, time, librosa, librosa.display, matplotlib.pyplot as plt, numpy as np, urllib.error
|
2 |
from pytube import YouTube
|
3 |
from moviepy.editor import VideoFileClip
|
4 |
|
5 |
-
def download_video(url, download_as):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
|
30 |
if show_amount_of_files_and_file_dur == True:
|
@@ -247,6 +265,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
247 |
with gr.Row():
|
248 |
url = gr.Textbox(label="URL")
|
249 |
download_as = gr.Radio(["wav", "mp3"], label="Audio format output", value="wav", info="What should the audio format be output as?")
|
|
|
250 |
convertion = gr.Button("Download", variant='primary')
|
251 |
convertion.click(
|
252 |
fn=download_video,
|
@@ -336,27 +355,8 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
336 |
gr.Image(label="Spectrogram result", show_download_button=False, scale=2)
|
337 |
)
|
338 |
with gr.TabItem("Changelog"):
|
|
|
339 |
gr.Markdown("v0.98.2 - Added new upcoming features tab.")
|
340 |
-
gr.Markdown("v0.98.1 - Reverted back due to none of the new features working apart from removing SR analyzer and adding new error checks.")
|
341 |
-
gr.Markdown("v0.97a - Fixed issue with spectrogram tab if no WAV file was selected.")
|
342 |
-
gr.Markdown("v0.97 - Added new spectrogram tool in Misc Tools and removed pitch analyzer as it did not fit with the purpose of this Space.")
|
343 |
-
gr.Markdown("v0.96 - Added new remaining files tool in Misc Tools.")
|
344 |
-
gr.Markdown("v0.95 - Fixed issue with mp3 files not downloading audio properly.")
|
345 |
-
gr.Markdown("v0.94a - Fixed issue with existing output.wav or output.mp3 files clashing with the split audio files with addition of the new tool.")
|
346 |
-
gr.Markdown("v0.94 - Added new tool: YouTube-to-audio.")
|
347 |
-
gr.Markdown("v0.93 - Removed obsolete warnings and fixed issue with all-in-one if output.mp3 or output.wav doesnt exist.")
|
348 |
-
gr.Markdown("v0.92 - Added all-in-one tab under Misc Tools.")
|
349 |
-
gr.Markdown("v0.91 - Added mp3 file support for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
|
350 |
-
gr.Markdown("v0.90a - Fixed bug that if 'show_amount_of_files_and_file_dur' was False, split wav files would not be deleted.")
|
351 |
-
gr.Markdown("v0.90 - Added mp3 support for downloading a Youtube video.")
|
352 |
-
gr.Markdown("v0.85 - Fixed bug in pitch analyzer if no audio file was given.")
|
353 |
-
gr.Markdown("v0.80 - Added new tool: Pitch Analyzer.")
|
354 |
-
gr.Markdown("v0.75 - Fixed bug that would cause split wav files to be packaged with the previously split wav files.")
|
355 |
-
gr.Markdown("v0.74 - Added new tool: WAV file splitter.")
|
356 |
-
gr.Markdown("v0.73 - Added Misc Tools tab and new Sample Rate analyzer tool.")
|
357 |
-
gr.Markdown("v0.70 - Fixed bug if no URL was passed or if the URL was invalid.")
|
358 |
-
gr.Markdown("v0.65 - Fixed bug if user tried to split an audio file when 'output.wav' didnt exist.")
|
359 |
-
gr.Markdown("v0.60 - Initial push to Huggingface Space.")
|
360 |
with gr.TabItem("Upcoming features"):
|
361 |
gr.HTML(
|
362 |
"""
|
|
|
1 |
+
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, librosa, time, librosa, librosa.display, matplotlib.pyplot as plt, numpy as np, urllib.error, traceback, yt_dlp
|
2 |
from pytube import YouTube
|
3 |
from moviepy.editor import VideoFileClip
|
4 |
|
5 |
+
def download_video(url, download_as, use_ytdlp):
|
6 |
+
if use_ytdlp == True:
|
7 |
+
try:
|
8 |
+
ydl_opts = {
|
9 |
+
'format': f"{download_as}/bestaudio/best",
|
10 |
+
'postprocessors': [{
|
11 |
+
'key': 'FFmpegExtractAudio',
|
12 |
+
'preferredcodec': download_as,
|
13 |
+
}]
|
14 |
+
}
|
15 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
16 |
+
ydl.download(url)
|
17 |
+
for i in glob.glob(f"*.{download_as}"):
|
18 |
+
if os.path.exists(i):
|
19 |
+
os.rename(i, f"output.{download_as}")
|
20 |
+
return "Finished downloading! Please proceed to next tab."
|
21 |
+
except:
|
22 |
+
raise gr.Error(traceback.format_exc())
|
23 |
+
else:
|
24 |
+
try:
|
25 |
+
yt = YouTube(url)
|
26 |
+
except pytube.exceptions.RegexMatchError:
|
27 |
+
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
28 |
+
except urllib.error.HTTPError as not_ok:
|
29 |
+
raise gr.Error(f"Recieved {not_ok}")
|
30 |
+
except pytube.exceptions.AgeRestrictedError:
|
31 |
+
raise gr.Error("The video you inputted is age-restricted! Please try another link.")
|
32 |
+
video = yt.streams.get_highest_resolution()
|
33 |
+
video.download()
|
34 |
+
video_path = f"{video.default_filename}"
|
35 |
+
video_clip = VideoFileClip(video_path)
|
36 |
+
audio_clip = video_clip.audio
|
37 |
+
if download_as == "wav":
|
38 |
+
audio_clip.write_audiofile("output.wav")
|
39 |
+
elif download_as == "mp3":
|
40 |
+
audio_clip.write_audiofile("output.mp3")
|
41 |
+
audio_clip.close()
|
42 |
+
video_clip.close()
|
43 |
+
for removalmp4 in glob.glob("*.mp4"):
|
44 |
+
os.remove(removalmp4)
|
45 |
+
return "Finished downloading! Please proceed to next tab."
|
46 |
|
47 |
def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
|
48 |
if show_amount_of_files_and_file_dur == True:
|
|
|
265 |
with gr.Row():
|
266 |
url = gr.Textbox(label="URL")
|
267 |
download_as = gr.Radio(["wav", "mp3"], label="Audio format output", value="wav", info="What should the audio format be output as?")
|
268 |
+
use_ytdlp = gr.Checkbox(False, label="Use yt_dlp instead of pytube?", info="Sometimes Pytube refuses to download a video. If that happens, check this box to download using yt_dlp instead.")
|
269 |
convertion = gr.Button("Download", variant='primary')
|
270 |
convertion.click(
|
271 |
fn=download_video,
|
|
|
355 |
gr.Image(label="Spectrogram result", show_download_button=False, scale=2)
|
356 |
)
|
357 |
with gr.TabItem("Changelog"):
|
358 |
+
gr.Markdown("v0.98.5 - Added an option to download yt link via yt_dlp if pytube cant download it.")
|
359 |
gr.Markdown("v0.98.2 - Added new upcoming features tab.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
with gr.TabItem("Upcoming features"):
|
361 |
gr.HTML(
|
362 |
"""
|