MLX Kokoro TTS produces NaN / silent audio on Apple Silicon β€” all voices, all languages

#5
by duck-tape - opened

Environment:

Mac: M3 Max (48 GB), macOS Sequoia 15
mlx-audio 0.4.4
mlx 0.31.2
Model: mlx-community/Kokoro-82M-bf16 (also tested Unravler/Kokoro-82M-4bit-MLX)
Wrapper: kokoro-tts-mlx 0.1.0 (github.com/flight505/kokoro_tts_mlx)
Python 3.12
Symptoms:

All audio output is NaN + zeros β€” no actual audio content
np.isnan() shows ~20-25% of samples are NaN, rest are 0.0
Affects ALL language codes (a, b, e, etc.) and ALL voices
The same model (hexgrad/Kokoro-82M) via PyTorch kokoro.KPipeline works perfectly (zero NaN, real audio)
Root cause β€” two bugs:

NaN output via kokoro-tts-mlx wrapper: KokoroTTS.generate() returns arrays where np.isnan() is true for ~20% of samples and the rest are silent zeros
Shape broadcast crash via native mlx-audio / generate_audio(): intermittent ValueError: [broadcast_shapes] Shapes (1,N,1) and (1,N+300,9) cannot be broadcast in istftnet.py:620 β€” the F0 sine generator produces misaligned tensor shapes
Key clue: The shape error always shows a delta of exactly 300 samples between the two dimensions (72000 vs 72300, 1200000 vs 1200300), suggesting a frame-size rounding bug in the MLX port of the Kokoro decoder (istftnet.py).

Workaround: PyTorch kokoro.KPipeline(lang_code='e', repo_id='hexgrad/Kokoro-82M') works perfectly on CPU at ~11Γ— realtime on M3 Max.

Anybody else run into this?

Sign up or log in to comment