File size: 1,455 Bytes
676cdad
 
 
 
 
4d01fa5
 
 
 
 
676cdad
 
4d01fa5
 
 
 
 
 
 
 
676cdad
 
 
 
 
 
 
 
 
7aaaf2f
 
d24f07f
676cdad
08f9357
676cdad
4d01fa5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import librosa
import gradio as gr
import pedalboard
import soundfile as sf

from pedalboard import Compressor, Gain, Phaser, Reverb




def inference(audio):
    y, sr = librosa.load(audio.name, sr=44100)
    board = pedalboard.Pedalboard([
        Compressor(ratio=10, threshold_db=-20),
        Gain(gain_db=20),
        Phaser(),
        Reverb()
    ], sample_rate=sr)
    
    effected = board.process(y)
    with sf.SoundFile('./processed-output-stereo.wav', 'w', samplerate=sr, channels=len(effected.shape)) as f:
        f.write(effected)
    return './processed-output-stereo.wav'


inputs = gr.inputs.Audio(label="Input Audio", type="file")
outputs =  gr.outputs.Audio(label="Output Audio", type="file")


title = "PedalBoard"
description = "Gradio demo for PedalBoard: A Python library for adding effects to audio. To use it, simply add your audio, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://engineering.atspotify.com/2021/09/07/introducing-pedalboard-spotifys-audio-effects-library-for-python/' target='_blank'>Introducing Pedalboard: Spotify’s Audio Effects Library for Python</a> | <a href='https://github.com/spotify/pedalboard' target='_blank'>Github Repo</a></p>"

examples = [['sample.wav']]

gr.Interface(inference, inputs, outputs, title=title, description=description, article=article, examples=examples, enable_queue=True).launch(debug=True)