[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 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

  • #308 @be-student による — マージされずにクローズ

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python

調査の方向性

audio_separator/separator/common_separator.py から始め、separator.py と audio_separator/utils/cli.py の引数パーサーを通じて output_subtype を追跡します。既存の 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時間
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nomadkaraoke/python-audio-separator のほかの issue

nomadkaraoke/python-audio-separator の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。