Lamara091 commited on
Commit
96818bf
·
verified ·
1 Parent(s): c25c37c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from funasr import AutoModel
3
+
4
+ # Initialize the FunASR model with the specified components
5
+ model = AutoModel(
6
+ model="paraformer-zh", model_revision="v2.0.4",
7
+ vad_model="fsmn-vad", vad_model_revision="v2.0.4",
8
+ punc_model="ct-punc-c", punc_model_revision="v2.0.4",
9
+ # Uncomment the next line to enable speaker verification/diarization
10
+ # spk_model="cam++", spk_model_revision="v2.0.2",
11
+ )
12
+
13
+ def transcribe(audio_file):
14
+ # Processing the input audio file
15
+ result = model.generate(
16
+ input=audio_file.name,
17
+ batch_size_s=300,
18
+ hotword='魔搭' # This is an example keyword; replace or remove as necessary
19
+ )
20
+ return result
21
+
22
+ # Gradio interface setup
23
+ interface = gr.Interface(
24
+ fn=transcribe,
25
+ inputs=gr.inputs.Audio(source="microphone", type="filepath", label="Upload your audio in Mandarin"),
26
+ outputs="text",
27
+ title="FunASR Speech Recognition",
28
+ description="This Gradio app uses the paraformer-zh model for speech recognition with additional features like VAD and punctuation restoration."
29
+ )
30
+
31
+ # Run the Gradio app
32
+ if __name__ == "__main__":
33
+ interface.launch()