Spaces:
Runtime error
Runtime error
xiaojin123rogers
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# 加载模型
|
5 |
+
model = pipeline('automatic-speech-recognition', model='BELLE-2/Belle-whisper-large-v3-zh-punct')
|
6 |
+
|
7 |
+
def transcribe(audio):
|
8 |
+
result = model(audio)
|
9 |
+
return result['text']
|
10 |
+
|
11 |
+
# 创建 Gradio 接口
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=transcribe,
|
14 |
+
inputs=gr.inputs.Audio(source="microphone", type="filepath"),
|
15 |
+
outputs="text",
|
16 |
+
live=True
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|