freddyaboulton HF Staff commited on
Commit
3f3d840
·
verified ·
1 Parent(s): 1210a5c

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. run.ipynb +1 -1
  3. run.py +15 -6
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 5.49.1
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 6.0.0
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_debugger"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import subprocess\n", "import os\n", "\n", "# get_audio returns the path to the audio file\n", "audio_file = gr.get_audio(\"cantina.wav\")\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tab(\"Audio\"):\n", " gr.Audio(audio_file)\n", " with gr.Tab(\"Interface\"):\n", " gr.Interface(\n", " lambda x: x, \"audio\", \"audio\", examples=[audio_file], cache_examples=True\n", " )\n", " with gr.Tab(\"Streaming\"):\n", " gr.Interface(\n", " lambda x: x,\n", " gr.Audio(streaming=True),\n", " \"audio\",\n", " examples=[audio_file],\n", " cache_examples=True,\n", " )\n", " with gr.Tab(\"console\"):\n", " ip = gr.Textbox(label=\"User IP Address\")\n", " gr.Interface(\n", " lambda cmd: subprocess.run([cmd], capture_output=True, shell=True, check=False)\n", " .stdout.decode(\"utf-8\")\n", " .strip(),\n", " \"text\",\n", " \"text\",\n", " )\n", "\n", " def get_ip(request: gr.Request):\n", " return request.client.host\n", "\n", " demo.load(get_ip, None, ip)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_debugger"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import subprocess\n", "from gradio.media import get_audio, MEDIA_PATHS\n", "\n", "# get_audio returns the path to the audio file\n", "audio_file = get_audio(\"cantina.wav\")\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tab(\"Audio\"):\n", " gr.Audio(audio_file, buttons=[\"download\"])\n", " with gr.Tab(\"Interface\"):\n", " gr.Interface(\n", " lambda x: x,\n", " gr.Audio(),\n", " gr.Audio(),\n", " examples=[audio_file],\n", " cache_examples=True,\n", " api_name=\"predict\",\n", " )\n", " with gr.Tab(\"Streaming\"):\n", " gr.Interface(\n", " lambda x: x,\n", " gr.Audio(streaming=True),\n", " \"audio\",\n", " examples=[audio_file],\n", " cache_examples=True,\n", " api_name=\"predict\",\n", " )\n", " with gr.Tab(\"console\"):\n", " ip = gr.Textbox(label=\"User IP Address\")\n", " gr.Interface(\n", " lambda cmd: subprocess.run(\n", " [cmd], capture_output=True, shell=True, check=False\n", " )\n", " .stdout.decode(\"utf-8\")\n", " .strip(),\n", " \"text\",\n", " \"text\",\n", " api_name=\"predict\",\n", " )\n", "\n", " def get_ip(request: gr.Request):\n", " return request.client.host\n", "\n", " demo.load(get_ip, None, ip)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch(allowed_paths=MEDIA_PATHS)\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
  import subprocess
3
- import os
4
 
5
  # get_audio returns the path to the audio file
6
- audio_file = gr.get_audio("cantina.wav")
7
 
8
  with gr.Blocks() as demo:
9
  with gr.Tab("Audio"):
10
- gr.Audio(audio_file)
11
  with gr.Tab("Interface"):
12
  gr.Interface(
13
- lambda x: x, "audio", "audio", examples=[audio_file], cache_examples=True
 
 
 
 
 
14
  )
15
  with gr.Tab("Streaming"):
16
  gr.Interface(
@@ -19,15 +24,19 @@ with gr.Blocks() as demo:
19
  "audio",
20
  examples=[audio_file],
21
  cache_examples=True,
 
22
  )
23
  with gr.Tab("console"):
24
  ip = gr.Textbox(label="User IP Address")
25
  gr.Interface(
26
- lambda cmd: subprocess.run([cmd], capture_output=True, shell=True, check=False)
 
 
27
  .stdout.decode("utf-8")
28
  .strip(),
29
  "text",
30
  "text",
 
31
  )
32
 
33
  def get_ip(request: gr.Request):
@@ -36,4 +45,4 @@ with gr.Blocks() as demo:
36
  demo.load(get_ip, None, ip)
37
 
38
  if __name__ == "__main__":
39
- demo.launch()
 
1
  import gradio as gr
2
  import subprocess
3
+ from gradio.media import get_audio, MEDIA_PATHS
4
 
5
  # get_audio returns the path to the audio file
6
+ audio_file = get_audio("cantina.wav")
7
 
8
  with gr.Blocks() as demo:
9
  with gr.Tab("Audio"):
10
+ gr.Audio(audio_file, buttons=["download"])
11
  with gr.Tab("Interface"):
12
  gr.Interface(
13
+ lambda x: x,
14
+ gr.Audio(),
15
+ gr.Audio(),
16
+ examples=[audio_file],
17
+ cache_examples=True,
18
+ api_name="predict",
19
  )
20
  with gr.Tab("Streaming"):
21
  gr.Interface(
 
24
  "audio",
25
  examples=[audio_file],
26
  cache_examples=True,
27
+ api_name="predict",
28
  )
29
  with gr.Tab("console"):
30
  ip = gr.Textbox(label="User IP Address")
31
  gr.Interface(
32
+ lambda cmd: subprocess.run(
33
+ [cmd], capture_output=True, shell=True, check=False
34
+ )
35
  .stdout.decode("utf-8")
36
  .strip(),
37
  "text",
38
  "text",
39
+ api_name="predict",
40
  )
41
 
42
  def get_ip(request: gr.Request):
 
45
  demo.load(get_ip, None, ip)
46
 
47
  if __name__ == "__main__":
48
+ demo.launch(allowed_paths=MEDIA_PATHS)