fix(diarization): stop overlap merge from shrinking speaker turns - #835
Merged
altic-dev merged 1 commit intoAug 11, 2026
Merged
Conversation
mergeAdjacentTurns took the incoming turn's endSeconds unconditionally when welding same-speaker turns. Diarization segments can overlap at boundaries (overlapping speech, VAD imprecision), so a later turn that ends inside the accumulated turn overwrote the end with an earlier timestamp and dropped the trailing audio ([turn.end, current.end]) from the transcribed slice. Use max(current.endSeconds, turn.endSeconds) so a merge never reduces the covered range. Adds overlap + touching regression tests.
Greptile SummaryThis PR prevents overlapping same-speaker diarization segments from shrinking an accumulated speaker turn and dropping trailing audio.
|
Owner
|
@YuriNachos you're awesome! |
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.
Description
SpeakerDiarizationService.mergeAdjacentTurnswelded consecutive same-speaker turns by taking the incoming turn'sendSecondsunconditionally. Diarization segments can overlap at boundaries (overlapping speech, VAD imprecision), so a later same-speaker turn that ends inside the accumulated turn overwrote the end with an earlier timestamp and silently dropped the trailing audio range[turn.end, current.end]from the transcribed slice. The fix takesmax(current.endSeconds, turn.endSeconds), so a merge can never reduce the covered time range.Type of Change
Related Issue or Discussion
Hardens the speaker-labeled file-transcription path landed in #378 (originally requested in #219). No standalone issue exists for the overlap case, so linking the feature it belongs to.
Testing
swiftlint --strict --config .swiftlint.yml Sources→ 0 violations on the edited filesswiftformat --config .swiftformat Sources(not a CI check; skipped to avoid unrelated formatting churn)xcodebuild test -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS,arch=arm64' -only-testing:FluidDictationIntegrationTests/SpeakerTurnMergingTests→ 10 tests, 0 failures. The two new cases (testOverlappingSameSpeakerTurnDoesNotShrinkMergedRange,testTouchingSameSpeakerTurnExtendsToEnd) fail on the previousendSeconds: turn.endSecondsand pass withmax(...).Screenshots / Video
Notes
Pure logic change to a
static, already unit-tested merge helper — no SettingsStore, UI, or model loading involved. Behavior for the normal non-overlapping case is unchanged (a later turn's end is>=the accumulated end there, somaxcollapses to the previous value).