Pedalboard: Spotify's Python Library for Audio Effects and Machine Learning
Summary
Pedalboard is a robust Python library developed by Spotify's Audio Intelligence Lab, designed for comprehensive audio processing tasks. It facilitates reading, writing, rendering, and applying a wide array of audio effects, including support for VST3® and Audio Unit plugins. Internally, Spotify leverages Pedalboard for data augmentation to enhance machine learning models and power innovative features like AI DJ, making advanced audio manipulation accessible within Python and TensorFlow environments.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
Pedalboard is a powerful Python library developed by Spotify's Audio Intelligence Lab, designed for comprehensive audio processing. It enables developers and researchers to read, write, render, and add a wide range of effects to audio. The library supports most popular audio file formats out of the box and, crucially, allows the integration of VST3® and Audio Unit formats for loading third-party software instruments and effects.
Internally at Spotify, Pedalboard is a cornerstone for data augmentation, significantly improving machine learning models. It also helps power innovative features such as Spotify's AI DJ and AI Voice Translation. Beyond its ML applications, Pedalboard streamlines content creation by making it possible to apply studio-quality effects to audio without the need for a traditional Digital Audio Workstation.
Installation
Getting started with Pedalboard is straightforward. The library is available via PyPI:
pip install pedalboard
For those new to Python, a comprehensive installation guide is available in the INSTALLATION.md file within the GitHub repository.
Pedalboard is thoroughly tested and compatible with Python 3.10, 3.11, 3.12, 3.13, and 3.14 across multiple platforms, including Linux (x86_64, aarch64), macOS (Intel and Apple Silicon), and Windows (amd64).
Examples
Pedalboard offers intuitive APIs for common audio tasks. Here's a quick start example demonstrating how to apply a chorus and reverb effect to an audio file:
from pedalboard import Pedalboard, Chorus, Reverb
from pedalboard.io import AudioFile
# Make a Pedalboard object, containing multiple audio plugins:
board = Pedalboard([Chorus(), Reverb(room_size=0.25)])
# Open an audio file for reading, just like a regular file:
with AudioFile('some-file.wav') as f:
# Open an audio file to write to:
with AudioFile('output.wav', 'w', f.samplerate, f.num_channels) as o:
# Read one second of audio at a time, until the file is empty:
while f.tell() < f.frames:
chunk = f.read(f.samplerate)
# Run the audio through our pedalboard:
effected = board(chunk, f.samplerate, reset=False)
# Write the output to our output file:
o.write(effected)
For more detailed examples, including making guitar-style pedalboards, using VST3®/Audio Unit plugins, creating parallel effects chains, running on live audio, and integrating with TensorFlow tf.data pipelines, refer to:
- The "examples" folder of the repository
- The "Pedalboard Demo" Colab notebook
- The YouTube video, "Working with Audio in Python (feat. Pedalboard)" by Peter Sobot
- An interactive web demo on Hugging Face Spaces and Gradio
Why Use Pedalboard?
Pedalboard stands out as a premier choice for audio processing in Python due to several key advantages:
- Comprehensive Audio I/O: It provides robust utilities for reading and writing various audio formats (AIFF, FLAC, MP3, OGG, WAV, AAC, AC3, WMA) with no external dependencies for core formats. It also supports on-the-fly resampling and live audio streaming.
- Rich Set of Built-in Effects: The library includes a diverse collection of audio transformations, from guitar-style effects like Chorus and Distortion to loudness control (Compressor, Limiter), equalizers (HighpassFilter, LowpassFilter), spatial effects (Delay, Reverb), and pitch manipulation.
- VST3® and Audio Unit Support: A significant feature is its ability to load and utilize third-party VST3® and Audio Unit instrument and effect plugins, greatly expanding its capabilities.
- High Performance: Engineered for efficiency, Pedalboard boasts strong thread-safety and optimized memory usage. It releases Python's Global Interpreter Lock (GIL), allowing for multi-core CPU utilization without
multiprocessing. It processes audio significantly faster than alternatives like pySoX and librosa.load. - Machine Learning Integration: With tested compatibility for TensorFlow, Pedalboard can be seamlessly integrated into
tf.datapipelines, making it an ideal tool for audio-centric machine learning projects.
Links
- GitHub Repository: https://github.com/spotify/pedalboard
- Official Documentation: https://spotify.github.io/pedalboard
- PyPI Package: https://pypi.org/project/pedalboard
- YouTube Video: "Working with Audio in Python (feat. Pedalboard)"
- Citing Pedalboard (Zenodo): https://doi.org/10.5281/zenodo.7817838