Skip to content

Fix timestamp rounding in live SRT and WebVTT captions - #175

Open
pcbeingused33 wants to merge 1 commit into
deepgram:mainfrom
pcbeingused33:fix/caption-timestamp-rounding
Open

pcbeingused33 wants to merge 1 commit into
deepgram:mainfrom
pcbeingused33:fix/caption-timestamp-rounding

Conversation

@pcbeingused33

Copy link
Copy Markdown

Summary

Live captions (dg listen with SRT or WebVTT output) round the fractional part of each timestamp after splitting out the larger time units. At 59.9996 seconds, this produces 00:00:59,1000 in SRT and 00:00:60.000 in WebVTT. Neither is a valid timestamp, so subtitle players and parsers reject the cue.

Changes

  • Round to total milliseconds first, then split the value into hours, minutes, seconds, and milliseconds. One shared helper does this for both formats. The same input now produces 00:01:00,000 in SRT and 00:01:00.000 in WebVTT.
  • Add a regression test for the live caption writer in both formats. It covers cue start and end times at second, minute, and hour boundaries.

Test plan

  • make check passes (format, lint, typecheck). Ruff lint and format passed on the changed files; typecheck was not run.
  • make dev passes (format, lint, tests). Not run.
  • Manual testing of affected commands
  • Caption unit tests (packages/deepctl-cmd-listen/tests/unit/test_captions.py): 5 fail before the fix, and all 42 pass after it.

Related issues

None. The bug was found while reading the code.

AI assistance was used to develop the fix and tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant