You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes a bug in GET /api/v1/events/{event_slug}/rooms/{room_id}/booths/{language_code}/transcripts/export where WebVTT and SRT exports could emit zero-duration subtitle cues (00:00:00.000 --> 00:00:00.000 / 00:00:00,000 --> 00:00:00,000) whenever consecutive transcript segments have elapsed offsets that round to the same millisecond.
Root Cause
Previously, _to_vtt() and _to_srt() in portal/routers/api_v1.py computed start_sec and end_sec = min(start_sec + 5.0, next_start_sec) as floats and passed them independently to _format_playback_time(seconds, sep).
When two consecutive timestamps rounded to the same integer millisecond (for example, 0 µs and 100 µs, or cross-boundary offsets like 600 µs and 1400 µs that are 800 µs apart yet both round to 1 ms), both cue endpoints formatted identically.
Update _format_playback_time(total_ms: int, sep: str) to format integer milliseconds directly (checked all repo callers: only _to_vtt and _to_srt call _format_playback_time).
tests/test_api_v1_transcription.py:
Add test_export_subtitle_cues_keep_positive_duration_after_rounding covering both vtt and srt (0 µs & 100 µs).
Add test_export_subtitle_cues_same_rounded_ms_and_hour_rollover covering segments 800 µs apart (600 µs & 1400 µs) that round to the same 1 ms, ordering, and hour-boundary rollover (3599.9999 s -> 01:00:00.000).
Testing
Tested locally
Existing tests pass
Added/updated tests
Checks run on Windows 11 (Python 3.13.15):
ruff check .: passed (All checks passed!)
ruff format --check portal/routers/api_v1.py tests/test_api_v1_transcription.py: passed (2 files already formatted)
Genuine terminal/HTTP API before-and-after screencast recorded locally at voxbento-1466-before-after.mp4 (uploading via GitHub web UI / PR comment).
Checklist
My code follows the project's coding standards
I have tested my changes
I have updated documentation where necessary
My changes do not introduce new warnings or errors
Additional Notes
Minimum-duration overlap trade-off: When consecutive cues round to the same millisecond, only the earlier cue's end_ms is clamped to start_ms + 1, so cue i (00:00:00.000 --> 00:00:00.001) overlaps cue i + 1 (00:00:00.000 --> 00:00:05.000) by 1 ms. Both W3C WebVTT (end > start required; overlapping cue intervals allowed) and SRT permit overlapping cues, and avoiding adjustments to cue i + 1's start time prevents cascading timestamp drift on later subtitles relative to audio playback. All segments separated by >= 1 ms after rounding remain non-overlapping.
…unding
Compute integer millisecond cue boundaries once in _subtitle_timestamps() for both _to_vtt() and _to_srt(), ensuring every cue retains at least 1 ms duration (end_ms = max(start_ms + 1, round(end * 1000))) while preserving text, ordering, hour rollovers, and >= 1 ms non-overlapping intervals.
Closesfossasia#1466
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Format subtitle timestamps from integer milliseconds and share cue-boundary calculation across VTT and SRT, enforcing at least a 1 ms duration.
portal/routers/api_v1.py L1250-1264 (+3 small edits)
Tests
Cover positive cue durations when timestamps round to the same millisecond, including ordering and hour rollover.
tests/test_api_v1_transcription.py L488-531
Tips and commands
Interacting with Sourcery
Trigger a new review: Comment @sourcery-ai review on the pull request.
Continue discussions: Reply directly to Sourcery's review comments.
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with @sourcery-ai issue to create an issue from it.
Generate a pull request title: Write @sourcery-ai anywhere in the pull
request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
Generate a pull request summary: Write @sourcery-ai summary anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment @sourcery-ai summary on the pull request to
(re-)generate the summary at any time.
Generate reviewer's guide: Comment @sourcery-ai guide on the pull
request to (re-)generate the reviewer's guide at any time.
Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 60772efe-62ca-4144-aab5-9412a328b3e9
Commits
Reviewing files that changed from the base of the PR and between 08a0054 and 14ee086.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
VTT and SRT subtitle exports now calculate cue timestamps in integer milliseconds. Cue ends are kept at least one millisecond after cue starts. Tests cover close timestamps, cue ordering, and formatting at the hour boundary.
Changes: Subtitle Cue Timing
Layer / File(s)
Summary
Shared cue timing and export validation portal/routers/api_v1.py, tests/test_api_v1_transcription.py
A shared helper calculates cue timestamps and ensures each cue has a positive duration. VTT and SRT use the helper with their respective separators. Tests cover close timestamps and hour rollover.
VTT and SRT exports now produce cues with a positive duration when timestamps round to the same millisecond. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix (keeping positive subtitle cue duration after millisecond rounding) in the api_v1 router, which matches the PR objectives: enforcing end_ms = max(start_ms + 1, round(end * 1000…
Linked Issues check
[#1466] The linked issue requires every WebVTT and SRT cue to have end_ms >= start_ms + 1. It also requires keeping text, ordering, the existing <= 5 s timing for segments at least 1 ms apart, and cle…
Out of Scope Changes check
The PR changes two files: portal/routers/api_v1.py and tests/test_api_v1_transcription.py. Per the summary, the api_v1.py changes are limited to the subtitle timestamp path: the new _subtitle_timestam…
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the fix (keeping positive subtitle cue duration after millisecond rounding) in the api_v1 router, which matches the PR objectives: enforcing end_ms = max(start_ms + 1, round(end * 1000)) for WebVTT and SRT exports. It also names the issue number #1466, which is consistent with the linked issue. The title is 83 characters, slightly long, but it is specific and accurate.
Full details: Linked Issues check
Explanation
[#1466] The linked issue requires every WebVTT and SRT cue to have end_ms >= start_ms + 1. It also requires keeping text, ordering, the existing <= 5 s timing for segments at least 1 ms apart, and clean hour rollovers. It also requires the earlier cue's end to move by 1 ms, while the next cue keeps its own start.
The whole-PR summary and PR description state these changes in portal/routers/api_v1.py:
A shared _subtitle_timestamps() helper serves _to_vtt() and _to_srt().
Cue boundaries are rounded to integer milliseconds once: start_ms = round(start * 1000), and end_ms = max(start_ms + 1, round(end * 1000)).
_format_playback_time() takes integer milliseconds. The PR states that only _to_vtt and _to_srt call it.
The end_ms rule enforces the minimum 1 ms duration. Only the earlier cue's end is clamped, so the next cue's start is unchanged. This matches the issue's expected behavior. The PR also adds tests in tests/test_api_v1_transcription.py for both formats, for same-rounded-millisecond segments (0 µs and 100 µs; 600 µs and 1400 µs), and for the 3599.9999 s hour rollover.
Limitation: the read tool truncated both files before the subtitle functions and the new tests. I confirmed the changed code only through the PR summary and description, not by reading the lines directly. The author also reports the test results (39 passed in the transcription test file).
Full details: Out of Scope Changes check
Explanation
The PR changes two files: portal/routers/api_v1.py and tests/test_api_v1_transcription.py. Per the summary, the api_v1.py changes are limited to the subtitle timestamp path: the new _subtitle_timestamps() helper, the rounding rule, and the _format_playback_time() signature. The test changes cover only the subtitle cue cases in #1466. The PR description also mentions a before-and-after video and a note about PR #1463. Neither adds code to this diff. The summary reports no unrelated edits. Changes in the summary do not show any change outside the issue's scope.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 32b11ddf-6bdc-406f-b1ed-59ab0dba6d7b
Commits
Reviewing files that changed from the base of the PR and between 164f059 and 08a0054.
Files selected for processing: 2
portal/routers/api_v1.py
tests/test_api_v1_transcription.py
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
#1466 bug(api_v1): VTT and SRT transcript export can emit zero-duration subtitle cues when consecutive timestamps round to the same millisecond · 3 of 3 met
#
Requirement
Status
Notes
1
Every WebVTT and SRT cue has a positive duration of at least 1 ms when consecutive timestamps round to the same millisecond.
✅ Met
The shared _subtitle_timestamps() helper clamps each end to at least start_ms + 1 and is used by both serializers.
2
Preserve transcript text and ordering, non-overlapping timing for segments at least 1 ms apart, and clean hour rollovers.
✅ Met
The serializers retain their text and iteration order; the shared helper preserves the 5-second cap and integer-millisecond formatting handles hour rollovers.
3
For cues that round to the same millisecond, keep the next cue at its own rounded start and bump only the earlier cue's end.
✅ Met
The helper adjusts only end_ms; each cue's start is independently rounded from its own timestamp.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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
ai-assistedPR created or assisted with an AI coding agent
3 participants
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
Fixes a bug in
GET /api/v1/events/{event_slug}/rooms/{room_id}/booths/{language_code}/transcripts/exportwhere WebVTT and SRT exports could emit zero-duration subtitle cues (00:00:00.000 --> 00:00:00.000/00:00:00,000 --> 00:00:00,000) whenever consecutive transcript segments have elapsed offsets that round to the same millisecond.Root Cause
_to_vtt()and_to_srt()inportal/routers/api_v1.pycomputedstart_secandend_sec = min(start_sec + 5.0, next_start_sec)as floats and passed them independently to_format_playback_time(seconds, sep).0 µsand100 µs, or cross-boundary offsets like600 µsand1400 µsthat are800 µsapart yet both round to1 ms), both cue endpoints formatted identically.Related Issue
Closes #1466
Changes Made
portal/routers/api_v1.py:_subtitle_timestamps(created_at, next_created_at, origin_utc, sep)for_to_vtt()and_to_srt().start_ms = round(start * 1000)and enforceend_ms = max(start_ms + 1, round(end * 1000))._format_playback_time(total_ms: int, sep: str)to format integer milliseconds directly (checked all repo callers: only_to_vttand_to_srtcall_format_playback_time).tests/test_api_v1_transcription.py:test_export_subtitle_cues_keep_positive_duration_after_roundingcovering bothvttandsrt(0 µs&100 µs).test_export_subtitle_cues_same_rounded_ms_and_hour_rollovercovering segments800 µsapart (600 µs&1400 µs) that round to the same1 ms, ordering, and hour-boundary rollover (3599.9999 s->01:00:00.000).Testing
Checks run on Windows 11 (Python 3.13.15):
ruff check .: passed (All checks passed!)ruff format --check portal/routers/api_v1.py tests/test_api_v1_transcription.py: passed (2 files already formatted)origin/dev @ 164f059):pytest -q tests/test_api_v1_transcription.py→3 failed, 36 passedpytest -q tests/test_api_v1_transcription.py→39 passedpytest tests/test_api_v1_transcription.py tests/test_roles.py tests/test_booth_recovery.py tests/test_transcription_concurrency.py -q→157 passedScreenshots (if applicable)
voxbento-1466-before-after.mp4
Genuine terminal/HTTP API before-and-after screencast recorded locally at
voxbento-1466-before-after.mp4(uploading via GitHub web UI / PR comment).Checklist
Additional Notes
end_msis clamped tostart_ms + 1, so cuei(00:00:00.000 --> 00:00:00.001) overlaps cuei + 1(00:00:00.000 --> 00:00:05.000) by1 ms. Both W3C WebVTT (end > startrequired; overlapping cue intervals allowed) and SRT permit overlapping cues, and avoiding adjustments to cuei + 1's start time prevents cascading timestamp drift on later subtitles relative to audio playback. All segments separated by>= 1 msafter rounding remain non-overlapping.fix/1453-restart-booth-transcription).Created with ChatGPT and Gemini 4 Hydrogen in Antigravity.
Summary by Sourcery
Keep exported subtitle cues valid when adjacent transcript timestamps resolve to the same millisecond.
Bug Fixes:
Tests:
Summary by CodeRabbit