tuning-whisper / app.py
jasper9w
更新录音方式
0ced63d
raw
history blame contribute delete
679 Bytes
from transformers import pipeline
import gradio as gr
import numpy as np
pipe = pipeline(model="openai/whisper-tiny")
def asr(test_file):
return pipe(test_file, max_new_tokens=100)
def gradio_asr(test_file):
return asr(test_file)
asr_upload = gr.Interface(fn=gradio_asr,
inputs=gr.Audio(source='upload', type='filepath'),
outputs='text')
app_mic = gr.Interface(fn=gradio_asr,
inputs=gr.Audio(source='microphone', type='filepath'),
outputs='text')
app = gr.TabbedInterface([asr_upload, app_mic], ["语音文件", "实时识别"])
app.launch(server_name='0.0.0.0', ssl_verify=False)