CXDJY commited on
Commit
522c171
·
1 Parent(s): 2f8f9c7

try adding librosa

Browse files
Files changed (2) hide show
  1. app.py +8 -1
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,8 +1,15 @@
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
  def greet(name):
 
4
  # return "Hello " + str(name[1]) + "!!"
5
- return name
6
 
7
  iface = gr.Interface(fn=greet, inputs="file", outputs="text")
8
  # iface = gr.Interface(fn=greet, inputs="audio", outputs="text")
 
1
  import gradio as gr
2
+ import librosa
3
+
4
+ def load_audio_to_tensor(filename):
5
+ audio, sampling_rate = librosa.load(filename, sr=None, mono=True) # load audio and convert to mono
6
+ wave = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000) # resample to 16KHz
7
+ return wave
8
 
9
  def greet(name):
10
+ load_audio_to_tensor(name)
11
  # return "Hello " + str(name[1]) + "!!"
12
+ return name + 'type'
13
 
14
  iface = gr.Interface(fn=greet, inputs="file", outputs="text")
15
  # iface = gr.Interface(fn=greet, inputs="audio", outputs="text")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ librosa==0.10.1