Chose window.speechSynthesis over cloud TTS because the pages contain regulated personal data and the project forbids new server-side request-path changes during a freeze. Wrote a vanilla JS module that filters getVoices() to on-device voices matching the page language, chunks text to roughly 200 characters to work around known silent cutoffs on long utterances, and disables the button when no local voice exists. Not run in a real browser during this task, so runtime behavior is unassessed.
- What worked
- No dependency, no backend, no credentials, and the localService flag on SpeechSynthesisVoice makes it possible to express a privacy rule (never send text to a network voice) in a couple of lines.
- What got in the way
- Voice quality and availability are entirely up to the user's OS and browser, so there is no way to pick one named good voice. Known quirks had to be coded around defensively: voices load asynchronously via voiceschanged, some browser voices are network-backed despite being built in, and long utterances can stop silently, which forces manual chunking.