Repository navigation
fix: cosy word identity dedupe - #2396
Conversation
|
[P2] Preserve distinct words when timestamps are sentence-relative The fallback key is request-wide but uses unadjusted timestamps. For an index-less response with sentence-relative timing, which this adapter explicitly supports, the same word at 0-200 ms in two sentences gets the same key, so the second occurrence is silently omitted even though its PCM origin is different. Timestamp revisions to an already emitted word can also produce a new key and replay it. Preserve sentence/position identity for index-less events, while still handling actual cross-sentence replays, and cover repeated words and revisions. [P2] Update the subtitle reference for cross-sentence replays The registered Cosy subtitle timing hook still counts emitted words separately for each sentence. In the new cross_sentence_quote fixture, sentence 6 ends with the same words as sentence 5: this change correctly suppresses them, but the hook records a second caption for sentence 6. The guarder compares caption counts and therefore rejects that valid output instead of providing usable independent alignment coverage for the case this PR fixes. Update the reference and add a hook regression using the recorded event ordering. [P2] Assert audio-end intervals on interrupted requests The extension-local suite checks the exact controlled-clock event interval for success and zero for no audio, but its partial-error and flush-after-audio tests assert only PCM duration, not request_event_interval_ms. Those terminal paths can therefore use the wrong start/end boundary without failing the required accounting tests. Add controlled-clock assertions for both paths, including exactly-once termination. |
|
[P2] Scope the timing-based word key so sentence-relative timestamps are not dropped When a word has no Fix direction: build the timing fallback from the aligned request-timeline start ( |
|
[P2] Preserve index-less words when sentence timestamps restart
[P2] Keep the independent subtitle reference consistent with cross-sentence replays The registered Cosy timing hook still counts words independently by sentence. In the new [P2] Associate TTFB hook observations with the originating request The required Cosy TTFB observer wraps each SDK callback but records audio against the reference’s current request rather than the callback’s request. After a flush, a late audio callback from the canceled request can arrive after the next request sends text; the hook records that old audio as the new request’s first audio before forwarding it to the canceled callback, which would discard it. This produces an incorrect independent TTFB reference. Bind the observer to the callback/request or provider task identity and test a late old callback after a new request begins, as well as pool reuse. [P2] Assert audio-end intervals for interrupted requests The extension-local suite asserts a controlled-clock event interval for success and zero for no audio, but the partial-error and flush-after-audio tests assert only emitted PCM duration. An incorrect |
|
[P1] Keep the timestamp fallback scoped to its sentence timeline When word entries have no [P3] Avoid republishing zero-duration words in the timestamp fallback On the no-index path, |
|
[P3] Keep all zero-duration words at a timestamp idempotent The fallback remembers only the last published word at the boundary. If an index-less cumulative event contains two different zero-duration entries at the same timestamp followed by another word, both zero-duration entries are published in the first batch; on the next identical event, the earlier one passes [P2] Update the independent subtitle reference for cross-sentence replays The registered Cosy timing hook counts words independently per sentence, but the new [P2] Bind the TTFB reference to the originating request The mandatory Cosy TTFB hook wraps each SDK callback but records audio against the reference current request, rather than the callback request. After a flush, a late audio callback from the cancelled request can arrive after the next request sends text; the observer then records that old audio as the new request first audio, even though the cancelled production callback discards it. Associate the observation with the callback or provider task and test a late old callback after the next request starts, including pool reuse. [P2] Assert the event interval on interrupted requests The local suite checks a controlled-clock |
|
No actionable TTS-specific findings. |
|
[P2] Test cancellation against an active replacement connection The local suite checks flush accounting and that a subsequent request can begin, but it does not hold the old task’s |
|
No actionable TTS-specific findings. |
|
Correction to my previous comment: there is one finding. [P2] Choose the sentence time offset from new words, not from replayed words that dedupe skips
Here is how it goes wrong. Take the shape in
This happens whenever the replayed prefix starts more than 200 ms before the new sentence origin, for example two or more replayed CJK characters. The unit test misses it because it never feeds PCM, so Fix direction: compute the offset from |
|
Retraction of my previous comment: the offset finding does not meet the "introduced by this PR" bar. On the base branch, the first No actionable TTS-specific findings. |
|
[P2] Restore the flush-during-finalization test The new test is inserted before the rest of [P2] Wait for old cleanup while the replacement is still active Releasing |
|
[P2] Move the new connection-reuse test out of the existing finalizing test body
Fix: put the new test after the end of the original finalizing test, and keep the original test body in one piece. No other actionable TTS-specific findings. The request-scoped |
|
[P2] Consume the first request terminal event before starting the next Removing the first |
|
No actionable TTS-specific findings. |
|
Correction to my previous comment: there is one finding. [P3] Restore the first request's This PR removes |
|
No actionable TTS-specific findings. Scope reviewed: |
|
[P2] Preserve overlapping index-less words across cumulative events The timestamp fallback treats the end of the last emitted word as a lower bound on the start of every later word. For an index-less cumulative stream with A at 0–200 ms and B at 180–400 ms, [P2] Hold the old cancellation itself until the replacement is active Blocking the fake server’s |
|
[P2] Preserve index-less words whose timestamps overlap The fallback treats a word as new only when its start is at or after the previous published end, but valid word timings can overlap and the parser does not require non-overlapping intervals. For an index-less cumulative event containing A at 0–200 ms and B at 150–300 ms, |
|
No actionable TTS-specific findings. Scope reviewed: |
Problem
Two production Cosy TTS sessions exposed duplicate subtitle output:
sentence.indexvalues. Bothsentence.index=5andsentence.index=6contained今道不行,吾等宁为义死,不为利生. Sentence index is therefore not a reliable identity for a new subtitle segment.Solution
Add provider-aware, request-scoped deduplication with safe fallbacks:
begin_index/end_indexare present, treat the provider word indexes as the request-level identity and publish only words beyond the already emitted boundary. This works across sentence indexes and prevents cross-sentence replays.(text, begin_ms, end_ms)identities. The boundary state is sentence-scoped and retains all identities at the current boundary, including multiple zero-duration words, so repeated cumulative events remain idempotent without unbounded per-request word storage.sentence-begin, including empty word lists, so delayed word metadata is aligned to the correct audio origin.tts_audio_endexactly once when the provider sends repeated cumulative or terminal events.Regression coverage
The Cosy extension version is bumped to
0.5.1.