Skip to content

feat(subtitles): add cue builder and srt/vtt renderers - #10

Merged
prateekchaplot merged 2 commits into
mainfrom
arch/tts/t1.4
Nov 20, 2026
Merged

prateekchaplot merged 2 commits into
mainfrom
arch/tts/t1.4

Conversation

@prateekchaplot

Copy link
Copy Markdown
Owner

Task T1.4 from docs/ARCHITECTURE.md §14 (refs §7.6, §8.2).

What changed

  • src/tts/subtitles/cues.py: build_cues(words, sentences, audio_duration_ms) — sentence grouping, 84-char / 5 s splits, 1.2 s minimum extension capped at the next cue start, last-cue clamp to audio duration.
  • src/tts/subtitles/srt.py / vtt.py: render_srt / render_vtt with SRT HH:MM:SS,mmm and WebVTT HH:MM:SS.mmm output.
  • 21 new unit tests plus byte-exact .srt / .vtt golden fixtures; .gitattributes pins the fixtures to LF.

Verification

  • python -m pytest tests/unit -q --basetemp .venv/ptmp-t14-all → 87 passed (66 baseline + 21 new)
  • ruff check src/tts tests → All checks passed
  • ruff format --check src/tts tests → 26 files already formatted
  • mypy --strict src/tts → Success, no issues in 22 source files
  • git diff --check → clean
  • Golden fixtures confirmed LF-only on disk; git check-attr reports eol: lf

Decisions (frozen downstream, also in docs/TASKS.md Notes)

  • subtitles/__init__.py added; cue text is word texts joined with one space (the interface has no source text); a single oversized word is never split.
  • Renderer output matches the shipped frontend/src/api/mock.ts format, including a single trailing newline; empty SRT → "", empty VTT → "WEBVTT\n\n".
  • frontend/src/api/mock.ts:buildCues lacks sentence grouping, the 1.2 s floor, and the audio cap; T4.1 should align it with tts.subtitles.cues.
  • T1.6 must pass (char_start, char_end, first_word_idx) triplets indexed into the final word list; empty sentences are skipped.

Next task: T1.5 (history DAL completion), after this PR is merged.

@prateekchaplot
prateekchaplot merged commit 89cd805 into main Nov 20, 2026
5 checks passed
@prateekchaplot
prateekchaplot deleted the arch/tts/t1.4 branch November 20, 2026 12:58
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