Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from pedalboard import Pedalboard, Chorus, Reverb, Distortion
|
3 |
from pedalboard.io import AudioFile
|
4 |
-
|
5 |
-
# Make a Pedalboard object, containing multiple plugins:
|
6 |
-
board = Pedalboard([Chorus(), Reverb(room_size=0.25)])
|
7 |
-
|
8 |
-
def greet(name, room_size):
|
9 |
with AudioFile(name) as f:
|
10 |
audio = f.read(f.frames)
|
11 |
samplerate = f.samplerate
|
12 |
|
13 |
-
|
14 |
-
board
|
15 |
|
16 |
-
|
17 |
effected = board(audio, samplerate)
|
18 |
output = "output.wav"
|
19 |
-
|
20 |
-
# Write the audio back as a wav file:
|
21 |
with AudioFile('output.wav', 'w', samplerate, effected.shape[0]) as f:
|
22 |
f.write(effected)
|
23 |
return output
|
24 |
|
25 |
-
|
26 |
-
demo = gr.Interface(fn=greet,
|
27 |
-
# Use the gr.inputs.Controls input type to add the control_kwargs parameter in the inputs section
|
28 |
-
inputs=[gr.inputs.Audio(type="filepath"), gr.inputs.Controls(control_kwargs={"room_size": {"label": "Room size", "min": 0, "max": 1, "step": 0.1}}}),
|
29 |
-
outputs=gr.Audio(type="filepath"))
|
30 |
|
31 |
-
# Launch the interface
|
32 |
demo.launch()
|
33 |
-
This allows you to specify the control_kwargs parameter in the inputs section, along with the other input types. The room_size argument in the greet function is used to update the room_size parameter of the Reverb plugin.
|
34 |
-
|
35 |
|
36 |
|
|
|
1 |
import gradio as gr
|
2 |
from pedalboard import Pedalboard, Chorus, Reverb, Distortion
|
3 |
from pedalboard.io import AudioFile
|
4 |
+
def greet(name):
|
|
|
|
|
|
|
|
|
5 |
with AudioFile(name) as f:
|
6 |
audio = f.read(f.frames)
|
7 |
samplerate = f.samplerate
|
8 |
|
9 |
+
# Make a Pedalboard object, containing multiple plugins:
|
10 |
+
board = Pedalboard([Chorus(), Reverb(room_size=0.25)])
|
11 |
|
12 |
+
# Run the audio through this pedalboard!
|
13 |
effected = board(audio, samplerate)
|
14 |
output = "output.wav"
|
15 |
+
# Write the audio back as a wav file:
|
|
|
16 |
with AudioFile('output.wav', 'w', samplerate, effected.shape[0]) as f:
|
17 |
f.write(effected)
|
18 |
return output
|
19 |
|
20 |
+
demo = gr.Interface(fn=greet, inputs=gr.Audio(type="filepath"), outputs=gr.Audio(type="filepath"))
|
|
|
|
|
|
|
|
|
21 |
|
|
|
22 |
demo.launch()
|
|
|
|
|
23 |
|
24 |
|