UberRoot commited on
Commit
7581176
·
1 Parent(s): 1118014

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Francesco agarrate que la nafta se disparo
2
+ import numpy as np
3
+ import gradio as gr
4
+
5
+ def generate_tone(note, octave, duration):
6
+ sampling_rate = 48000
7
+ a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)
8
+ frequency = a4_freq * 2 ** (tones_from_a4 / 12)
9
+ audio = np.linspace(0, int(duration), int(duration) * sampling_rate)
10
+ audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)
11
+ return sampling_rate, audio
12
+
13
+ gr.Interface(
14
+ generate_tone,
15
+ [
16
+ gr.inputs.Dropdown(["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"], type="index"),
17
+ gr.inputs.Slider(4, 6, step=1),
18
+ gr.inputs.Textbox(type="number", default=1, label="Duration in seconds"),
19
+ ],
20
+ "audio",
21
+ title="Generate a Musical Tone!"
22
+ ).launch()