I'm trying to convert a simple example from interface to block, and I have missing part
我正在尝试将一个简单的示例从接口转换为块,但缺少部分
The app displays every 2 seconds the temporary recording wav file name:
该应用程序每隔2秒显示一次临时录音WAV文件名:
import gradio as gr
import time
def transcribe(audio, state=""):
time.sleep(2)
return audio
inf = gr.Interface(
fn=transcribe,
inputs=[
gr.Audio(source="microphone", type="filepath", streaming=True),
],
outputs=[
"textbox",
],
live=True)
if __name__ == "__main__":
inf.launch()
I'm trying to write this simple example with blocks, but I don't know how to connect the transcribe function to the new file event ?
我试图用块编写这个简单的示例,但我不知道如何将转录函数与新的文件事件联系起来?
import gradio as gr
import time
def transcribe(audio, state=""):
time.sleep(2)
return audio
with gr.Blocks() as demo:
input_mic = gr.Audio(source="microphone", type="filepath", streaming=True)
out_text = gr.Textbox()
# how to connect transcribe function to the input_mic event ?
if __name__ == "__main__":
demo.launch()
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!