snoringAI / app.py
CXDJY's picture
try wave
a709495
raw
history blame
546 Bytes
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()