Skip to main content

Module segment

Module segment 

Source
Expand description

Cue segmentation: phrase grouping, splitting, merging, line breaking.

Donor: CutRight cutright-captions (itself ported from video-media’s caption model). Deterministic: identical words + config give identical cues.

Structs§

CaptionConfig
Per-profile segmentation limits.
Cue
One caption cue on the output timeline. Cues never overlap.
GroupRules
Rules for group_words, the lightweight cue grouper for engines whose words are already clean (no line breaking, no reading-speed limits). Use build_cues for caption-grade segmentation.

Enums§

Profile
Named segmentation profile (replaces CutRight’s timeline Preset).

Functions§

build_cues
Builds non-overlapping cues from output-time words.
cues_from_spans
One single-line cue per span, in order (first_word == last_word == the span’s index), widened to min_cue_ms. For callers that already hold cues as TimedWord spans (text = cue text) and only need export.
group_words
Groups words (in order, not re-normalised) into single-line cues by GroupRules. first_word/last_word index the input slice. A cue closes on sentence-final punctuation (after sentence_min_words words), at max_words, at max_span_ms, or on a gap over max_gap_ms.
normalize_words
Trims, drops empty/zero-length words, collapses inner whitespace and clamps overlaps so each word ends no later than the next starts.