check changelog tab, this is a massive update
Browse files
app.py
CHANGED
@@ -7,6 +7,10 @@ def download_video(url, download_as):
|
|
7 |
yt = YouTube(url)
|
8 |
except pytube.exceptions.RegexMatchError:
|
9 |
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
|
|
|
|
|
|
|
|
10 |
video = yt.streams.get_highest_resolution()
|
11 |
video.download()
|
12 |
video_path = f"{video.default_filename}"
|
@@ -146,6 +150,10 @@ def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration,
|
|
146 |
yt = YouTube(ytvideo)
|
147 |
except pytube.exceptions.RegexMatchError:
|
148 |
raise gr.Error("URL not valid or was left empty! Please fix the link or enter one.")
|
|
|
|
|
|
|
|
|
149 |
video = yt.streams.get_highest_resolution()
|
150 |
video.download()
|
151 |
video_path = f"{video.default_filename}"
|
@@ -183,11 +191,15 @@ def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration,
|
|
183 |
time.sleep(2)
|
184 |
return "Process done successfully! Check below for zipped files!", zip_file_name
|
185 |
|
186 |
-
def download_video_as_audio_only(yt_video, audio_output_format):
|
187 |
try:
|
188 |
yt = YouTube(yt_video)
|
189 |
except pytube.exceptions.RegexMatchError:
|
190 |
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
|
|
|
|
|
|
|
|
191 |
video = yt.streams.get_highest_resolution()
|
192 |
video.download()
|
193 |
video_path = f"{video.default_filename}"
|
@@ -203,16 +215,13 @@ def download_video_as_audio_only(yt_video, audio_output_format):
|
|
203 |
os.remove(mp4remove)
|
204 |
single_zip_name = "only_audio.zip"
|
205 |
audio_files = glob.glob("*.wav") if audio_output_format == "wav" else glob.glob("*.mp3")
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
if os.path.exists(outputmp3removal):
|
214 |
-
os.remove(outputmp3removal)
|
215 |
-
return "Done! Download the zip file below! This only contains the audio file.", single_zip_name
|
216 |
|
217 |
def check_for_remaining_wav_or_mp3_files(which_filetype):
|
218 |
audio_files = glob.glob(f"*.{which_filetype}")
|
@@ -277,18 +286,6 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
277 |
outputs=[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
278 |
)
|
279 |
with gr.TabItem("Misc tools"):
|
280 |
-
with gr.Tab("SR analyzer"):
|
281 |
-
gr.Markdown("Upload a zip file of your wavs here and this will determine the average sample rate.")
|
282 |
-
with gr.Row():
|
283 |
-
with gr.Column():
|
284 |
-
with gr.Row():
|
285 |
-
zipuploader = gr.File(file_count='single', file_types=[".zip"], label="ZIP file")
|
286 |
-
uploadbtn = gr.Button("Analyze", variant='primary')
|
287 |
-
uploadbtn.click(
|
288 |
-
analyze_audio,
|
289 |
-
[zipuploader],
|
290 |
-
[gr.Text(label="Result")]
|
291 |
-
)
|
292 |
with gr.Tab("File splitter"):
|
293 |
gr.Markdown("If you would rather split a single WAV or mp3 audio file, use this method instead.")
|
294 |
with gr.Row():
|
@@ -327,11 +324,12 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
327 |
with gr.Row():
|
328 |
yt_video = gr.Textbox(label="URL")
|
329 |
audio_output_format = gr.Radio(["wav", "mp3"], value="wav", label="Download audio as:")
|
|
|
330 |
commence_download = gr.Button("Download", variant='primary')
|
331 |
commence_download.click(
|
332 |
download_video_as_audio_only,
|
333 |
-
[yt_video, audio_output_format],
|
334 |
-
[gr.Text(label="Output"), gr.File(label="
|
335 |
)
|
336 |
with gr.Tab("Check for leftover mp3 or wav files"):
|
337 |
gr.Markdown("There might be instances where sometimes a few wav or mp3 files are left over after a conversion. This section tells how many of those files are left, if any.")
|
@@ -357,6 +355,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
357 |
gr.Image(label="Spectrogram result", show_download_button=False, scale=2)
|
358 |
)
|
359 |
with gr.TabItem("Changelog"):
|
|
|
360 |
gr.Markdown("v0.97a - Fixed issue with spectrogram tab if no WAV file was selected.")
|
361 |
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.")
|
362 |
gr.Markdown("v0.96 - Added new remaining files tool in Misc Tools.")
|
|
|
7 |
yt = YouTube(url)
|
8 |
except pytube.exceptions.RegexMatchError:
|
9 |
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
10 |
+
except urllib.error.HTTPError as not_ok:
|
11 |
+
raise gr.Error(f"{not_ok}")
|
12 |
+
except pytube.exceptions.AgeRestrictedError:
|
13 |
+
raise gr.Error("The video you are trying to convert is age-restricted and cannot be downloaded! A proper login system may be implemented in the future.")
|
14 |
video = yt.streams.get_highest_resolution()
|
15 |
video.download()
|
16 |
video_path = f"{video.default_filename}"
|
|
|
150 |
yt = YouTube(ytvideo)
|
151 |
except pytube.exceptions.RegexMatchError:
|
152 |
raise gr.Error("URL not valid or was left empty! Please fix the link or enter one.")
|
153 |
+
except urllib.error.HTTPError as not_ok:
|
154 |
+
raise gr.Error(f"{not_ok}")
|
155 |
+
except pytube.exceptions.AgeRestrictedError:
|
156 |
+
raise gr.Error("The video you are trying to convert is age-restricted and cannot be downloaded! A proper login system may be implemented in the future.")
|
157 |
video = yt.streams.get_highest_resolution()
|
158 |
video.download()
|
159 |
video_path = f"{video.default_filename}"
|
|
|
191 |
time.sleep(2)
|
192 |
return "Process done successfully! Check below for zipped files!", zip_file_name
|
193 |
|
194 |
+
def download_video_as_audio_only(yt_video, audio_output_format, download_as_zip_or_wav):
|
195 |
try:
|
196 |
yt = YouTube(yt_video)
|
197 |
except pytube.exceptions.RegexMatchError:
|
198 |
raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
|
199 |
+
except urllib.error.HTTPError as not_ok:
|
200 |
+
raise gr.Error(f"{not_ok}")
|
201 |
+
except pytube.exceptions.AgeRestrictedError:
|
202 |
+
raise gr.Error("The video you are trying to convert is age-restricted and cannot be downloaded! A proper login system may be implemented in the future.")
|
203 |
video = yt.streams.get_highest_resolution()
|
204 |
video.download()
|
205 |
video_path = f"{video.default_filename}"
|
|
|
215 |
os.remove(mp4remove)
|
216 |
single_zip_name = "only_audio.zip"
|
217 |
audio_files = glob.glob("*.wav") if audio_output_format == "wav" else glob.glob("*.mp3")
|
218 |
+
if download_as_zip_or_wav == "zip":
|
219 |
+
with zipfile.ZipFile(single_zip_name, 'w') as zip_file:
|
220 |
+
for audio_file in audio_files:
|
221 |
+
zip_file.write(audio_file, os.path.basename(audio_file))
|
222 |
+
return "Done! Download the zip file below! This only contains the audio file.", single_zip_name
|
223 |
+
elif download_as_zip_or_wav == "wav":
|
224 |
+
return "Done! Download the audio file below!", "output.wav"
|
|
|
|
|
|
|
225 |
|
226 |
def check_for_remaining_wav_or_mp3_files(which_filetype):
|
227 |
audio_files = glob.glob(f"*.{which_filetype}")
|
|
|
286 |
outputs=[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
287 |
)
|
288 |
with gr.TabItem("Misc tools"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
with gr.Tab("File splitter"):
|
290 |
gr.Markdown("If you would rather split a single WAV or mp3 audio file, use this method instead.")
|
291 |
with gr.Row():
|
|
|
324 |
with gr.Row():
|
325 |
yt_video = gr.Textbox(label="URL")
|
326 |
audio_output_format = gr.Radio(["wav", "mp3"], value="wav", label="Download audio as:")
|
327 |
+
download_as_zip_or_wav = gr.Radio(["zip", "wav"], value="wav", label="Get returned audio file as:")
|
328 |
commence_download = gr.Button("Download", variant='primary')
|
329 |
commence_download.click(
|
330 |
download_video_as_audio_only,
|
331 |
+
[yt_video, audio_output_format, download_as_zip_or_wav],
|
332 |
+
[gr.Text(label="Output"), gr.File(label="Audio file")]
|
333 |
)
|
334 |
with gr.Tab("Check for leftover mp3 or wav files"):
|
335 |
gr.Markdown("There might be instances where sometimes a few wav or mp3 files are left over after a conversion. This section tells how many of those files are left, if any.")
|
|
|
355 |
gr.Image(label="Spectrogram result", show_download_button=False, scale=2)
|
356 |
)
|
357 |
with gr.TabItem("Changelog"):
|
358 |
+
gr.Markdown("v0.98 - Added more error checking for downloading a video, removed SR Analyzer, and added WAV as a returned audio file option (for 'audio only download' tab only).")
|
359 |
gr.Markdown("v0.97a - Fixed issue with spectrogram tab if no WAV file was selected.")
|
360 |
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.")
|
361 |
gr.Markdown("v0.96 - Added new remaining files tool in Misc Tools.")
|