Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,14 @@
|
|
1 |
-
import librosa
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import librosa
|
5 |
-
import soundfile as sf
|
6 |
|
7 |
-
|
8 |
-
X_std = (X - X.min()) / (X.max() - X.min())
|
9 |
-
X_scaled = X_std * (max - min) + min
|
10 |
-
return X_scaled
|
11 |
-
def greet(name):
|
12 |
-
print("np array" , name)
|
13 |
-
#step 0 revert the things done to get back to the raw spectrogram
|
14 |
-
# i
|
15 |
-
#img = np.flip(img, axis=0) # put low frequencies at the bottom in image
|
16 |
-
img = (255-name) *-1
|
17 |
-
img = scale_minmax(img, 0, 1).astype(np.float64)
|
18 |
-
|
19 |
-
# step1 - converting a wav file to numpy array and then converting that to mel-spectrogram
|
20 |
-
S_inv = librosa.feature.inverse.mel_to_audio(img)
|
21 |
-
|
22 |
-
#Export wav
|
23 |
-
|
24 |
-
# step4 - save it as a wav file
|
25 |
-
return (16000,S_inv)
|
26 |
-
#mel -> audio
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
#
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
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 audio using librosa
|
9 |
+
audio = librosa.feature.inverse.mel_to_audio(mel_spectrogram)
|
10 |
+
return audio
|
11 |
|
12 |
+
# create the gradio app
|
13 |
+
app = gr.Interface(mel_to_audio, "image", "audio")
|
14 |
+
app.launch()
|