[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
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 1.5k
- 派生
- 216
- 平均合并
- 1 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nomadkaraoke/python-audio-separator 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 68/100
nomadkaraoke/python-audio-separator#292 · 2 条评论 ·
-
Confusing info in README可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 1/5 1 小时以内 新手友好度 65/100
nomadkaraoke/python-audio-separator#246 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
查看 nomadkaraoke/python-audio-separator 的全部 Issue
相似的 Issue
-
request_access
难度 1/5 1 小时以内 新手友好度 75/100
-
blocker bug
难度 2/5 1-3 小时 新手友好度 76/100
achisolomon/software-factory#305 ·
-
难度 2/5 1-3 小时 新手友好度 92/100
erkamyaman/rust-anything#963 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
commonmark/commonmark-spec#850 ·
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 78/100