pedalboard / app.py
Ahsen Khaliq
Update app.py
4d01fa5
raw history blame
No virus
1.46 kB
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)