localspeech
localspeech started with one question: can a browser speak naturally, with no server and no API, on the machines people actually have? It grew into three published npm packages and a live demo. The headline is text-to-speech that can read an AI assistant's reply aloud while it's still streaming in; speech-to-text for live dictation and transcription followed.
- My role
- Solo project: research, engineering, packaging, and the demo app
- Topics
- TypeScript · ONNX Runtime Web · WebGPU · React · Speech AI · npm
The Packages
@localspeech/text-to-speech
npm · MIT license
Streaming text-to-speech with Kokoro 82M on WebGPU or WebAssembly. Speak finished text or an LLM reply as it streams in, synthesize audio files, and use the React hooks or the assistant-ui read-aloud adapters.
View on npm (opens in a new tab)@localspeech/speech-to-text
npm · MIT license
Live speech-to-text with NVIDIA's Parakeet TDT v3: dictation with live text, file transcription, and microphone plus call-audio sessions, with React hooks and an assistant-ui dictation adapter.
View on npm (opens in a new tab)@localspeech/core
npm · MIT license
The shared plumbing: model download and caching, environment detection, and command-line tools that fetch the pinned model files so your own site can serve them.
View on npm (opens in a new tab)
The Idea
Cloud speech APIs are easy to use, but they come with per-minute costs, API keys, and audio leaving the user's device. I wanted to know whether modern speech models could run well enough inside an ordinary browser, including on machines without a dedicated GPU, to replace them. The first version was a benchmark that measured exactly that.
What I Built
The text-to-speech package reads finished text, or speaks an LLM's reply while it's still streaming, a sentence at a time, with playback that stays ahead without stalling. It reads Markdown the way a person would: no asterisks, links as their text, and code announced rather than spelled out. The speech-to-text package handles live dictation and transcription in 25 European languages, from a microphone, a recording, or shared call audio. Both ship React hooks and drop-in adapters for assistant-ui chat interfaces.
The live demo uses the packages exactly as any other site would, and adds meeting transcription with speaker labels and exports, a read-aloud reader with sentence highlighting, and a benchmark that times every stage.
How It Works
Text goes through a Markdown-aware sentence planner into Kokoro 82M for speech; audio goes through voice-activity segmentation into NVIDIA's Parakeet TDT 0.6B v3 for transcription. Both models run in Web Workers on ONNX Runtime Web, using WebGPU when it's available and multithreaded WebAssembly otherwise. Model files are pinned to exact versions and cached in the browser after the first download.
Challenges & Decisions
Two things mattered most. The first was performance on ordinary hardware: on WebAssembly with 8 CPU threads, speech starts in about 1.3 seconds and generates at roughly three times real time, and WebGPU is used automatically when available.
The second was trust. "Local" should be provable, not just promised. Production builds ship a strict Content-Security-Policy that blocks every connection except the app itself and its model host, and the model files can be self-hosted for locked-down networks, so audio and text can't leave the device even through a bug. Streaming speech is also tested to be exactly what reading the finished text would produce.
What I Learned
Starting with a benchmark instead of a feature list gave clear answers about download size, start-up time, and playback continuity, and those numbers shaped the libraries that followed.
Current State
Still in active development. All three packages are published on npm under the MIT license, and the demo is live (Chrome or Edge recommended). The voice is English, with US and UK voices; transcription covers 25 European languages.
