[Bug]: MDX models: vocals scaled down by the input's peak when the input peak is below normalization_threshold , leaving voice in the instrumental stem

Aperta
#318 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@Rahul-cs50 ci sta già lavorando.

Dal 4/11/2026.

  • #319 di @Rahul-cs50 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start in separator/architectures/mdx_separator.py, in separate(), where peak is computed, the mix goes through spec_utils.normalize, and the output is multiplied by peak. Reproduce with a quiet input (peak around 0.35) using an MDX model such as Kim_Vocal_2.onnx, and check whether the vocal and instrumental stems sum back to the input level. Done when the gain applied by normalize is undone correctly, so the stems match the original scale, and the Roformer/MDXC results still hold.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Describe the bug

Title: MDX models: vocals scaled down by the input's peak when the input peak is below normalization_threshold, leaving voice in the instrumental stem

Version: audio-separator 0.48.0, onnxruntime 1.31.1 (CPU), torch 2.11.0+cpu, Python 3.12.3, Linux x86_64

Summary

In separator/architectures/mdx_separator.py, separate() does:

peak = np.abs(mix).max()                                                    # line 168
mix = spec_utils.normalize(wave=mix, max_peak=self.normalization_threshold,
                           min_peak=self.amplification_threshold)           # line 169
source = self.demix(mix) * peak                                             # line 172
...
self.secondary_source = (-self.primary_source * self.compensate) + mix.T    # line 195

normalize() only rescales the mix when its peak is above max_peak (0.9 by default), or below min_peak. For any input whose peak lies between those two values, the mix is passed through unchanged, but the result is still multiplied by peak. The primary (vocal) stem is therefore scaled down by the input's own peak. Because the secondary stem is mix - primary * compensate, the missing part of the voice ends up in the instrumental.

Reproduction

Any quiet speech or vocal file with a peak of about 0.3–0.5, separated with an MDX model (Kim_Vocal_2.onnx or UVR-MDX-NET-Voc_FT.onnx):

  • A talk excerpt with peak 0.355 gave vocals exactly 9.0 dB below the input level (20·log10 0.355 = −9.0).
  • On plain speech with no music, the instrumental stem was only 3.8 dB below the original. It should be near silence.
  • The instrumental was 99.4% correlated with the vocal stem: it was essentially (1 − peak) / peak × vocals.
  • Rescaling the same file to peak 1.0 before separation, so the multiplication becomes × 1, fixed it. Vocals were then −0.2 dB from the input, and the instrumental −19.3 dB, matching BS-Roformer on the same audio.

Roformer and MDXC models go through a different code path and were not affected in our tests.

Expected

The stems sum back to the input at its original level, whatever the input loudness.

Suggested fix

Keep the gain that normalize() actually applied, and undo exactly that gain, for example:

peak_in = np.abs(mix).max()
mix_norm = spec_utils.normalize(wave=mix.copy(), max_peak=self.normalization_threshold,
                                min_peak=self.amplification_threshold)
gain = (np.abs(mix_norm).max() / peak_in) if peak_in > 0 else 1.0
source = self.demix(mix_norm) / gain
...
self.secondary_source = (-self.primary_source * self.compensate) + mix.T  # original-scale mix

An alternative is to always normalise to unit peak before demix and multiply by peak afterwards, as the current code seems to assume.

Workaround for users

Rescale the input to peak exactly 1.0, pass normalization_threshold=1.0, and scale both output stems back by the original peak. Use float WAV input and use_soundfile=True, so the output keeps float format and nothing clips.

Have you searched for existing issues? 🔎
  • I have searched and found no existing issues.
Lingua principale
Python
Stelle
1.5k
Fork
216
Merge medio
1h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nomadkaraoke/python-audio-separator

Tutte le issue di nomadkaraoke/python-audio-separator

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.