v153 · in developer trial (behind a flag)
SpeechRecognitionResult Timestamps (WebSpeech API)
The Web Speech API is a black box about when in the audio a phrase was spoken. The spec (web-speech-api PR #192, now in the editor's draft) adds two attributes — speechStartTime and speechEndTime, seconds on the session audio timeline — to SpeechRecognitionResult, letting you line transcripts up with a media timeline and measure on-device recognition latency. These demos call the real Web Speech API and look for the new fields, degrading honestly when the attributes are absent. Chrome 153–155 shipped an earlier draft under different names, audioStartTime / audioEndTime; the demos report those too, labelled as the draft.
concepts
-
On-device latency monitor
Compute processing lag as
event.timeStamp − (audiostart.timeStamp + result.speechEndTime × 1000)and feed that signal into an application-defined fallback policy. -
Caption timeline mapper
Place each recognised phrase on an audio timeline using
speechStartTimeandspeechEndTime, the way a captioning or transcript-scrubbing tool would. -
Result-object capability probe
Detect the timestamps correctly:
SpeechRecognitionResulthas no constructor to probe, so you must inspect a live result instance. Covers the spec names, the Chrome 153–155 draft names, and timer coarsening.
why timestamps matter
Two problems drove the proposal. Timeline association: the API currently gives no direct way to map a result back to its source-audio segment, complicating caption timelines, transcript scrubbing, and highlight-as-you-play. Latency tracking and failover: as recognition moves on-device for privacy, performance now depends on the visitor's hardware. Exposing speechEndTime lets an app compare it against the result event's timeStamp to detect processing lag and invoke an application-defined fallback if one is configured and appropriate. The timestamps do not themselves provide, authorize, or make a cloud transition seamless.
the shape
partial interface SpeechRecognitionResult {
readonly attribute double speechStartTime; // seconds on the session audio timeline
readonly attribute double speechEndTime; // seconds on the session audio timeline
};
The session audio timeline starts at 0.0 with the first audio frame the recognizer consumes (the audiostart event) and advances with the audio consumed, so the values are offsets, not clock readings, and drop straight into a VTTCue or media.currentTime. Precision is implementation-defined; the explainer says implementations such as Chromium coarsen them (for example to 2 ms) to reduce fingerprinting.
The names changed during the trial. Chrome 153–155 implement an earlier draft: DOMHighResTimeStamp? audioStartTime / audioEndTime — nullable milliseconds on the page's time origin. Chrome 156 renamed them to the spec's speechStartTime / speechEndTime (verified in each branch's speech_recognition_result.idl). Code written for one does not find the other.
enabling it
Both names are gated by the Blink runtime flag WebSpeechTimestamps. In Chrome 153–159 its status is experimental: enable chrome://flags/#enable-experimental-web-platform-features, or launch Chrome with --enable-blink-features=WebSpeechTimestamps. Chromium main (after the M159 branch) marks it stable on Windows, macOS and Linux, so it is on by default there; Android and ChromeOS still need the flag. A timing-capable recognition backend is also required, and an on-device backend may require a downloaded speech model. When the attributes are absent, the demos say so plainly and offer a clearly-labelled sample walkthrough instead of faking values.