Skip to main content

Separate audio into stems (vocals, instruments) using AI-powered Spleeter

Project description

demix

version build release

audio processing tool: download from YouTube or use local files, separate stems, adjust tempo/pitch, detect and transpose key, and cut segments.

prerequisites

[!NOTE] Please note: I'm using homebrew for installing virtualenvwrapper and ffmpeg. If you're using another package manager or different operating system than macOS (e.g. Linux), you need to install it differently. In the examples for creating virtualenv below, replace python path below with your own python3.8 path. I'm personally using pyenv for installing various python verions, but you can do it as you wish.

installation

I suggest to create virtualenv for this project to not break existing system-wide installations:

brew install virtualenvwrapper
brew install ffmpeg
mkdir demix
cd demix
mkvirtualenv -p /Users/pw/.pyenv/versions/3.8.16/bin/python demix
workon demix
pip install demix
demix -v

update

pip install demix --upgrade

development

prepare environment:

brew install virtualenvwrapper
brew install ffmpeg
git clone git@github.com:pwittchen/demix.git
cd demix
mkvirtualenv -p /Users/pw/.pyenv/versions/3.8.16/bin/python demix
workon demix
pip install -r requirements.txt
python demix.py -v

virtualenv

exit virtualenv, when you're done:

deactivate

to activate env again:

workon demix

testing

install pytest:

pip install pytest

run all tests (-v param for verbose):

pytest -v

versioning and deployment

When we create and push a new git tag, e.g. v1.0.4, deploy.yml github action is triggered. It automatically extracts created tag, updates version with bump_version.py script, performs git commit and push. After that, deployment of the new package version to PyPi is executed.

usage

demix -u <youtube-url> [options]
demix -s <search-query> [options]
demix -f <audio-file> [options]

options

Option Description
-u, --url YouTube video URL to process
-s, --search Search YouTube for a song (e.g., 'Artist - Song Name')
-f, --file Local audio file to process (mp3, wav, flac, etc.)
-o, --output Output directory (default: output)
-t, --tempo Tempo factor for output audio (default: 1.0, use < 1.0 to slow down)
-p, --transpose Transpose pitch by semitones (default: 0, range: -12 to +12)
-k, --key Detect and display the musical key of the audio
-K, --target-key Transpose audio to target key (e.g., C, Am, F#, Bb minor)
-ss, --start Start time for cutting (format: MM:SS or HH:MM:SS)
-to, --end End time for cutting (format: MM:SS or HH:MM:SS)
-m, --mode Processing mode: nosplit, 2stems, 4stems, or 5stems (default: nosplit)
--video Generate video: accompaniment track in 2stems mode, or the output music track in nosplit mode (default: skip video generation)
-q, --quiet Suppress progress messages and spinners; print only the final result and errors
-c, --clean Clean up files: output, models, or all
-v, --version Show version number
-h, --help Show help message

modes

Mode Description
nosplit No stem separation (download, convert, and apply effects only)
2stems vocals, accompaniment
4stems vocals, drums, bass, other
5stems vocals, drums, bass, piano, other

examples

# separate a YouTube video into vocals and accompaniment
demix -u 'https://www.youtube.com/watch?v=VIDEO_ID' -m 2stems

# search YouTube by artist and song name
demix -s 'Queen - Bohemian Rhapsody' -m 4stems

# separate a local file with 4 stems
demix -f /path/to/song.mp3 -m 4stems

# cut audio from 1:30 to 3:45
demix -f song.mp3 -ss 1:30 -to 3:45

# start from 0:30 (skip intro)
demix -f song.mp3 -ss 0:30

# keep only the first 2 minutes
demix -f song.mp3 -to 2:00

# combine cutting with tempo and transpose
demix -f song.mp3 -ss 1:00 -to 4:00 -t 0.8 -p -2

# detect musical key of a song
demix -f song.mp3 -k

# detect key before and after transposing
demix -f song.mp3 -k -p -3

# transpose to a specific key (auto-detects current key)
demix -f song.mp3 -K C

# transpose to A minor
demix -f song.mp3 -K Am

# transpose to target key with tempo change
demix -f song.mp3 -K "F# minor" -t 0.9

# slow down without separating stems
demix -f song.mp3 -t 0.8 -m nosplit

# download and cut without separation
demix -u 'https://www.youtube.com/watch?v=VIDEO_ID' -ss 1:00 -to 3:00 -m nosplit

# run silently and only print the final result message
demix -f song.mp3 -m 4stems -q

Claude Code skill

This repo ships a Claude Code skill at .claude/skills/demix/SKILL.md that translates plain-English requests into demix invocations — describe what you want and Claude picks the flags, shows the command, and runs it.

Examples of requests the skill handles:

  • "Download https://youtu.be/abc123 and give me the instrumental"demix -u 'https://youtu.be/abc123' -m 2stems
  • "Find 'Radiohead Creep', slow it 15%, keep only the first two minutes"demix -s 'Radiohead Creep' -t 0.85 -to 2:00
  • "~/Music/song.mp3 — transpose to G minor and split into 4 stems"demix -f '~/Music/song.mp3' -m 4stems -K 'Gm'
  • "What key is song.wav in?"demix -f 'song.wav' -k
  • "Make a karaoke video from 'Adele - Hello'"demix -s 'Adele - Hello' -m 2stems --video

Trigger it by typing /demix in Claude Code, or just describe the task in natural language — the skill loads automatically when the intent matches.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demix-1.6.1.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

demix-1.6.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file demix-1.6.1.tar.gz.

File metadata

  • Download URL: demix-1.6.1.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for demix-1.6.1.tar.gz
Algorithm Hash digest
SHA256 b0ef21e05d842b9a347c36ac3d84f5ffdd34fcb7a4f90475304b13c8fe42ec1f
MD5 74090c56a2f350a5c49af4bd35da2e7f
BLAKE2b-256 a9c3f21991f3f5e26564631d80ee1caced3436cd82d50fffbf16691be8c077bd

See more details on using hashes here.

File details

Details for the file demix-1.6.1-py3-none-any.whl.

File metadata

  • Download URL: demix-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for demix-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f513e9c590e8d9b1af5df228dc2f37468b97771ca96610b30bd63d5c15ef280e
MD5 e27b5b424b2db607416dce83a055254a
BLAKE2b-256 4bdd9168c40f33699d71bd684e4146a53d74e04f6af00c66f3ae114623e7f3e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page