python中的gradio使用麦克风时报错
当运行至
import gradio as gr
with gr.Blocks() as demo:
with gr.Tab("microphone transcriber"):
gr.Audio(source="microphone", type="numpy", streaming=True)
demo.queue()
##访问链接 https://ip:1235/
demo.launch(share=True,server_name="0.0.0.0", server_port=1235, ssl_verify=False, ssl_certfile="./cert.pem",
ssl_keyfile="./key.pem") #NewVoice/Ahmad/BAGINHUMAS/Queation60.wav
# demo.launch(server_name="0.0.0.0", server_port=1235
# )
报错
TypeError: Audio.__init__() got an unexpected keyword argument 'source'
解决方案
source修改为sources即可。亲测有效。
gr.Audio(sources="microphone", type="numpy", streaming=True)