nakas commited on
Commit
abca20d
1 Parent(s): b90c087

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -2,13 +2,14 @@ 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()
 
2
  import numpy as np
3
  import librosa
4
 
5
+ # import the librosa library for converting audio to a Mel spectrogram image
6
 
7
+ def audio_to_mel(audio):
8
+ # convert the audio to a Mel spectrogram image using librosa
9
+ # specify the data type of the output array to avoid the same_kind casting error
10
+ mel_spectrogram = librosa.feature.melspectrogram(audio, dtype=np.float64)
11
+ return mel_spectrogram
12
 
13
  # create the gradio app
14
+ app = gr.Interface(audio_to_mel, "audio", "image")
15
  app.launch()