$ show jiaaro/pydub
Pydub is a mature, high-level Python library for audio manipulation. It provides an immutable `AudioSegment` class that supports slicing, concatenation, overlaying, gain changes, fading, and format conversion using ffmpeg/avconv as a backend for non-WAV formats. The library includes a variety of DSP effects (normalize, speedup, compression, filters, equalization), silence detection/splitting, signal generators (sine, square, sawtooth, white noise), and optional playback via simpleaudio, pyaudio, or ffplay. Its architecture is modular, with core functionality in `audio_segment.py` and effects registered via a decorator pattern. The codebase demonstrates clean abstractions and is well-tested, though it carries some legacy Python 2 compatibility patterns.
The LLM identified 4 files worth highlighting for reuse:
Core class providing immutable audio segments with rich operators (+, -, *, slicing), methods for overlay, append, fade, gain, format conversion, and metadata queries (dBFS, duration, sample array). Demonstrates clean design for an immutable multimedia data type with seamless ffmpeg integration.
Provides functions to detect silent/non-silent regions and split audio on silence. Uses an efficient iterative approach with configurable thresholds and step sizes. Self-contained and easily reusable in any audio processing pipeline requiring silence-based segmentation.
Abstract base class for signal generators (Sine, Square, Sawtooth, Triangle, WhiteNoise) that produce float samples and convert to AudioSegment. Extensible design: subclass and implement generate() generator. Useful for synthetic audio creation, testing, or audio effects prototyping.
Contains the `register_pydub_effect` decorator that dynamically adds methods to AudioSegment, enabling a plugin-like effect system. Also provides reusable utilities: db/ratio conversions, chunk splitting, codec probing, and ffmpeg path detection. The decorator pattern is notable for cleanly extending a core class.