check changelog tab
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, librosa, time
|
2 |
from pytube import YouTube
|
3 |
from moviepy.editor import VideoFileClip
|
4 |
|
@@ -131,15 +131,6 @@ def split_wav_or_mp3_file(audiofileuploader, mindur2, maxdur2, name_for_split_fi
|
|
131 |
os.remove(file2)
|
132 |
return f"File split successfully!\nCheck below for zipped files.\nAmount created: {len(audio_files)}", zip_file_name2
|
133 |
|
134 |
-
def get_average_pitch(audio_file):
|
135 |
-
if audio_file == None:
|
136 |
-
raise gr.Error("Audio file cannot be empty!")
|
137 |
-
else:
|
138 |
-
y, sr = librosa.load(audio_file, sr=None)
|
139 |
-
pitches, magnitudes = librosa.piptrack(y=y, sr=sr)
|
140 |
-
mean_pitch = pitches.mean()
|
141 |
-
return f"Average pitch: {mean_pitch:.2f} Hz"
|
142 |
-
|
143 |
def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files, progress=gr.Progress()):
|
144 |
if download_as == "mp3":
|
145 |
gr.Warning("MP3 is experimental, especially with this, so caution is advised.")
|
@@ -227,6 +218,18 @@ def check_for_remaining_wav_or_mp3_files(which_filetype):
|
|
227 |
audio_files = glob.glob(f"*.{which_filetype}")
|
228 |
return f"There are {len(audio_files)} leftover files."
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
231 |
gr.HTML(
|
232 |
"<h1> Welcome to the GDMGS! (GlobalDatasetMaker Gradio Space) </h1>"
|
@@ -295,19 +298,6 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
295 |
[audiofileuploader, mindur2, maxdur2, name_for_split_files2],
|
296 |
[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
297 |
)
|
298 |
-
with gr.Tab("Pitch analyzer"):
|
299 |
-
gr.Markdown("Upload a wav file here, and this will determine the average pitch.")
|
300 |
-
gr.HTML("<h1> Zip files and MP3 files are not supported as of now.")
|
301 |
-
with gr.Row():
|
302 |
-
with gr.Column():
|
303 |
-
with gr.Row():
|
304 |
-
upload = gr.File(file_count='single', file_types=[".wav"], label="WAV file")
|
305 |
-
analyze = gr.Button("Analyze", variant='primary')
|
306 |
-
analyze.click(
|
307 |
-
get_average_pitch,
|
308 |
-
[upload],
|
309 |
-
[gr.Text(label="Result")]
|
310 |
-
)
|
311 |
with gr.Tab("All-in-one downloader and splitter"):
|
312 |
gr.Markdown("This is very experimental and may break or change in the future. This essentially combines both the first 2 tabs into an all-in-one script.")
|
313 |
with gr.Row():
|
@@ -349,7 +339,19 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
349 |
which_filetype,
|
350 |
gr.Text(label="Result")
|
351 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
with gr.TabItem("Changelog"):
|
|
|
353 |
gr.Markdown("v0.96 - Added new remaining files tool in Misc Tools.")
|
354 |
gr.Markdown("v0.95 - Fixed issue with mp3 files not downloading audio properly.")
|
355 |
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.")
|
|
|
1 |
+
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, librosa, time, librosa, librosa.display, matplotlib.pyplot as plt, numpy as np
|
2 |
from pytube import YouTube
|
3 |
from moviepy.editor import VideoFileClip
|
4 |
|
|
|
131 |
os.remove(file2)
|
132 |
return f"File split successfully!\nCheck below for zipped files.\nAmount created: {len(audio_files)}", zip_file_name2
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files, progress=gr.Progress()):
|
135 |
if download_as == "mp3":
|
136 |
gr.Warning("MP3 is experimental, especially with this, so caution is advised.")
|
|
|
218 |
audio_files = glob.glob(f"*.{which_filetype}")
|
219 |
return f"There are {len(audio_files)} leftover files."
|
220 |
|
221 |
+
def display_audio_spectrogram(audio_file):
|
222 |
+
y, sr = librosa.load(audio_file)
|
223 |
+
d = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max)
|
224 |
+
plt.figure(figsize=(12, 8))
|
225 |
+
librosa.display.specshow(d, sr=sr, x_axis="time", y_axis="log")
|
226 |
+
plt.colorbar(format="%+2.0f db")
|
227 |
+
plt.title("Spectrogram")
|
228 |
+
output = "spectrogram.png"
|
229 |
+
plt.savefig(output)
|
230 |
+
plt.close()
|
231 |
+
return output
|
232 |
+
|
233 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
234 |
gr.HTML(
|
235 |
"<h1> Welcome to the GDMGS! (GlobalDatasetMaker Gradio Space) </h1>"
|
|
|
298 |
[audiofileuploader, mindur2, maxdur2, name_for_split_files2],
|
299 |
[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
300 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
with gr.Tab("All-in-one downloader and splitter"):
|
302 |
gr.Markdown("This is very experimental and may break or change in the future. This essentially combines both the first 2 tabs into an all-in-one script.")
|
303 |
with gr.Row():
|
|
|
339 |
which_filetype,
|
340 |
gr.Text(label="Result")
|
341 |
)
|
342 |
+
with gr.Tab("Audio spectrogram"):
|
343 |
+
gr.Markdown("Insert a wav file here and this will show the spectrogram for it.")
|
344 |
+
with gr.Row():
|
345 |
+
with gr.Column():
|
346 |
+
filetoanalyze = gr.File(file_count='single', file_types=[".wav"], label="WAV file")
|
347 |
+
analyzebtn = gr.Button("Display", variant='primary')
|
348 |
+
analyzebtn.click(
|
349 |
+
display_audio_spectrogram,
|
350 |
+
filetoanalyze,
|
351 |
+
gr.Image(label="Spectrogram result", show_download_button=False, scale=2)
|
352 |
+
)
|
353 |
with gr.TabItem("Changelog"):
|
354 |
+
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.")
|
355 |
gr.Markdown("v0.96 - Added new remaining files tool in Misc Tools.")
|
356 |
gr.Markdown("v0.95 - Fixed issue with mp3 files not downloading audio properly.")
|
357 |
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.")
|