$ show deezer/spleeter
Spleeter is a Python library and CLI tool for music source separation, providing pretrained models to decompose audio tracks into stems (e.g., vocals, drums, bass, piano). The codebase is structured around a core Separator class backed by TensorFlow estimation, with abstract audio adapters (default FFMPEG), model providers (GitHub releases), and configuration loading from embedded or file-based JSON. The architecture supports both inference and training, with a well-defined pipeline for waveform loading, STFT computation, U-Net-based separation, and output saving. The library is designed for production use with multiprocessing support and Docker deployment. However, it relies heavily on deprecated TensorFlow 1.x APIs (tf.compat.v1, tf.estimator), indicating technical drift. The code is well-organized with clear separation of concerns, reusable components (audio adapter, model provider, utilities), and comprehensive test coverage.
The LLM identified 3 files worth highlighting for reuse:
Defines the `AudioAdapter` abstract base class for loading/saving audio, with a default instance (FFMPEG) and a dynamic factory method `get()` that imports a class by dotted path. This pattern enables swapping audio backends without changing client code, and is reusable in any audio processing pipeline.
Implements `AudioAdapter` using FFMPEG subprocesses. It handles loading (via ffmpeg.probe, ffmpeg.input to pipe) and saving (via ffmpeg.input from pipe). The code is robust, with proper error handling and codec mapping. This component can be extracted and reused as a standalone FFMPEG audio I/O utility.
Implements `ModelProvider` to download pretrained model archives from GitHub Releases. It uses HTTP/2 via httpx, computes SHA256 checksums, validates against a remote checksum index, and extracts tar.gz archives. This pattern is reusable for any project needing on-demand model downloading with integrity verification.