Skip to content

Update speech recognition result timestamps explainer - #206

Merged
alan33d merged 11 commits into
WebAudio:alan33d-patch-1from
alan33d:alan33d-patch-1
Sep 3, 2026
Merged

Update speech recognition result timestamps explainer#206
alan33d merged 11 commits into
WebAudio:alan33d-patch-1from
alan33d:alan33d-patch-1

Conversation

@alan33d

@alan33d alan33d commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Remove latency tracking uses cases since SpeechRecognitionEvent timestamps can be used for that purpose. Instead focus on developer need for timeline association use cases in the updated explainer and alternatives considered.

WebAudio#203)

* Update audioStartTime and audioEndTime to be relative to start of audio stream

We want to switch to  stream-Relative (0-based) impl. since:
- In Web Audio and Media APIs (HTMLMediaElement.currentTime, AudioContext.currentTime, WebCodecs VideoFrame.timestamp), media timelines are always 0-based offsets relative to stream start, not the time origin.
- Immune to inter-process jitter since SODA and audio capture run in a separate utility/browser process. Translating stream offsets to the renderer's timeOrigin relies on estimating when IPC AudioStarted() arrived, which introduces IPC latency jitter. Stream-relative offsets are not prune to this and aligns with the raw audio frames.
- If SpeechRecognition is used with a pre-recorded MediaStreamTrack, a 0-based stream offset reflects the actual position in the audio track regardless of when the webpage was loaded.
- Being relative to performance.timeOrigin doesn't make sense in general for the Web Speech API because it assumes that the audio source is live. Since a SpeechRecognizer can also be created for a prerecorded media stream I think the timestamps on the speech recognition events should be relative to the position in that media stream.

See https://crbug.com/542330168 for more details.

* Update speech recognition explainer with timestamp conversion

Added a section on converting stream timestamps to document time origin and provided a live translation latency example with code.

* Minor update to close live transcription latency measurement example

Added separator before security section and closed example section for live transcription measurements.

* respond to review comment
…atives and refactor Timestamps to use Seconds (WebAudio#205)

* Expand on limitations of existing speech recognition events

Added detailed explanations regarding the limitations of existing API surfaces for tracking latency in speech recognition in the Alternatives Considered section, including issues with `speechstart` and `speechend` events and the implications of modifying `event.timeStamp`.

* Refactor speech recognition timestamps to use seconds

Updated the speech recognition result timestamps to use seconds instead of milliseconds, improving consistency with other Web APIs. Added detailed explanations for the choice of time representation, proposed behavior, and security considerations. Based off of comments from WebAudio#205
Merge changes from original repo
Removed sections discussing the limitations of `speechend` and the overloading of `SpeechRecognitionEvent.timeStamp`. Added a note about attaching `speechStartTime` and `speechEndTime` to `SpeechRecognitionResult` for better timeline association.
Updated the discussion on using existing event timestamps for speech recognition results, highlighting their limitations and the benefits of attaching timestamps directly to SpeechRecognitionResult.
Removed redundant points about interim results and trailing silence skew from the explanation of existing VAD and result event timestamps.
Updated the explanation of timestamp limitations in the Web Speech API and provided a clearer example of synchronizing captions with live video frames, including a playout buffer delay for ASR processing.
Added a link to an interactive demo for synchronizing captions with live WebRTC video frames.
@alan33d alan33d self-assigned this Sep 1, 2026

@alan33d alan33d left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be merged back to the main Webspeech repo

@alan33d
alan33d marked this pull request as ready for review September 1, 2026 05:02
@alan33d alan33d changed the title Alan33d patch 1 Update speech recognition result timestamps explainer to focus on timeline association use cases Sep 1, 2026
@alan33d alan33d changed the title Update speech recognition result timestamps explainer to focus on timeline association use cases Update speech recognition result timestamps explainer Sep 1, 2026
Updated example to clarify live video conferencing with accurate caption synchronization and added details on handling captions during live calls and post-meeting replay.
@alan33d
alan33d merged commit 13cf286 into WebAudio:alan33d-patch-1 Sep 3, 2026
1 check passed
alan33d added a commit that referenced this pull request Sep 4, 2026
* Update audioStartTime and audioEndTime to be relative to start of audio stream

We want to switch to  stream-Relative (0-based) impl. since:
- In Web Audio and Media APIs (HTMLMediaElement.currentTime, AudioContext.currentTime, WebCodecs VideoFrame.timestamp), media timelines are always 0-based offsets relative to stream start, not the time origin.
- Immune to inter-process jitter since SODA and audio capture run in a separate utility/browser process. Translating stream offsets to the renderer's timeOrigin relies on estimating when IPC AudioStarted() arrived, which introduces IPC latency jitter. Stream-relative offsets are not prune to this and aligns with the raw audio frames.
- If SpeechRecognition is used with a pre-recorded MediaStreamTrack, a 0-based stream offset reflects the actual position in the audio track regardless of when the webpage was loaded.
- Being relative to performance.timeOrigin doesn't make sense in general for the Web Speech API because it assumes that the audio source is live. Since a SpeechRecognizer can also be created for a prerecorded media stream I think the timestamps on the speech recognition events should be relative to the position in that media stream.

See https://crbug.com/542330168 for more details.

* Update speech recognition explainer with timestamp conversion

Added a section on converting stream timestamps to document time origin and provided a live translation latency example with code.

* Minor update to close live transcription latency measurement example

Added separator before security section and closed example section for live transcription measurements.

* respond to review comment

* Update speech recognition result timestamps explainer (#206)

Revised explainer to focus on timeline association use cases with the new SpeechRecognitionResult timestamps.  Provided 2 examples and interactive demo.

* change click-to-seek granularity from word to phrase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants