Separates a mixed audio file into individual stems (vocals, drums, bass, other instruments) using Meta’s Demucs neural network. Useful for analyzing individual elements of a mixed file, or preparing stems for masking analysis.
Requires the phantom-audio[separation] extra. Add it with: uv tool install "phantom-audio[separation]" --python 3.13 --force
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| file_path | string | required | Path to mixed audio file |
| output_dir | string | required | Directory to write separated stems. Must sit inside Phantom's output directory (~/.phantom/output by default, or PHANTOM_OUTPUT_DIR). Paths outside it are rejected. |
Example Output
Illustrative summary; MCP responses use structured JSON.
$ separate_stems full-mix.wav ~/.phantom/output
What the Numbers Mean
-
stems — A map of stem name to the WAV file path Phantom wrote it to. Each file is 16-bit PCM WAV at the model’s native sample rate.
-
output_dir — Must resolve inside
PHANTOM_OUTPUT_DIR(defaults to~/.phantom/output). A directory outside that sandbox is rejected. -
Processing time — Stem separation uses neural networks and is CPU-intensive. Runtime depends on audio length, model, and hardware; the first run also downloads model weights.
Example Prompts
Full separation
Separate my mix into stems — I want to analyze each element individually
Vocals only
Extract just the vocals from song.wav so I can analyze them
Analysis pipeline
Separate this reference track into stems, then run masking analysis between my vocals and the reference vocals
Related Tools
- analyze_masking — Compare separated stems for frequency overlap
- multi_stem_masking — Analyze all separated stems at once
- batch_diagnostic — Run diagnostics on all separated stems
Pro tip
Stem separation quality drops with heavily compressed or limited audio (less transient information for the model to work with). For best results, use the highest quality source available: uncompressed WAV or FLAC, before any mastering processing.