v153 · speechrecognitionresult timestamps

On-device latency monitor

On-device speech recognition trades server cost and privacy for a dependency on the visitor's hardware. speechEndTime tells you when a phrase ended in the audio, in seconds from the moment recognition started consuming audio; anchoring that to the audiostart event's timeStamp and comparing it with the result event's timeStamp (when the transcript arrived) gives you the processing lag. Crossing an application-defined threshold can inform a configured fallback decision; the timing signal does not itself provide or authorize a cloud backend.

Enable it: the attributes sit behind the Blink runtime flag WebSpeechTimestamps. In Chrome 153–159 it is experimental: turn on chrome://flags/#enable-experimental-web-platform-features, or launch Chrome with --enable-blink-features=WebSpeechTimestamps. Chromium main (after the M159 branch) enables it by default on Windows, macOS and Linux; Android and ChromeOS still need the flag. The spec names are speechStartTime / speechEndTime (Chrome 156+): seconds on the session audio timeline, not a clock reading, so this page anchors them to audiostart. Chrome 153–155 expose an earlier draft, audioStartTime / audioEndTime (nullable ms on the time origin); the page uses those only when the spec names are absent and labels the reading as draft. If neither yields a number it says so and will not invent a latency. Use the sample walkthrough to see the gauge move.

Live latency gauge

— ms processing lag

Idle. Start listening, or play the sample walkthrough.

(transcript will appear here)

code path

const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.continuous = true;
recognition.interimResults = true;

let audioOriginMs = 0;                               // session audio timeline t = 0
recognition.onaudiostart = (event) => { audioOriginMs = event.timeStamp; };

recognition.onresult = (event) => {
  const result = event.results[event.resultIndex];
  // speechEndTime: seconds since audiostart, on the session audio timeline.
  const endMs = audioOriginMs + result.speechEndTime * 1000;
  const lagMs = event.timeStamp - endMs;
  if (lagMs > failoverThresholdMs) switchToCloudBackend();
};
// The audio timeline counts consumed audio, not wall-clock time, so this is an
// estimate for live microphone input and meaningless for faster-than-real-time input.

see also