aliabd HF Staff commited on
Commit
a8730f7
·
verified ·
1 Parent(s): 080ff0b

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +1 -1
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@38c2ad425a905431b1eb17b9498669f9e49f0dd5#subdirectory=client/python
2
- https://gradio-builds.s3.amazonaws.com/38c2ad425a905431b1eb17b9498669f9e49f0dd5/gradio-4.38.1-py3-none-any.whl
3
  numpy
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@76c175935019833baef709a5cf401d2263ca72ee#subdirectory=client/python
2
+ https://gradio-builds.s3.amazonaws.com/76c175935019833baef709a5cf401d2263ca72ee/gradio-4.38.1-py3-none-any.whl
3
  numpy
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: generate_tone"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import numpy as np\n", "import gradio as gr\n", "\n", "notes = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"]\n", "\n", "def generate_tone(note, octave, duration):\n", " sr = 48000\n", " a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)\n", " frequency = a4_freq * 2 ** (tones_from_a4 / 12)\n", " duration = int(duration)\n", " audio = np.linspace(0, duration, duration * sr)\n", " audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)\n", " return sr, audio\n", "\n", "demo = gr.Interface(\n", " generate_tone,\n", " [\n", " gr.Dropdown(notes, type=\"index\"),\n", " gr.Slider(4, 6, step=1),\n", " gr.Textbox(value=1, label=\"Duration in seconds\"),\n", " ],\n", " \"audio\",\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: generate_tone"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import numpy as np\n", "import gradio as gr\n", "\n", "notes = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"]\n", "\n", "def generate_tone(note, octave, duration):\n", " sr = 48000\n", " a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)\n", " frequency = a4_freq * 2 ** (tones_from_a4 / 12)\n", " duration = int(duration)\n", " audio = np.linspace(0, duration, duration * sr)\n", " audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)\n", " return sr, audio\n", "\n", "demo = gr.Interface(\n", " generate_tone,\n", " [\n", " gr.Dropdown(notes, type=\"index\"),\n", " gr.Slider(4, 6, step=1),\n", " gr.Textbox(value=\"1\", label=\"Duration in seconds\"),\n", " ],\n", " \"audio\",\n", ")\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -17,7 +17,7 @@ demo = gr.Interface(
17
  [
18
  gr.Dropdown(notes, type="index"),
19
  gr.Slider(4, 6, step=1),
20
- gr.Textbox(value=1, label="Duration in seconds"),
21
  ],
22
  "audio",
23
  )
 
17
  [
18
  gr.Dropdown(notes, type="index"),
19
  gr.Slider(4, 6, step=1),
20
+ gr.Textbox(value="1", label="Duration in seconds"),
21
  ],
22
  "audio",
23
  )