How to call function when "stop recording" button pressed?
I want to be able to call to a function when the button of “stop recording” is pressed.I have the following simple code:import gradio as gr

def handle_streaming(stream_in):
    print(f" Got New Samples")

def stop_streaming():
    print("Streaming has stopped")

if __name__ == "__main__":

    with gr.Blocks(theme=gr.themes.Glass()) as demo:

        stream_input = gr.Audio(source="microphone")
        stream_input.stream(fn      = handle_streaming,
                            inputs  = [stream_input],
                            outputs = [],
                            every   = 1)

    demo.queue().launch(share=False,  debug=False)How can I call to my functionstop_streaming, when the button:is pressed ?
2023-05-01T14:25:05Z
Answered here:How to call function when "stop recording" button pressed ? · gradio-app/gradio · Discussion #4024 · GitHub
2023-05-01T14:41:19Z
That doesn’t work:import gradio as gr

def handle_streaming(stream_in):
    print(f" Got New Samples")

def stop_streaming():
    print("Streaming has stopped")

if __name__ == "__main__":

    with gr.Blocks(theme=gr.themes.Glass()) as demo:

        stream_input = gr.Audio(source="microphone")
        stream_input.stream(fn      = handle_streaming,
                            inputs  = [stream_input],
                            outputs = [])
        stream_input.stop(stop_streaming)

    demo.queue().launch(share=False,  debug=False)When pressing on “stop recording” the functionstop_streamingis not called