DEV Community

Fei Y
Fei Y

Posted on Fully Autonomous

How we built no-upload speech recognition in the browser

We built two websites that turn a recording into an editable transcript in the browser. mojiokoshi.tools is for Japanese audio and video. Red Panda Transcribe covers other languages, including English, Spanish, French, and German. Both run the speech recognizer with WebAssembly, so the recording and the generated transcript stay on your device.

We got the idea from running a video encoder inside a browser tab for RedPanda Compress. The same approach seemed useful for a client call, an interview, or a voice memo you’d rather keep to yourself. You should be able to open the file, listen as you correct the text, and leave with a transcript or a subtitle file. The hard part was getting a speech model small enough to download and accurate enough to leave you with a draft worth editing.

Getting a speech model into the browser

The app opens the file locally, extracts the audio track if it’s a video, and decodes it into 16 kHz mono samples. A Web Worker feeds those samples to a recognizer built with sherpa-onnx and ONNX Runtime. The worker sends recognized text and timing back to the page, where you can edit it and export TXT, SRT, or VTT.

The build has two jobs. Emscripten compiles the native recognition runtime to a .wasm binary. The model stays in ONNX format. We package the model files and their token list into a .data file, and the generated JavaScript loader makes those files available to the runtime through its virtual filesystem. For Japanese, the package contains a quantized SenseVoiceSmall model. Most international models are streaming Kroko transducers, packaged by language with an encoder, a decoder, and a joiner.

One practical surprise was that swapping out the language package also meant swapping its loader. The generated JavaScript contains byte offsets into the .data file, so an English package can download successfully and still fail at model initialization if it gets the Italian loader. We ship each pair together and check at build time that the loader’s final offset matches the package size. sherpa-onnx WASM build guide · Emscripten file packaging

Choosing how much model to download

Every extra megabyte is part of the first-use wait. Quantizing the model reduces the size of its weights. Brotli reduces the bytes transferred over the network. Once the model is downloaded, the app can keep it in the browser’s Origin Private File System for later visits. We still had to decide how much accuracy was worth a larger initial download.

We tested the Japanese candidates on the same 150 clips from the public FLEURS test set. We normalized the reference and recognized text, ignored punctuation and spaces, and counted insertions, deletions, and substitutions per reference character. Here are the numbers that mattered to the choice. The sizes are approximate compressed model payloads, with the WASM runtime counted separately.

Japanese candidate Compressed model Short-clip character error rate
Zipformer int4 72 MB 10.7%
Zipformer int8 125 MB 10.0%
SenseVoiceSmall int8 150 MB 8.1%

The larger model made more sense once we stitched clips into multi-minute recordings. The int8 Zipformer’s error rate rose to about 18%, while SenseVoice stayed near 9% in that test. For about 25 MB more than the int8 Zipformer on the first download, the Japanese site got a noticeably better starting transcript on the longer material we tested. That was the comparison that changed our choice.

On the international site, we compare word error rate against Whisper large-v3 on the same filtered clips for each benchmarked language. FLEURS gives us a repeatable comparison on read speech. A real meeting also brings noise, overlap, and names that the model may get wrong. Japanese evaluation · International evaluation

Getting text on screen while the file is still processing

On a long recording, users should be able to start reviewing the first part while the rest is still running. Where the format supports it, we decode the file in pieces and keep the queue bounded so decoded audio doesn’t pile up in memory. When workers finish out of order, the page waits for the earlier result before adding the next section to the transcript.

The two sites get there in different ways. The Japanese site uses an offline recognizer. We find quiet points around short chunks, recognize those chunks independently, and display the results in order. The international site uses streaming recognizers that carry state as they receive successive blocks of audio. The worker collects a segment each time the recognizer detects the end of an utterance and flushes any remaining text when it runs out of input. For longer files, separate spans can go to different workers. The page adds completed spans as they become available in order. In both cases, the input is a recording you open from your device.

There was one revealing bug in the streaming path. With two seconds of audio between endpoint checks, we sometimes found a pause after the next sentence had already started. Resetting the recognizer could drop its first words. Checking every 200 milliseconds reduced how far we could run past the pause. That’s a failure a short, standalone benchmark sentence can easily miss.

Try it with a recording

Use mojiokoshi.tools for Japanese, or choose your audio language on Red Panda Transcribe. Both are free, require no account, and have a built-in sample. If you try a longer recording, we’d be curious to hear how quickly the first text appears and which parts of the transcript you end up correcting.

Drafted with AI using RedPanda’s implementation and evaluation notes.

Top comments (0)