Live captions from SpeechRecognition, with the Translator API for a second language

Speech is turned into a caption element that the canvas draws over the video, with a translation under the frame. Press Play. The page starts with a recorded transcript of the clip, which works in every browser. Then choose speech recognition on the clip's sound or on the microphone, and a second language.

recorded transcript 0:00.0

The video hasn't been played yet.

No speech recognition events yet.

Show the code recognition, translation, a caption element, a recording
  1. The markup. The video, a control bar and the caption element are children of the canvas.
  2. Recognise speech. continuous and interimResults give words as they are heard. start(track) recognises a sound track in place of the microphone.
  3. The clip's own sound. video.captureStream() has an audio track for the element's sound.
  4. Words into elements. One <span> per word. Only the words that changed are replaced.
  5. Translate. Translator.create() for the language pair, then translate() for each result. Interim results are translated one at a time and overtaken ones are dropped.
  6. Draw. The caption element is drawn twice with a clip: its first line over the bottom of the frame, its second line under the control bar.
  7. WebVTT out. Each final result has a start and an end time, which is all a cue needs.
  8. The recorded transcript. The cue file of the clip, fed in word by word at each word's time stamp.
  9. The CSS.

How it works

Live checks

Each check builds its own small video and canvas in a corner of the window. The player above isn't touched. No check opens the microphone or starts a download.

ResultExperimentDetail

Findings

From Chromium 157 headless, 2026-11-21. The rows above and the two status blocks under the player say what your browser does.