|
import gradio as gr |
|
from funasr import AutoModel |
|
|
|
|
|
model = AutoModel( |
|
model="paraformer-zh", model_revision="v2.0.4", |
|
vad_model="fsmn-vad", vad_model_revision="v2.0.4", |
|
punc_model="ct-punc-c", punc_model_revision="v2.0.4", |
|
|
|
|
|
) |
|
|
|
def transcribe(audio_file): |
|
|
|
result = model.generate( |
|
input=audio_file.name, |
|
batch_size_s=300, |
|
hotword='魔搭' |
|
) |
|
return result |
|
|
|
|
|
interface = gr.Interface( |
|
fn=transcribe, |
|
inputs=gr.inputs.Audio(source="microphone", type="filepath", label="Upload your audio in Mandarin"), |
|
outputs="text", |
|
title="FunASR Speech Recognition", |
|
description="This Gradio app uses the paraformer-zh model for speech recognition with additional features like VAD and punctuation restoration." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
interface.launch() |
|
|