luoqiu commited on
Commit
bce76fa
·
1 Parent(s): 010b4cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -25,7 +25,7 @@ if not os.path.exists(model_dir):
25
  local_dir=model_dir,
26
  local_dir_use_symlinks=False
27
  )
28
-
29
  # 1. 加载模型(只加载一次)
30
  model = FireRedAsr.from_pretrained(
31
  "aed",
@@ -82,9 +82,9 @@ with gr.Blocks() as demo:
82
 
83
  with gr.Tab("🎤 实时麦克风录音"):
84
  gr.Markdown("点击录音按钮开始说话,识别结果会实时显示。")
85
- mic_audio = gr.Audio(source="microphone", type="filepath", label="实时录音", live=True)
86
- mic_output = gr.Textbox(label="实时识别结果")
87
- mic_audio.change(fn=transcribe_fn, inputs=mic_audio, outputs=mic_output)
88
 
89
  with gr.Tab("📁 文件上传识别"):
90
  gr.Markdown("上传音频文件,点击按钮进行识别。")
 
25
  local_dir=model_dir,
26
  local_dir_use_symlinks=False
27
  )
28
+
29
  # 1. 加载模型(只加载一次)
30
  model = FireRedAsr.from_pretrained(
31
  "aed",
 
82
 
83
  with gr.Tab("🎤 实时麦克风录音"):
84
  gr.Markdown("点击录音按钮开始说话,识别结果会实时显示。")
85
+ mic_audio = gr.Audio(type="filepath", label="实时录音", streaming=True)
86
+ output_text = gr.Textbox()
87
+ mic_audio.stream(fn=transcribe_fn, inputs=mic_audio, outputs=output_text)
88
 
89
  with gr.Tab("📁 文件上传识别"):
90
  gr.Markdown("上传音频文件,点击按钮进行识别。")