音源分離
Open-Unmix HQ はステレオ音楽トラックを 4 つの独立したステム — ボーカル、ドラム、ベース、その他 に分離します。独立した 4 つの BiLSTM モデル(各ステムに 1 つ)がミックス STFT 上でマグニチュードマスクを生成し、任意の Wiener 後処理で整合させます。MLX で Apple Silicon 上動作します。
2 つのエンジンが利用できます: Open-Unmix HQ(軽量、デフォルト)と HTDemucs (Demucs v4) — --engine htdemucs で選択する、より高品質な Hybrid Transformer モデルです。どちらも MLX を介して Apple Silicon 上で動作し、同じ 4 つのステムを 44.1 kHz で出力します。
概要
- 4 stems per track — vocals, drums, bass, other. Each is a 2-channel 44.1 kHz stem file.
- Magnitude-mask model — each stem model predicts a non-negative mask applied to the mixture spectrogram; phase is taken from the mixture.
- Wiener post-filter (optional) — soft-mask refinement across all 4 stems so they sum coherently back to the mixture. Adds ~0.5 dB SDR.
- Small footprint — 8.9M params per stem, ~136 MB total for all 4 stems.
- Apache-2.0 — upstream weights under MIT, our CoreML/MLX conversion under Apache-2.0.
アーキテクチャ
Four independent stems, each a copy of the same network:
| Stage | Shape / operation |
|---|---|
| STFT | 4096-point FFT, 1024-hop, periodic Hann window, reflect-pad. 2049 frequency bins per frame. |
| Input normalize | Crop to 1487 bins (≈16 kHz), apply learned per-bin mean + scale from training. |
| Encoder | Linear 2974 → 512 + BatchNorm + tanh. Input is 2 channels × 1487 bins. |
| BiLSTM | 3 layers, 256 hidden per direction (512 effective). Captures temporal context across frames. |
| Decoder | Skip-concat of encoder and LSTM outputs (1024) → Linear 1024 → 512 + BN + ReLU → Linear 512 → 4098. |
| Output denorm + mask | Element-wise multiply with mixture magnitude; phase from mixture; iSTFT overlap-add. |
| Wiener (optional) | Power-ratio masks across all 4 stem estimates. Refines phase so stems sum to mixture. |
モデル
| Component | Value |
|---|---|
| Parameters / stem | 8.9M |
| Parameters total (4 stems) | ~35.6M |
| Sample rate | 44.1 kHz stereo |
| Chunk latency | Offline (full-track STFT) |
| Weights | aufklarer/OpenUnmix-HQ-MLX (safetensors, ~136 MB) |
| Upstream | sigsep/open-unmix-pytorch (Stöter et al., JOSS 2019) |
HTDemucs (Demucs v4)
For higher separation quality — especially on bass and drums — the package also ships HTDemucs, Meta's Hybrid Transformer Demucs. It merges a spectrogram branch and a waveform branch through a cross-domain transformer; the shipped htdemucs_ft variant is a bag of four fine-tuned sub-models, one per stem. Weights download from HuggingFace on first use. On a directional MUSDB-sample benchmark (museval / BSSEval v4) it averages +3.01 dB SDR over UMX-HQ, with the biggest gains on bass (+5.75 dB).
| Component | Value |
|---|---|
| Parameters | 168M (4 × 42M fine-tuned sub-models) |
| Sample rate | 44.1 kHz stereo |
| Windowing | 7.8 s segments, 25% overlap, triangular cross-fade |
| Weights | aufklarer/HTDemucs-FT-MLX (fp16, ~320 MB) |
| Upstream | facebookresearch/demucs (Rouard et al., ICASSP 2023) |
クイックスタート — Swift
import SourceSeparation
import AudioCommon
let separator = try await SourceSeparator.fromPretrained()
let stereo = try AudioFileLoader.loadStereo(
url: URL(fileURLWithPath: "song.wav"),
targetSampleRate: 44100
)
let stems = separator.separate(audio: stereo, sampleRate: 44100)
// stems[.vocals], stems[.drums], stems[.bass], stems[.other]
// Each is [[Float]] — left channel, right channel.
try WAVWriter.writeStereo(
left: stems[.vocals]![0],
right: stems[.vocals]![1],
sampleRate: 44100,
to: URL(fileURLWithPath: "vocals.wav")
)
Pass wiener: true (default) for best quality. Pass targets: [.vocals] to extract only a subset of stems and skip the other models.
コマンドライン
speech separate song.wav # all 4 stems into song_stems/ (Open-Unmix)
speech separate song.wav --engine htdemucs # Demucs v4 — higher quality
speech separate song.wav --engine htdemucs --htdemucs-precision int8 # smaller int8 bundle
speech separate song.wav --stems vocals # vocals only
speech separate song.wav --stems vocals,drums # subset
speech separate song.wav --output-dir /tmp/stems/ # custom output dir
speech separate song.wav --verbose # show timing
使用タイミング
…Apple Silicon 上のアプリやパイプライン内で、軽量なオフライン音源分離が必要なときです。ステム毎に 890 万パラメータでダウンロードとメモリを節約。マグニチュードマスク + Wiener は多くのポップ/ロックで良好なステムを生成します。スタジオ素材で最先端のボーカル分離を行うには、--engine htdemucs で同梱の HTDemucs (Demucs v4) エンジンに切り替えてください。Open-Unmix は軽量でアプリへそのまま組み込めるトレードオフの側に留まります。