File size: 546 Bytes
ef910fd
522c171
 
 
 
 
 
ef910fd
85c8109
a709495
8e797fd
a709495
ef910fd
8e797fd
 
ef910fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
import librosa

def load_audio_to_tensor(filename):
    audio, sampling_rate = librosa.load(filename, sr=None, mono=True)  # load audio and convert to mono
    wave = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)  # resample to 16KHz
    return wave

def greet(name):
    wave = load_audio_to_tensor(name)
    # return "Hello " + str(name[1]) + "!!"
    return wave

iface = gr.Interface(fn=greet, inputs="file", outputs="text")
# iface = gr.Interface(fn=greet, inputs="audio", outputs="text")
iface.launch()