mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
ac378d0875
* 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>
28 lines
509 B
Python
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()
|