Skip to content

feat: subtitle/caption export (SRT + WebVTT)#184

Open
seonghobae wants to merge 1 commit into
mainfrom
feat/subtitle-export
Open

feat: subtitle/caption export (SRT + WebVTT)#184
seonghobae wants to merge 1 commit into
mainfrom
feat/subtitle-export

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Why

Captions/subtitles are a high-value output for recorded audio/video — searchable, accessible, embeddable. This adds a self-contained module to turn timestamped transcript segments into .srt and .vtt files.

What

  • New subtitles.py (stdlib-only, no new dependency; independent — does not import the transcription module).
  • Segment dataclass input contract (also accepts duck-typed objects with .start/.end/.text).
  • to_srt/to_vtt (return text) and write_srt/write_vtt (write files). SRT HH:MM:SS,mmm + 1-based indices; VTT HH:MM:SS.mmm + WEBVTT header. Handles empty input, sub-second, hours>0, multi-line, negative clamp, ms rounding.

Tests

tests/test_subtitles.py — 21 tests (formats, indices, headers, empty, hour-plus, rounding, duck-typing, file roundtrips). interrogate 100%; full suite no new failures.

🤖 Generated with Claude Code

Add a self-contained, stdlib-only subtitles.py that converts timestamped
transcript segments into SubRip (.srt) and WebVTT (.vtt) captions.

- Segment dataclass as a tiny input contract (also accepts duck-typed
  objects with .start/.end/.text), independent of transcribe.py
- to_srt / to_vtt render formatted text; write_srt / write_vtt write files
- Correct timestamp formatting: SRT HH:MM:SS,mmm, VTT HH:MM:SS.mmm,
  sequential SRT indices, WEBVTT header, hours>0, sub-second, multi-line
- Edge cases: empty input, negative-time clamp, millisecond rounding,
  CRLF normalization
- 21 unit tests in tests/test_subtitles.py; interrogate 100%

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CJRVbDrp1vGYkJgNHMGPpG
@seonghobae seonghobae enabled auto-merge (squash) July 6, 2026 14:26
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