mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
* changes * process fe fn tests * cleanup * cleanup * create_target_meta tests and abstraction * add interactivity detection and tests * more functions more tests * add tests for component loader, fix errors * fix everything * add changeset * add changeset * ci * cleanup * cleanup * test * fix again * tweaks * cleanup * add changeset * fix loading_status * cleanup * ensure updates have been flushed before making API requests * add changeset * df fix * fixes * fix dataframe updates * fix dataframe updates * remove $open var * add changeset * fix tests * extend timeout for lite --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
41 lines
1017 B
Python
41 lines
1017 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()
|