Skip to content

Kokoro Noise Fix — atan2 phase correction (PR #50)

Latest

Choose a tag to compare

@Alex-Wengg Alex-Wengg released this 03 May 21:51

Pre-built KokoroNoise.mlpackage + KokoroNoise.mlmodelc bundles with the atan2 phase-correction fix from PR #50. Drop these into ~/.cache/.../kokoro-82m-coreml/ANE-zh/ (or your FluidAudio cache equivalent) to verify the fix without rebuilding from source.

What's fixed

CoreMLForwardSTFT.transform now matches PyTorch's atan2 branch convention at the (imag = 0, real < 0) boundary that hits the DC and Nyquist STFT bins on every real-valued input. The π/2π phase offset that previously propagated through noise_convs[0] into all 256 channels of x_source_0 is gone.

See models/tts/kokoro-v1.1-zh/coreml/convert-coreml.py:432-456 in the PR diff for the patch, and report.md / TRIALS.md for the full investigation.

Verification (before → after)

metric before after
KokoroNoise x_source_0 rel-rms 0.397 0.057
x_source_0 corr 0.911 0.998
HF audio (≥10 kHz) — CoreML, zm_009 −81.31 dB −83.91 dB
HF audio — PyTorch reference −83.81 dB −83.90 dB
Δ(CoreML − PyTorch) +2.50 dB −0.01 dB
Δ(CoreML − PyTorch), zf_001 (untested) +0.11 dB

CoreML output's noise band is now within 0.01 dB of the PyTorch reference on the male voice and 0.11 dB on the female voice. The audible noise is gone.

Asset contents

KokoroNoise-fixed.zip (~32 MB compressed, ~35 MB extracted) contains:

  • KokoroNoise.mlpackage/ — 17.6 MB, fp32 weights, no palettization
  • KokoroNoise.mlmodelc/ — 17.6 MB, compiled for ANE-zh deployment

Built with --no-palettize noise for diagnostic A/B parity. For HF deployment a palettized rebuild is recommended (see PR #50 description for the conversion command).

How to use

# Find your cache root for FluidAudio (depends on app)
CACHE=~/Library/Caches/.../kokoro-82m-coreml/ANE-zh

unzip KokoroNoise-fixed.zip -d /tmp/
mv "${CACHE}/KokoroNoise.mlmodelc" "${CACHE}/KokoroNoise.mlmodelc.bak.broken"
mv /tmp/KokoroNoise.mlmodelc "${CACHE}/"

Generated from PR branch feat/kokoro-v1.1-zh-coreml @ 7e931a1.