File size: 617 Bytes
0fb9949
 
 
 
 
 
 
7cb4a5f
12c52b2
0fb9949
 
 
 
 
 
 
 
 
e54243e
0fb9949
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline
import time

pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")

def transcribe(audio, state=""):
    #print(audio)
    time.sleep(2)
    text = pipe(audio)["text"]
    state += text + " "
    return state, state


with gr.Blocks() as demo:
  state = gr.State(value="")
  with gr.Row():
      with gr.Column():
        audio = gr.Audio(sources="microphone", type="filepath") 
      with gr.Column():
        textbox = gr.Textbox()
  audio.stream(fn=transcribe, inputs=[audio, state], outputs=[textbox, state])

demo.launch(debug=True)