Piper WASM adapter with voice download and OPFS cache #10

Closed
opened 2026-10-25 14:58:14 +00:00 by dsh · 2 comments
Owner

Goal

The first real voice: Piper running entirely in the browser, with an honest download story.

Scope

  • Engine module for @mintplex-labs/piper-tts-web@1.0.5 (MIT) + pinned onnxruntime-web@1.18.x (the 1.0.5 build imports onnxruntime-web/wasm; never float it). Record the provenance caveat: the 1.0.5 tarball contains code absent from the public GitHub repo.
  • M1 default voice: en_US-lessac-medium (official catalog, single speaker, 63.1 MB). Additional M1 voices: en_US-amy-medium, en_US-hfc_female-medium, and one non-English voice (de_DE-thorsten-medium) to prove the multilingual option.
  • Voice catalog explicitly excludes, for now: en_US-glados-medium (not in the official catalog; only unofficial fan/ncnn clones, no licence) and en_US-libritts_r-medium (2,306 speakers — needs a speaker picker). Both are handled by #23 and the M2 catalog decision.
  • prepare(voiceId, onProgress): explicit user action only; progress; detect stored() so a cached voice loads without re-download; remove() for purge; OPFS availability check with a clear fallback message.
  • synthesize in the Worker: text → WAV Blob → decodeAudioData in the main thread (or PCM transfer); honour rate via the queue.
  • Self-test: synth a known sentence and assert non-silent audio (peak > 0) before claiming ready.
  • Fallback: feature-detect AudioContext/OPFS; if unavailable, mark engine unavailable with a reason.
  • Document the swap path to piper-tts-web@1.1.2 or a direct ONNX+phonemizer build if the fork dies.

Acceptance

  • Cold load downloads ~92 MB (operator-approved budget; up to ~100 MB is fine) with visible progress and no main-thread freeze; reload uses OPFS (0 bytes re-downloaded).
  • A 10-sentence reply plays end-to-end through the queue; stop works mid-synthesis.
  • Chrome + Firefox on Arch Linux desktop tested; results recorded in the checklist.

Notes

  • Depends on #7, #8, #9. Part of M1; the flagship path. Sizes/risks: docs/research/tts-engines.md §3.
  • Operator decisions 2026-10-25 (#22): download budget accepted; English default with multilingual as an option; GLaDOS deferred to the M2 voice-catalog decision.
## Goal The first real voice: Piper running entirely in the browser, with an honest download story. ## Scope - [ ] Engine module for `@mintplex-labs/piper-tts-web@1.0.5` (MIT) + **pinned** `onnxruntime-web@1.18.x` (the 1.0.5 build imports `onnxruntime-web/wasm`; never float it). Record the provenance caveat: the 1.0.5 tarball contains code absent from the public GitHub repo. - [ ] **M1 default voice: `en_US-lessac-medium`** (official catalog, single speaker, 63.1 MB). Additional M1 voices: `en_US-amy-medium`, `en_US-hfc_female-medium`, and one non-English voice (`de_DE-thorsten-medium`) to prove the multilingual option. - [ ] Voice catalog explicitly excludes, for now: `en_US-glados-medium` (not in the official catalog; only unofficial fan/ncnn clones, no licence) and `en_US-libritts_r-medium` (2,306 speakers — needs a speaker picker). Both are handled by #23 and the M2 catalog decision. - [ ] `prepare(voiceId, onProgress)`: explicit user action only; progress; detect `stored()` so a cached voice loads without re-download; `remove()` for purge; OPFS availability check with a clear fallback message. - [ ] `synthesize` in the Worker: text → WAV Blob → `decodeAudioData` in the main thread (or PCM transfer); honour rate via the queue. - [ ] Self-test: synth a known sentence and assert non-silent audio (peak > 0) before claiming ready. - [ ] Fallback: feature-detect `AudioContext`/OPFS; if unavailable, mark engine unavailable with a reason. - [ ] Document the swap path to `piper-tts-web@1.1.2` or a direct ONNX+phonemizer build if the fork dies. ## Acceptance - Cold load downloads ~92 MB (operator-approved budget; up to ~100 MB is fine) with visible progress and no main-thread freeze; reload uses OPFS (0 bytes re-downloaded). - A 10-sentence reply plays end-to-end through the queue; stop works mid-synthesis. - Chrome + Firefox on Arch Linux desktop tested; results recorded in the checklist. ## Notes - Depends on #7, #8, #9. Part of M1; the flagship path. Sizes/risks: `docs/research/tts-engines.md` §3. - Operator decisions 2026-10-25 (#22): download budget accepted; English default with multilingual as an option; GLaDOS deferred to the M2 voice-catalog decision.
Author
Owner

Code landed in 9193f7c (worker f586bbc). Piper + ORT 1.18 are bundled into the embedded worker; createPiperEngine maps the curated catalogue (en_US-lessac-medium default, amy, hfc_female, de_DE-thorsten-medium) onto the worker protocol, and createSpeechPipeline chunks → synthesizes → decodes → enqueues into the Web Audio queue. Settings has an explicit Enable audio & preview button (downloads only on click) and the auto-read switch.

Tests: 110 total, CI run #9 green. Pending the browser check in #11 — the sandbox cannot open the GUI or click the button.

**Code landed** in `9193f7c` (worker `f586bbc`). Piper + ORT 1.18 are bundled into the embedded worker; `createPiperEngine` maps the curated catalogue (`en_US-lessac-medium` default, amy, hfc_female, `de_DE-thorsten-medium`) onto the worker protocol, and `createSpeechPipeline` chunks → synthesizes → decodes → enqueues into the Web Audio queue. Settings has an explicit **Enable audio & preview** button (downloads only on click) and the auto-read switch. Tests: 110 total, CI run #9 green. **Pending the browser check in #11** — the sandbox cannot open the GUI or click the button.
Author
Owner

Delivered: Piper worker, OPFS download, PCM decoding and the speech pipeline are shipping; fresh-download race handled in #31.

Delivered: Piper worker, OPFS download, PCM decoding and the speech pipeline are shipping; fresh-download race handled in #31.
dsh closed this issue 2026-11-06 04:36:04 +00:00
Sign in to join this conversation.
No description provided.