[Feature]: internal processing is 32 bit float but output is truncated to 16 bit integer - allow for 32 or 24 bit output

未关闭
#258 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

  • #308 来自 @be-student —— 已关闭,未合并

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
python

调研方向

从 audio_separator/separator/common_separator.py 开始,然后跟踪 output_subtype 在 separator.py 以及 audio_separator/utils/cli.py 中的参数解析器里的传递过程。检查现有的 pydub 和 soundfile 路径如何处理 WAV 和 FLAC 输出,并验证配置的位深能够传递到 Separator。完成的标准是 24-bit 无损输出能够正常工作,同时现有的 16-bit 和有损格式行为保持不变。

由索引模型根据 Issue 内容生成。

描述

enhancement
Description

Claude Code:

1. 24-bit PCM output support via soundfile

Files:

  • audio_separator\separator\common_separator.py — __init__() + write_audio_pydub()
  • audio_separator\separator\separator.py — __init__() + config dict
  • audio_separator\utils\cli.py — argument parser + Separator instantiation

Date: 2025-02-12

Problem:
Models output float32 (~24 bits of precision) but write_audio_pydub() truncates all output to int16 (16-bit) before writing. The existing write_audio_soundfile() path (--use_soundfile) has a bug where float data is assigned to an int16 interleave array without scaling by 32767, producing silent output. Documentation claimed 24-bit output but the library was always writing 16-bit.

Changes:

common_separator.py

Added output_subtype from config (after line ~85):

self.output_subtype = config.get("output_subtype", "PCM_16")

Added early-return soundfile path in write_audio_pydub() (before the int16 conversion):

# For WAV/FLAC with PCM_24, use soundfile directly (pydub can't do 24-bit)
file_format = stem_path.lower().split(".")[-1]
if self.output_subtype == "PCM_24" and file_format in ("wav", "flac"):
    import soundfile as sf
    sf.write(stem_path, stem_source, self.sample_rate, subtype="PCM_24")
    self.logger.debug(f"Exported 24-bit {file_format.upper()} via soundfile to {stem_path}")
    return
separator.py

Added output_subtype="PCM_16" parameter to __init__(), stored as self.output_subtype, and included in the config dict passed to architecture-specific separators.

cli.py

Added --output_subtype argument (default "PCM_16") and passed it to the Separator constructor.

Why: Preserves the full precision of model output. 24-bit PCM captures the float32 model output without the quantization noise from 16-bit truncation. The existing pydub int16 path remains untouched for 16-bit output and lossy formats (MP3, M4A, etc.).

Note: The broken write_audio_soundfile() path was not modified — instead, the fix uses soundfile.write() directly inside the existing write_audio_pydub() method with an early return for 24-bit lossless formats. This avoids the interleaving bugs in the soundfile path while keeping the change minimal.

Configuration: Controlled by separation_bit_depth in the [output_processing] section of UpMixery.ini. The value is passed to audio_separator_launcher.py via --bit-depth, which maps it to --output_subtype PCM_24 or PCM_16.

主要语言
Python
星标
1.5k
派生
216
平均合并
1 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nomadkaraoke/python-audio-separator 的其他 Issue

查看 nomadkaraoke/python-audio-separator 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。