gradio/demo/streaming_wav2vec/run.py
aliabid94 ac378d0875
Stream works now (#2351)
* changes

* changes

* lazy load streaming deps

* lazy load streaming deps

* cleanup

* fix last chunks of streaming

* add changelog

* add changelog

* add changelog

* add changelog

* updated streaming demo

* renamed sst

* changes

Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2022-10-05 14:11:47 -07:00

28 lines
509 B
Python

from transformers import pipeline
import gradio as gr
import time
p = pipeline("automatic-speech-recognition")
def transcribe(audio, state=""):
time.sleep(2)
text = p(audio)["text"]
state += text + " "
return state, state
demo = gr.Interface(
fn=transcribe,
inputs=[
gr.Audio(source="microphone", type="filepath", streaming=True),
"state"
],
outputs=[
"textbox",
"state"
],
live=True
)
if __name__ == "__main__":
demo.launch()