Spaces:
Build error
Build error
Download demos/audio_debugger/run.py from gradio-pr-deploys/pr-9320-all-demos: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/gradio-pr-deploys/pr-9320-all-demos/resolve/a38caf97a2d9a279d3be1ed620d043e3bab2e57d/demos/audio_debugger/run.py
- Command line
-
hf download hf://spaces/gradio-pr-deploys/pr-9320-all-demos@a38caf97a2d9a279d3be1ed620d043e3bab2e57d/demos/audio_debugger/run.py
-
curl -L -o run.py https://huggingface.co/spaces/gradio-pr-deploys/pr-9320-all-demos/resolve/a38caf97a2d9a279d3be1ed620d043e3bab2e57d/demos/audio_debugger/run.py
1.01 kB
| 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, check=False) | |
| .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.launch() | |