Overview
SoundfileMixer is an audio mixer that combines incoming audio with audio from files. It supports multiple audio file formats through the soundfile library and can handle runtime volume adjustments and sound switching.
Installation
No additional dependencies are required —soundfile is included in the base Pipecat installation.
Sample Rate Requirements
Sound files must match the output transport’s sample rate and be mono (single channel). If a file’s sample rate doesn’t match, the mixer skips it at load time and logs a warning:has incorrect sample rate and convert the file to the transport’s sample rate.
Constructor Parameters
Dictionary mapping sound names to file paths. Files must be mono (single channel), and each file’s sample rate must match the output transport’s sample rate.
Initial volume for the mixed sound. Values typically range from 0.0 to 1.0, but can go higher.
Control Frames
Usage Example
Notes
- Supports any audio format that soundfile can read
- Sound files must be mono and match the output transport’s sample rate — they are not resampled (see Sample Rate Requirements)
- Thread-safe for pipeline processing
- Can dynamically switch between multiple sound files
- Volume can be adjusted in real-time
- Mixing can be enabled/disabled on demand