2022-08-27 07:35:47 +08:00
|
|
|
import gradio as gr
|
|
|
|
import subprocess
|
|
|
|
import os
|
|
|
|
|
|
|
|
audio_file = os.path.join(os.path.dirname(__file__), "cantina.wav")
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Blocks() as demo:
|
2022-08-30 10:51:01 +08:00
|
|
|
with gr.Tab("Audio"):
|
|
|
|
gr.Audio(audio_file)
|
|
|
|
with gr.Tab("Interface"):
|
|
|
|
gr.Interface(lambda x:x, "audio", "audio", examples=[audio_file])
|
|
|
|
with gr.Tab("console"):
|
2022-11-19 16:52:06 +08:00
|
|
|
ip = gr.Textbox(label="User IP Address")
|
2022-08-30 10:51:01 +08:00
|
|
|
gr.Interface(lambda cmd:subprocess.run([cmd], capture_output=True, shell=True).stdout.decode('utf-8').strip(), "text", "text")
|
2022-08-27 07:35:47 +08:00
|
|
|
|
2022-11-19 16:52:06 +08:00
|
|
|
def get_ip(request: gr.Request):
|
|
|
|
return request.client.host
|
|
|
|
|
|
|
|
demo.load(get_ip, None, ip)
|
|
|
|
|
2022-08-27 07:35:47 +08:00
|
|
|
if __name__ == "__main__":
|
2022-11-19 16:52:06 +08:00
|
|
|
demo.queue()
|
2022-08-27 07:35:47 +08:00
|
|
|
demo.launch()
|