gradio/demo/audio_debugger/run.py
Hannah c35fac049a
Ensure device selection works in Audio when streaming (#7082)
* Fix microphone device access denied issue

* add changeset

* add microphone test

* create shared DeviceSelect component

* add changeset

* add e2e test

* regen notebooks

* formatting

* Fix e2e test

* formatting

* adjust controls box

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-01-23 10:49:29 +01:00

27 lines
868 B
Python

import gradio as gr
import subprocess
import os
audio_file = os.path.join(os.path.dirname(__file__), "cantina.wav")
with gr.Blocks() as demo:
with gr.Tab("Audio"):
gr.Audio(audio_file)
with gr.Tab("Interface"):
gr.Interface(lambda x:x, "audio", "audio", examples=[audio_file], cache_examples=True)
with gr.Tab("Streaming"):
gr.Interface(lambda x:x, gr.Audio(streaming=True), "audio", examples=[audio_file], cache_examples=True)
with gr.Tab("console"):
ip = gr.Textbox(label="User IP Address")
gr.Interface(lambda cmd:subprocess.run([cmd], capture_output=True, shell=True).stdout.decode('utf-8').strip(), "text", "text")
def get_ip(request: gr.Request):
return request.client.host
demo.load(get_ip, None, ip)
if __name__ == "__main__":
demo.queue()
demo.launch()