DEV Community

Tania Alwan
Tania Alwan

Posted on

How Ultimate Vocal Remover Separates Vocals: From Phase Cancellation to Neural Masks, With a Python Demo

By Tania Alwan

If you've ever tried to make a karaoke track or an acapella, someone has probably told you to use Ultimate Vocal Remover. UVR is a free, open-source desktop app that runs neural source separation models on your own computer, and it's one of the tools I reach for most when I need a clean vocal.

But what is it actually doing? In this post I explain the two big ideas behind vocal removal: the old centre-channel trick and the neural approach that tools like UVR use. Then I'll walk through a small Python script, tested with Python 3 and NumPy, that shows both on a synthetic mix where we know the right answer.

What Ultimate Vocal Remover is (and isn't)

According to its GitHub README, Ultimate Vocal Remover GUI is an application that "uses state-of-the-art source separation models to remove vocals from audio files." A few facts worth knowing:

  • It's free and open source. The GUI code is MIT-licensed, and the core developers are Anjok07 and aufr33
  • It runs locally. There are installers for Windows and macOS, and instructions for Linux, so your audio stays on your machine
  • It's a front end for several model families. The README credits tsurumeso for the original VR Architecture code, KUIELab and Woosung Choi for the original MDX-Net code, Meta's Demucs (by Alexandre Défossez) and ZFTurbo for the MDX23C models
  • Most models were trained by the UVR team. The README says the core developers trained all bundled models except the Demucs v3 and v4 4-stem models

So UVR isn't one algorithm. It's a convenient way to run and compare several separation architectures without writing code.

The old trick: centre-channel cancellation

Before neural networks, the classic "vocal remover" was phase cancellation. In many mixes the lead vocal is panned dead centre, which means it's identical in the left and right channels. Subtract one channel from the other and anything identical cancels out:

side = (left - right) / 2
Enter fullscreen mode Exit fullscreen mode

It's cheap and instant, but it has well-known problems:

  • Everything in the centre disappears, not just the vocal. Bass and kick drum are usually centred too
  • Stereo effects survive. Reverb and delay on the vocal are often wider than the dry voice, so they leak through as a ghostly echo
  • The result is mono, because you've thrown away what the two channels had in common

The neural approach: predicting a mask

Most modern separators work on a spectrogram, a picture of the sound showing how much energy is at each frequency over time. The model looks at the spectrogram of the mix and predicts a mask: a value between 0 and 1 for every time-frequency cell that says how much of that cell belongs to the vocal.

Multiply the mix spectrogram by the mask, convert back to audio, and you have an estimated vocal. Multiply by one minus the mask and you have the instrumental.

The VR Architecture and MDX-Net models in UVR work on spectrograms. Demucs started as a waveform model, and newer versions combine a waveform branch with a spectrogram branch. The details differ, but the goal is the same: learn from many songs with known stems what a voice looks like, so the model can find it in a mix it has never heard.

That's why neural separation doesn't care where the vocal is panned. It recognises the voice by its spectral patterns, harmonics and the way they move over time, not by its position.

A Python demo: cancellation vs an ideal mask

The script below builds a 4-second synthetic stereo mix: a "vocal" melody with vibrato and a bass line in the centre, a plucked "guitar" panned left and a "pad" panned right. Because we built the mix, we know each stem, which lets us measure the results.

It then tries:

  1. Centre-channel cancellation, with a dry vocal and with a one-sided echo on the vocal
  2. An oracle soft mask: the ideal mask computed from the true stems. A real model has to estimate this from the mix alone, so treat it as an upper bound for this simple masking method, not as what a model will achieve

You only need NumPy (pip install numpy). Save it as separate.py:

import wave
import numpy as np

SR = 22050
t = np.arange(int(SR * 4.0)) / SR

def tone(f0, n_harm, decay):
    return sum((decay ** k) * np.sin(2 * np.pi * f0 * (k + 1) * t) for k in range(n_harm))

# "vocal": a 4-note melody with vibrato and a few harmonics
notes = np.repeat([220.0, 247.0, 262.0, 247.0], len(t) // 4 + 1)[: len(t)]
f0 = notes * (1 + 0.01 * np.sin(2 * np.pi * 5.5 * t))
phase = 2 * np.pi * np.cumsum(f0) / SR
vocal = sum((0.6 ** k) * np.sin((k + 1) * phase) for k in range(6)) * 0.3

bass = tone(55.0, 4, 0.5) * 0.3                               # centred, like the vocal
guitar = tone(330.0, 5, 0.6) * np.exp(-3 * (t % 0.5)) * 0.3   # plucked, mostly left
pad = (tone(392.0, 3, 0.5) + tone(494.0, 3, 0.5)) * 0.12      # mostly right

def pan(x, p):  # p = -1 (left) .. +1 (right), constant-power pan law
    a = (p + 1) * np.pi / 4
    return np.array([np.cos(a) * x, np.sin(a) * x])

def side(st):   # centre-channel cancellation: (L - R) / 2
    return (st[0] - st[1]) / 2

def energy(x):
    return float(np.sum(x ** 2))

def sdr(ref, est):
    return 10 * np.log10(energy(ref) / (energy(ref - est) + 1e-12))

def write_wav(name, x):
    x = x / (np.max(np.abs(x)) + 1e-9) * 0.9
    with wave.open(name, "wb") as w:
        w.setnchannels(1); w.setsampwidth(2); w.setframerate(SR)
        w.writeframes((x * 32767).astype(np.int16).tobytes())

stems = {"vocal": pan(vocal, 0), "bass": pan(bass, 0),
         "guitar": pan(guitar, -0.8), "pad": pan(pad, 0.8)}
stereo_mix = sum(stems.values())

# --- Method 1: centre-channel cancellation ---
print("Method 1: centre-channel cancellation (L - R)")
for name, st in stems.items():
    kept = energy(side(st)) / (energy(st.mean(axis=0)) + 1e-12)
    print(f"  {name:7s} left after cancelling: {100 * kept:6.1f}% (vs. its level in the mono mix)")

# Same vocal with a short echo on the right channel only (a stereo effect)
d = int(0.12 * SR)
echo = np.concatenate([np.zeros(d), stems["vocal"][1][:-d]]) * 0.5
wet_vocal = stems["vocal"] + np.array([np.zeros_like(echo), echo])
wet_side = side(stereo_mix - stems["vocal"] + wet_vocal)
print(f"  with a one-sided echo, vocal = {100 * energy(side(wet_vocal)) / energy(wet_side):.0f}% "
      "of the 'karaoke' output")

# --- Method 2: spectrogram masking (what neural separators learn to estimate) ---
N, H = 1024, 256
win = np.hanning(N)

def stft(x):
    return np.fft.rfft(np.array([x[i:i + N] * win for i in range(0, len(x) - N, H)]), axis=1)

def istft(X, length):
    y, norm = np.zeros(length), np.zeros(length)
    for k, frame in enumerate(np.fft.irfft(X, n=N, axis=1)):
        y[k * H:k * H + N] += frame * win
        norm[k * H:k * H + N] += win ** 2
    return y / np.maximum(norm, 1e-8)

mono = stereo_mix.mean(axis=0)
true_vocal = stems["vocal"].mean(axis=0)
true_accomp = mono - true_vocal
V, A, M = stft(true_vocal), stft(true_accomp), stft(mono)
mask = np.abs(V) ** 2 / (np.abs(V) ** 2 + np.abs(A) ** 2 + 1e-12)  # "oracle" soft mask
est_vocal = istft(mask * M, len(mono))
est_accomp = istft((1 - mask) * M, len(mono))

e = slice(N, len(mono) - N)  # skip edges where frames don't fully overlap
print("Method 2: oracle soft mask on the mono mix")
print(f"  vocal SDR:          {sdr(true_vocal[e], est_vocal[e]):5.1f} dB")
print(f"  accompaniment SDR:  {sdr(true_accomp[e], est_accomp[e]):5.1f} dB")
print(f"  baseline (mix used as the vocal): {sdr(true_vocal[e], mono[e]):5.1f} dB")

write_wav("mix_mono.wav", mono)
write_wav("karaoke_side.wav", side(stereo_mix))
write_wav("mask_vocal.wav", est_vocal)
write_wav("mask_accompaniment.wav", est_accomp)
print("Wrote mix_mono.wav, karaoke_side.wav, mask_vocal.wav, mask_accompaniment.wav")
Enter fullscreen mode Exit fullscreen mode

Running python separate.py prints:

Method 1: centre-channel cancellation (L - R)
  vocal   left after cancelling:    0.0% (vs. its level in the mono mix)
  bass    left after cancelling:    0.0% (vs. its level in the mono mix)
  guitar  left after cancelling:   52.8% (vs. its level in the mono mix)
  pad     left after cancelling:   52.8% (vs. its level in the mono mix)
  with a one-sided echo, vocal = 23% of the 'karaoke' output
Method 2: oracle soft mask on the mono mix
  vocal SDR:           14.2 dB
  accompaniment SDR:   15.2 dB
  baseline (mix used as the vocal):  -0.9 dB
Wrote mix_mono.wav, karaoke_side.wav, mask_vocal.wav, mask_accompaniment.wav
Enter fullscreen mode Exit fullscreen mode

It also writes four short WAV files you can open in any audio player or DAW.

Reading the results

Cancellation does exactly what the maths says. The centred vocal drops to 0%, but so does the centred bass. The panned guitar and pad survive at reduced level. Listen to karaoke_side.wav and you'll hear a thin instrumental with no low end.

A stereo effect breaks it. Add a single echo to only the right channel of the vocal, which is a simple stand-in for a wide reverb or delay, and the vocal makes up 23% of the "karaoke" output. That's the ghost vocal people hear when they try this on real songs.

Masking separates by content, not position. The oracle mask works on the mono mix, where panning information is gone, and still gets around 14 to 15 dB SDR (signal-to-distortion ratio) for both parts, versus about -1 dB if you simply used the mix as the "vocal". Higher SDR means the estimate is closer to the true stem.

A big caveat: this toy mix is easy. The vocal and instruments sit on different notes, so their harmonics rarely overlap. In real songs, voices and instruments share frequencies all the time, the mix has reverb, compression and distortion, and the model has to guess the mask. That's where model choice in UVR starts to matter.

Practical tips for using Ultimate Vocal Remover

From my own use, a few habits make a bigger difference than any single setting:

  • Start from the best source you have. A lossless file usually separates more cleanly than a low-bitrate stream rip
  • Try more than one model. Different architectures handle different material better, so compare two or three on the same chorus before processing a whole album
  • Listen on headphones. Artefacts like "watery" cymbals or breathy fragments in the instrumental are easy to miss on laptop speakers
  • Check the vocal in context. A vocal that sounds fine soloed can still carry faint drums that show up once you add new music under it
  • Expect a GPU to help. Separation runs on a CPU, but it's much slower on long files

Alternatives if you don't want to install anything

UVR is excellent if you're comfortable installing a desktop app and picking models. If you'd rather work in the browser, hosted services do the same kind of separation for you. Moises and LALAL.AI are well-known options, and the Voicestars AI stems splitter separates a song into vocals, drums, bass, guitars, piano and other. Compare their limits and terms, because they differ from service to service.

If you're a developer, you can also call Demucs directly from Python or the command line and build separation into your own pipeline.

Try it yourself

Run the script, then change one thing at a time: pan the vocal slightly off-centre, add the echo to both channels, or move the guitar onto the same notes as the vocal and watch the mask scores drop. Once you've seen where the simple methods break, open UVR on a real song and listen for the same problems.

Disclosure: this article was written in partnership with Voicestars.

Top comments (0)