remove todo, fix bug if no audio file was present
Browse files
app.py
CHANGED
|
@@ -127,10 +127,13 @@ def split_wav_file(audiofileuploader, mindur2, maxdur2, name_for_split_files2):
|
|
| 127 |
return f"File split successfully!\nCheck below for zipped files.\nAmount created: {len(audio_files)}", zip_file_name2
|
| 128 |
|
| 129 |
def get_average_pitch(audio_file):
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app:
|
| 136 |
gr.HTML(
|
|
@@ -198,8 +201,7 @@ with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app:
|
|
| 198 |
)
|
| 199 |
with gr.Tab("Pitch analyzer"):
|
| 200 |
gr.Markdown("Upload a wav file here, and this will determine the average pitch.")
|
| 201 |
-
gr.HTML("<h1> Zip files are not supported as of now.")
|
| 202 |
-
gr.HTML("<h1> TODO: Add error message if no audio file is provided. </h1>")
|
| 203 |
with gr.Row():
|
| 204 |
with gr.Column(variant='compact'):
|
| 205 |
with gr.Row():
|
|
|
|
| 127 |
return f"File split successfully!\nCheck below for zipped files.\nAmount created: {len(audio_files)}", zip_file_name2
|
| 128 |
|
| 129 |
def get_average_pitch(audio_file):
|
| 130 |
+
if audio_file == None:
|
| 131 |
+
raise gr.Error("Audio file cannot be empty!")
|
| 132 |
+
else:
|
| 133 |
+
y, sr = librosa.load(audio_file, sr=None)
|
| 134 |
+
pitches, magnitudes = librosa.piptrack(y=y, sr=sr)
|
| 135 |
+
mean_pitch = pitches.mean()
|
| 136 |
+
return f"Average pitch: {mean_pitch:.2f} Hz"
|
| 137 |
|
| 138 |
with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app:
|
| 139 |
gr.HTML(
|
|
|
|
| 201 |
)
|
| 202 |
with gr.Tab("Pitch analyzer"):
|
| 203 |
gr.Markdown("Upload a wav file here, and this will determine the average pitch.")
|
| 204 |
+
gr.HTML("<h1> Zip files and MP3 files are not supported as of now.")
|
|
|
|
| 205 |
with gr.Row():
|
| 206 |
with gr.Column(variant='compact'):
|
| 207 |
with gr.Row():
|