While building Voice Notes, an offline browser voice studio on GitHub Pages (source), I hit a nasty audio bug on WebGPU.
Every spoken note came back as radio static.
1. WebGPU fp16 and q8 break Kokoro-82M output
My first worker setup loaded Kokoro-82M on WebGPU with dtype: "fp16" and fell back to WebGPU q8 when half-precision failed. Both settings ran without throwing an error, and both produced unintelligible noise on WebGPU.
The fix in tts-worker.js was simple once isolated:
- Use
dtype: "fp32"whenever WebGPU is active. - Fall back to WASM
q8when WebGPU is unavailable.
If your browser TTS pipeline suddenly outputs static after a quantization tweak, check the device and dtype pair before debugging audio buffers or sample rates.
2. Reading all 99 languages from the model config
Hardcoded language dropdowns go stale or miss locales that the underlying model already supports. Instead of shipping a static array, languages.js reads lang_to_id directly from Xenova/whisper-tiny's generation_config.json (99 languages):
- Map each ISO code to a readable label with
Intl.DisplayNames. - Derive the matching browser speech locale tag (such as
ml-IN) usingnew Intl.Locale(code).maximize(). - Cache the resolved map in
localStorageso repeat loads skip extra work.
3. Word-level click-to-seek and subtitle export
For playback follow-along, timeline.js aligns live captions onto Whisper chunk word timings with longest common subsequence (LCS) matching. Clicking any word seeks audio directly to word.start (seeking slightly earlier lands on the previous word boundary), and the aligned timings export cleanly to SRT and VTT files without a backend server.