Speech recognition, synthesis and voice cloning in a browser tab
Which speech models actually run in a browser tab, and how long does each one keep you waiting? The recognition, synthesis and cloning stages, in pipeline order, with a Whisper transcription snippet you can copy as is.
Audio is awkward to ship over the network and users notice latency immediately, so we try to keep it on the device. The catalogue splits into audio (asr / tts / denoising / source-separation / audio-classification) and generative-audio (text-to-music / voice-cloning). Denoising, separation and VAD have their own posts; the three stages wired up here are recognition, synthesis and cloning.
The 30-second Whisper window
Whisper is an encoder plus a decoder: log-mel spectrograms go in, tokens come out one at a time. Picking a variant is mostly picking how long you are willing to wait. Whistle is about 16.1 MiB on WebAssembly and loads fastest; Whisper Base is about 73.3 MiB and much steadier across languages; Whisper Small is about 191 MiB, best quality and the longest first load.
The native implementation works in 30-second windows, so longer recordings need your own splitting and some care at the boundaries. Setting return_timestamps to word level saves a lot of that: cuts can land between sentences, no word gets sliced in half, and subtitle alignment becomes easy.
Put a VAD in front and send only the speech ranges through. Saving decode time is the smaller win. The awkward part is that Whisper can produce perfectly confident text over pure noise, and a VAD blocks most of that at the source.
TTS is really two models
An acoustic model turns text into a spectrogram or discrete acoustic tokens, then a vocoder rebuilds the waveform. Both stages have to run. Kokoro 82M at about 121 MiB is a reasonable quality-for-size pick. Piper ships one small package per language, so each new language is another download. Silero TTS synthesises in real time on CPU. Bark can laugh and sigh, at a clear cost in size and latency.
Running locally is mostly about losing one network round trip, not about cost: press and it starts talking, which feels very different. The trade-offs are real too. You get a fixed set of voices, coarser prosody control than cloud systems, and long text has to be split into sentences by your own code.
Cloning: one reference clip is enough
A reference clip is encoded into a speaker embedding, then fed to the synthesiser together with the text, which is how timbre and content get separated. OpenVoice v2 leans towards zero-shot timbre conversion, same words in a different voice; Coqui XTTS v2 clones across languages. Neither is a single file. Encoder, synthesiser and vocoder load separately in the browser, which is why these demos are slow to open the first time.
The part that needs thought here is consent, not inference. Cloning someone’s voice requires their explicit agreement, and running it on-device makes it far too easy: any short recording will do. A product needs a consent flow and stated limits, not one more filter in a menu.
| Stage | Representative model | Measured size | Character |
|---|---|---|---|
| ASR | Whistle | ~16.1 MiB | Light, WASM-friendly, fastest load |
| ASR | Whisper Base | ~73.3 MiB | Multilingual, clearly better quality |
| ASR | Whisper Small | ~191 MiB | Best quality, slowest load |
| TTS | Kokoro 82M | ~121 MiB | The quality/size balance point |
| TTS | Piper | Packaged per language | Multilingual, light, CPU-friendly |
| Cloning | OpenVoice v2 | Multi-component | Zero-shot timbre conversion |
| Cloning | Coqui XTTS v2 | Multi-component | Cross-lingual cloning |
A transcription snippet you can copy
const asr = await pipeline('automatic-speech-recognition', 'Xenova/whisper-base', {
dtype: 'q8',
});
const out = await asr(audioUrl, {
return_timestamps: 'word',
chunk_length_s: 30,
stride_length_s: 5,
});
// out.text / out.chunks[i].timestampPutting it together
VAD cuts ranges, ASR produces text, a local LLM rewrites or summarises it, TTS reads it back. All four steps fit in one tab, which is roughly how meeting notes, voice memos and offline translation are built. The VAD, ASR and TTS demos on this site can be clicked through in that order; the voice cloning page keeps the words and swaps the voice.