mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-18 10:44:33 +08:00
2a93225952
* changes * fix * fix for vars too * changes * fix tests Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
20 lines
528 B
Python
20 lines
528 B
Python
import gradio as gr
|
|
import numpy as np
|
|
|
|
with gr.Blocks() as demo:
|
|
inp = gr.Audio(source="microphone")
|
|
out = gr.Audio()
|
|
stream = gr.Variable()
|
|
|
|
def add_to_stream(audio, instream):
|
|
if audio is None:
|
|
return gr.update(), instream
|
|
if instream is None:
|
|
ret = audio
|
|
else:
|
|
ret = (audio[0], np.concatenate((instream[1], audio[1])))
|
|
return ret, ret
|
|
inp.stream(add_to_stream, [inp, stream], [out, stream])
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |