Skip to content

How AI Captioning Works in Your Browser: Whisper, WebGPU and WASM Explained Simply

From video file to timed captions without a server: audio decoding, the Whisper model, WebGPU vs WebAssembly, and why the first run downloads a model.

Try it now: AI Subtitle Generator — timed subtitles from speech in 20 languages, processed in your browser.

A modern browser can do what used to need a server: listen to a video's audio and write timed text. Here is the pipeline, in plain language.

Step 1: Read the video file

You pick an MP4, MOV or WebM file. The page checks the container by looking at the first bytes of the file (not just the extension), then reads only the audio it needs instead of loading the whole file into memory. Where the browser supports the WebCodecs API, audio is decoded as a stream; otherwise it falls back to the browser's older audio-decoding function.

The file never leaves your device in this step.

Step 2: Cut the audio into chunks

Speech models work on short windows of audio. GenKit Lab's pipeline processes it in chunks of up to about eight seconds and writes each chunk's text with timestamps, which is how caption lines get their start and end times.

Step 3: The speech model

The model is Whisper, an open speech-recognition model from OpenAI. Its paper describes training on 680,000 hours of multilingual, multitask supervision from internet audio, which is why a single model family handles many languages.

What the product runs, as of this writing (the code is the source of truth and can change):

  • Sinhala: a fine-tuned small Whisper model built for Sinhala.
  • Other languages: a multilingual Whisper model, with the larger "large-v3-turbo" model used where the graphics card supports the needed 16-bit shader feature, and a smaller model otherwise.

See Whisper model sizes for what the sizes mean.

Step 4: GPU or CPU

  • WebGPU is a browser API that lets web pages use your graphics card for general computation. MDN describes it as giving first-class support for GPU computation, and marks it as having limited availability, which is why a page must check for it before using it. It needs HTTPS.
  • WebAssembly (WASM) runs compiled code on your CPU. It works almost everywhere and is slower.

The tool uses WebGPU when your browser and GPU support what the larger model needs, and falls back to a smaller model on WASM otherwise. That is why the same video can take very different times on different computers. No speed figures are published, because none have been measured and published.

Step 5: Review and export

The text appears in the editor. You correct it, style it and export SRT, VTT or a burned-in MP4. The video rendering is also done in the browser (using WebCodecs).

Why the first run is slower

Models are large files. The first time you use a language, the browser downloads the model from the site's storage, and later runs can reuse what it saved. That download is the one big thing that comes from a server; your video does not go to one. For the full picture see what stays on your device.

Limits to be aware of

  • Browser support varies. Desktop Chrome and Edge are the best-tested.
  • Accuracy depends on audio, language and speaker; no accuracy percentage is published.
  • Speech in several languages in one video is a hard case.

Developers who want to build something similar can start with the developer walkthrough using transformers.js, which runs Whisper in the browser through ONNX Runtime. To see the pipeline from the user side, try the AI subtitle generator.

Sources

Last updated