werning commited on
Commit
2352e73
·
1 Parent(s): 7fc4bd8

Add gradio demo app

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+
4
+ # gradio generate tone example
5
+
6
+ notes = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
7
+
8
+ def generate_tone(note, octave, duration):
9
+ sr = 48000
10
+ a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)
11
+ frequency = a4_freq * 2 ** (tones_from_a4 / 12)
12
+ duration = int(duration)
13
+ audio = np.linspace(0, duration, duration * sr)
14
+ audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)
15
+ return sr, audio
16
+
17
+ demo = gr.Interface(
18
+ generate_tone,
19
+ [
20
+ gr.Dropdown(notes, type="index"),
21
+ gr.Slider(4, 6, step=1),
22
+ gr.Textbox(value="1", label="Duration in seconds"),
23
+ ],
24
+ "audio",
25
+ )
26
+ if __name__ == "__main__":
27
+ demo.launch()
28
+
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ wheel
2
+ paderbox
3
+ padertorch
4
+ onnxruntime
5
+ TTS
6
+ torchdiffeq