Commit
·
5e3d1e1
1
Parent(s):
798712f
Update app.py
Browse files
app.py
CHANGED
@@ -10,17 +10,17 @@ def main():
|
|
10 |
gr.Markdown(
|
11 |
"""
|
12 |
# <div align="center"> Ilaria Audio Analyzer 💖 (BETA) </div>
|
13 |
-
Audio Analyzer Software by Ilaria, Help me on
|
14 |
-
Special thanks to
|
15 |
|
16 |
-
Need help with AI?
|
17 |
"""
|
18 |
)
|
19 |
|
20 |
with gr.Row(elem_id=1):
|
21 |
audio_input = gr.Audio(type='filepath')
|
22 |
-
|
23 |
-
|
24 |
|
25 |
with gr.Row(elem_id=2):
|
26 |
output_markdown = gr.Markdown(value="", visible=True)
|
@@ -37,8 +37,9 @@ def create_spectrogram_and_get_info(audio_file):
|
|
37 |
# Read the audio data from the file
|
38 |
audio_data, sample_rate = sf.read(audio_file)
|
39 |
|
40 |
-
#
|
41 |
-
|
|
|
42 |
|
43 |
# Create the spectrogram
|
44 |
plt.specgram(audio_data, Fs=sample_rate / 1, NFFT=4096, sides='onesided',
|
|
|
10 |
gr.Markdown(
|
11 |
"""
|
12 |
# <div align="center"> Ilaria Audio Analyzer 💖 (BETA) </div>
|
13 |
+
Audio Analyzer Software by Ilaria, Help me on Ko-Fi\n
|
14 |
+
Special thanks to Alex Murkoff for helping me coding it!
|
15 |
|
16 |
+
Need help with AI? Join AI Hub!
|
17 |
"""
|
18 |
)
|
19 |
|
20 |
with gr.Row(elem_id=1):
|
21 |
audio_input = gr.Audio(type='filepath')
|
22 |
+
with gr.Column():
|
23 |
+
create_spec_butt = gr.Button(value='Create Spectrogram And Get Info', variant='primary')
|
24 |
|
25 |
with gr.Row(elem_id=2):
|
26 |
output_markdown = gr.Markdown(value="", visible=True)
|
|
|
37 |
# Read the audio data from the file
|
38 |
audio_data, sample_rate = sf.read(audio_file)
|
39 |
|
40 |
+
# Convert to mono if it's not mono
|
41 |
+
if len(audio_data.shape) > 1:
|
42 |
+
audio_data = np.mean(audio_data, axis=1)
|
43 |
|
44 |
# Create the spectrogram
|
45 |
plt.specgram(audio_data, Fs=sample_rate / 1, NFFT=4096, sides='onesided',
|