Tutorial · Python · ~6 min
How to Separate a Song into Stems in Python
No CUDA. No model weights to download. No OOM errors on long tracks. About five minutes, using our sample audio.
Step 1 — Sign up and get your API key
- Sign up (free tier included)
- Copy the key from the dashboard
- pip install mlslabs
Step 2 — Pick sample audio
| Sample | Use for |
|---|---|
| concert-stereo.wav | Live performance, 4 stems |
| pop-song.mp3 | Commercial-style mix |
| city-rain-night.wav | Environmental stems |
| movie-scene.wav | Dialogue + SFX separation |
Step 3 — Submit a separation job
Python
import mlslabs
client = mlslabs.Client("YOUR_API_KEY")
job = client.source_separation.submit(
input_url="s3://bucket/pop-song.mp3",
output_url="s3://bucket/stems/",
presets="music_4stems", # music_4stems | music_6stems | environmental | all
stems=["vocals", "drums", "bass", "guitar", "piano"],
)
print(job.job_id)Step 4 — Poll for the result
Python
job.wait()
print(job.status) # done | failedStep 5 — Download and verify
Bash
# each stem gets its own download URL
curl -L -o vocals.wav <vocals_url>
curl -L -o drums.wav <drums_url>
ffprobe -show_streams vocals.wav | grep -E "channels|duration"
# => channels=2, duration matches sourceNext: spatial upmixing
The separated stems are exactly what the upmixing pipeline wants: place each stem in space and render 5.1/7.1.2 — see the upmix tutorial.