Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from funasr import AutoModel
|
| 4 |
+
model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc",
|
| 5 |
+
# spk_model="cam++",
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
def asr(audio):
|
| 9 |
+
res = model.generate(input=audio, batch_size_s=300)
|
| 10 |
+
return res[0]['text']
|
| 11 |
+
|
| 12 |
+
with gr.Blocks() as app:
|
| 13 |
+
gr.Markdown("# <center>🌊💕🎶 语音识别</center>")
|
| 14 |
+
inp = gr.Audio(label="请上传一个音频文件", type="filepath")
|
| 15 |
+
btn = gr.Button("一键开启语音识别")
|
| 16 |
+
out = gr.Textbox(label="文字内容")
|
| 17 |
+
|
| 18 |
+
btn.click(asr, [inp], [out])
|
| 19 |
+
|
| 20 |
+
app.launch(share=False, show_error=True)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|