Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,17 @@ import gradio as gr
|
|
2 |
import numpy as np
|
3 |
import librosa
|
4 |
|
5 |
-
# import the librosa library for converting
|
6 |
|
7 |
-
def
|
8 |
-
# convert the
|
|
|
|
|
|
|
9 |
# specify the data type of the output array to avoid the same_kind casting error
|
10 |
-
|
11 |
-
return
|
12 |
|
13 |
# create the gradio app
|
14 |
-
app = gr.Interface(
|
15 |
app.launch()
|
|
|
2 |
import numpy as np
|
3 |
import librosa
|
4 |
|
5 |
+
# import the librosa library for converting a Mel spectrogram image to audio
|
6 |
|
7 |
+
def mel_to_audio(mel_spectrogram):
|
8 |
+
# convert the Mel spectrogram image to a grayscale image to avoid the string indices must be integers error
|
9 |
+
mel_spectrogram = np.mean(mel_spectrogram, axis=0)
|
10 |
+
|
11 |
+
# convert the Mel spectrogram image to audio using librosa
|
12 |
# specify the data type of the output array to avoid the same_kind casting error
|
13 |
+
audio = librosa.feature.inverse.mel_to_audio(mel_spectrogram, dtype=np.float64)
|
14 |
+
return audio
|
15 |
|
16 |
# create the gradio app
|
17 |
+
app = gr.Interface(mel_to_audio, "image", "audio")
|
18 |
app.launch()
|