reazonspeech / app.py
aka7774's picture
Update app.py
5cea8c6 verified
raw
history blame
No virus
740 Bytes
import git
git.Repo.clone_from('https://github.com/reazon-research/ReazonSpeech', 'ReazonSpeech')
import pip, site, importlib
pip.main(['install', 'ReazonSpeech/pkg/nemo-asr'])
importlib.reload(site)
import gradio as gr
from reazonspeech.nemo.asr import audio_from_path, load_model, transcribe
model = None
def speech_to_text(audio_file):
global model
if not model:
model = load_model()
audio = audio_from_path(audio_file)
ret = transcribe(model, audio)
return ret.text, "\n".join(ret.segments), "\n".join(ret.subwords)
load_model(model_size)
gr.Interface(
fn=speech_to_text,
inputs=[
gr.Audio(sources="upload", type="filepath"),
],
outputs=["text","text","text"]).launch()