Fix negative subtitle durations in adjust_for_pause (#253)#275
Merged
kaixxx merged 1 commit intokaixxx:mainfrom Feb 20, 2026
Merged
Fix negative subtitle durations in adjust_for_pause (#253)#275kaixxx merged 1 commit intokaixxx:mainfrom
kaixxx merged 1 commit intokaixxx:mainfrom
Conversation
The adjust_for_pause() function shifts segment start and end independently when they fall within a VAD-detected pause. For short segments that lie entirely inside a pause, this can push start past end, resulting in negative durations in WebVTT output. Save original boundaries before adjustment and revert if start >= end after processing.
Owner
|
Your new friend Claude produces nice problem reports. I use mostly Codex. The results are also quite good, but not as comprehensive as this. But I have never generated a full PR with it, so I might have to try that. |
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.
Summary
Fixes #253
The
adjust_for_pause()function adjusts segment boundaries when they fall within a VAD-detected pause. It shiftssegment.startforward (to the end of the pause) andsegment.endbackward (to the start of the pause) independently. For short segments that lie entirely inside a pause, this can pushstartpastend, resulting in negative durations in WebVTT subtitle output.Root cause
When a short segment (e.g. 5.0s–5.3s) falls entirely within a pause (e.g. 4.8s–5.8s), start moves to ~5.6s while end moves to ~5.0s →
start > end→ negative duration.Fix
Save the original segment boundaries before adjustment. After processing all pause chunks, check if
start >= end. If so, revert to the original values.This is a minimal, safe fix — it only changes behavior for the specific edge case that causes the bug.
Note
I was not able to test this fix with a long audio file that reproduces the issue. The fix is based on code analysis only. I would appreciate it if someone with a 7+ hour audio file could verify.
Test plan