fix(soniox): widen final span to all timed tokens, never regress end_time - #6976
Open
rkfshakti wants to merge 1 commit into
Open
fix(soniox): widen final span to all timed tokens, never regress end_time#6976rkfshakti wants to merge 1 commit into
rkfshakti wants to merge 1 commit into
Conversation
…time The endpoint path builds SpeechData from the final accumulator alone. update() took start_time from the first token that carried start_ms and overwrote end_time from every token that carried end_ms. When the leading tokens of an utterance arrive without timing keys and only a trailing token has them, the emitted span collapsed onto that trailing token (e.g. two words in 180ms); a trailing token whose end_ms regressed pulled the end backwards by the same mechanism. start_time is now the earliest start_ms seen and end_time the latest end_ms seen, matching the min/max guards merged_speech_data() already applies on the interim path. Regression tests cover both mechanisms (issue livekit#6885).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6885
Problem
A
FINAL_TRANSCRIPTemitted at a natural endpoint can carry astart_time/end_timespan far shorter than the speech its owntextrepresents — e.g."He's trying."with a 0.18s span.Root cause
_TokenAccumulator.update()tookstart_timefrom the first token that carriedstart_msand overwroteend_timefrom every token that carriedend_ms:Two failure mechanisms (both confirmed against the fake-WS harness):
start_ms/end_ms, only a trailing token has them → the span collapses onto that trailing token.end_msis smaller than an earlier one pulls the end backwards.merged_speech_data()(the interim path) already guards both withmin(...)/max(...); the final path did not.Fix
start_time= earlieststart_msseen (not just the first)end_time= latestend_msseen (never regresses)Regression tests cover both mechanisms. Verified: 2 of 3 new tests fail on the old code, all 31 soniox tests pass with the fix.