aliabd HF Staff commited on
Commit
53914e7
·
1 Parent(s): 9771e1e

Upload with huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +6 -7
  2. __pycache__/run.cpython-36.pyc +0 -0
  3. requirements.txt +1 -0
  4. run.py +25 -0
  5. screenshot.png +0 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Generate Tone Main
3
- emoji: 📉
4
- colorFrom: green
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: generate_tone_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
__pycache__/run.cpython-36.pyc ADDED
Binary file (913 Bytes). View file
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ numpyhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+
4
+ notes = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
5
+
6
+ def generate_tone(note, octave, duration):
7
+ sr = 48000
8
+ a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)
9
+ frequency = a4_freq * 2 ** (tones_from_a4 / 12)
10
+ duration = int(duration)
11
+ audio = np.linspace(0, duration, duration * sr)
12
+ audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)
13
+ return sr, audio
14
+
15
+ demo = gr.Interface(
16
+ generate_tone,
17
+ [
18
+ gr.Dropdown(notes, type="index"),
19
+ gr.Slider(4, 6, step=1),
20
+ gr.Textbox(value=1, type="number", label="Duration in seconds"),
21
+ ],
22
+ "audio",
23
+ )
24
+ if __name__ == "__main__":
25
+ demo.launch()
screenshot.png ADDED