File size: 556 Bytes
99890d7
216357c
99890d7
216357c
 
99890d7
 
216357c
 
 
 
 
 
 
 
99890d7
 
216357c
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
import nemo.collections.asr as nemo_asr

model = nemo_asr.models.ASRModel.restore_from("CnLgGm025_SpeUni1024_DI_EATL.nemo")
model.eval()


def transcribe(audio_file):
    # import speech_recognition as sr
    # r = sr.Recognizer()
    # with sr.AudioFile(audio_file) as source:
    #     audio = r.record(source)
    # return r.recognize_google(audio)
    t = model.transcribe([audio_file])
    return t[0]


gr.Interface(
    transcribe,
    inputs=gr.inputs.Audio(source="microphone", type="filepath"),
    outputs="text",
).launch()