2
0
mirror of https://github.com/gradio-app/gradio.git synced 2025-01-12 10:34:32 +08:00
gradio/demo/audio_debugger/run.ipynb
aliabid94 9b42ba8f10
Update guides esp plots ()
* changes

* changes

* revert changes

* changes

* add changeset

* notebooks script

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
2024-07-29 22:08:51 -07:00

2.0 KiB

Gradio Demo: audio_debugger

In [ ]:
!pip install -q gradio 
In [ ]:
# Downloading files from the demo repo
import os
!wget -q https://github.com/gradio-app/gradio/raw/main/demo/audio_debugger/cantina.wav
In [ ]:
import gradio as gr
import subprocess
import os

audio_file = os.path.join(os.path.abspath(''), "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()