mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-18 10:44:33 +08:00
4d58ae79b3
* state * state fix * variable -> state * fix * added state tests * formatting * fix test * formatting * fix test * added tests for bakcward compatibility * formatting * config fix * additional doc * doc fix * formatting
20 lines
525 B
Python
20 lines
525 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.State()
|
|
|
|
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() |