Follows #289 (caption.js 2.2.0), which added joinSentences: a short whole sentence shares the caption before it. Two cases are left where a short sentence still ends up alone in a caption. There is also one thing callers cannot get from the result at all. The companion issue is hyperaudio/hyperaudio-lite-editor#666.
The example is the opening of an interview:
[speaker-A] to start?
[speaker-B] Sure. So to start off, Dr. Ashby, can you just introduce yourself and give us a little insight into… the organizations that you work for?
With joinSentences on, this generates to start? · Sure. · So to start off, Dr. Ashby, … Two captions of one and two words go by before the speech gets going.
1. Dual-speaker captions.
joinToPrevious() refuses whenever the sentence opens with a speaker label, so a change of speaker always starts a new caption. The style guides put a new speaker on a new line:
- Netflix Timed Text Style Guide: "Use a hyphen without a space to indicate two speakers in one subtitle, with a maximum of one speaker per line."
- BBC Subtitle Guidelines: differently coloured speakers may share a subtitle; white-text speakers each start a new line preceded by a dash.
Wanted, as an option (name to be settled, e.g. dualSpeakers), in the Netflix form:
-
Two short sentences from different speakers may share a caption, with two speakers at most and one speaker per line. Each of the two lines opens with a hyphen, with no space after it.
-
The hyphen marks two speakers sharing a caption, not a change of speaker. A caption with one speaker never has a hyphen, even when it opens a new speaker's turn.
-
The limits are those of any other join. Each side is a whole sentence, or several short ones from one speaker, that fits its line with the hyphen counted. The pause between them is within maxJoinGap. A caption has two lines at most. A third turn starts a new caption.
-
paragraphBreaks wins over this option. A speaker label opens a paragraph, so with that option on a label still starts a new caption.
2. A short sentence may lead the long sentence that follows it.
Joining only works backwards. "Sure." has nothing of its own speaker before it, and the sentence after it is too long for one caption, so it stands alone.
Wanted, as an option (e.g. leadSentences):
- When a short sentence cannot be joined to the caption before it, and the next sentence is by the same speaker, within
maxJoinGap, and too long for one line, the two are laid out as one run. That gives Sure. So to start off, Dr. Ashby,, and the rest follows as it would have.
- "Short" means shorter than
minLength, so the long sentence keeps most of its first line.
- Backward joining keeps priority, because it keeps captions aligned with sentences. No sentence is split that would not have been split anyway, since the long sentence is divided across captions either way.
3. The speaker of each line, in the result.
segmentMeta.speaker is set while segmenting and then dropped. Each cue in result.data is { start, stop, text }. A caller that wants speakers has to re-derive them from cue start times against the transcript, which the editor does. That stops working with dual-speaker captions, because a second line has no time of its own.
Wanted: each cue in result.data also carries the speaker of each of its lines, e.g. speakers: ["speaker-A", "speaker-B"], with one entry per line and "" where there is none. Two things are needed for that:
- The generator has to carry the current speaker forward. Today only the first segment after a label knows its speaker, and later sentences in the same turn have
"".
- The field has to be always present. It is additive, and the
vtt and srt strings are unchanged by it.
This is also the groundwork #284 (voice tags and speaker colours in the generated files) needs, since it cannot colour a line without knowing who speaks it.
Compatibility. With neither option given, vtt, srt and the cue texts are byte-for-byte what 2.2.0 produces. The only difference is the new speakers field on each cue. caption.d.ts and the README document the options and the field.
Acceptance.
- The opening above generates
-to start? / -Sure. as one caption when the pause allows. Otherwise it generates to start?, then Sure. So to start off, Dr. Ashby,.
- No caption has more than two speakers, or more than one speaker on a line. Hyphens appear on both lines of a dual-speaker caption and on no other caption.
- Every cue's
speakers has one entry per line and names the right speaker, including sentences deep inside a long turn.
- With
paragraphBreaks on, or with no speaker labels in the transcript, captions are what they are today.
- jest tests cover each of the above, the pause limit, the two-line limit, and the no-options output against 2.2.0's.
Follows #289 (
caption.js2.2.0), which addedjoinSentences: a short whole sentence shares the caption before it. Two cases are left where a short sentence still ends up alone in a caption. There is also one thing callers cannot get from the result at all. The companion issue is hyperaudio/hyperaudio-lite-editor#666.The example is the opening of an interview:
With
joinSentenceson, this generatesto start?·Sure.·So to start off, Dr. Ashby,… Two captions of one and two words go by before the speech gets going.1. Dual-speaker captions.
joinToPrevious()refuses whenever the sentence opens with a speaker label, so a change of speaker always starts a new caption. The style guides put a new speaker on a new line:Wanted, as an option (name to be settled, e.g.
dualSpeakers), in the Netflix form:Two short sentences from different speakers may share a caption, with two speakers at most and one speaker per line. Each of the two lines opens with a hyphen, with no space after it.
The hyphen marks two speakers sharing a caption, not a change of speaker. A caption with one speaker never has a hyphen, even when it opens a new speaker's turn.
The limits are those of any other join. Each side is a whole sentence, or several short ones from one speaker, that fits its line with the hyphen counted. The pause between them is within
maxJoinGap. A caption has two lines at most. A third turn starts a new caption.paragraphBreakswins over this option. A speaker label opens a paragraph, so with that option on a label still starts a new caption.2. A short sentence may lead the long sentence that follows it.
Joining only works backwards. "Sure." has nothing of its own speaker before it, and the sentence after it is too long for one caption, so it stands alone.
Wanted, as an option (e.g.
leadSentences):maxJoinGap, and too long for one line, the two are laid out as one run. That givesSure. So to start off, Dr. Ashby,, and the rest follows as it would have.minLength, so the long sentence keeps most of its first line.3. The speaker of each line, in the result.
segmentMeta.speakeris set while segmenting and then dropped. Each cue inresult.datais{ start, stop, text }. A caller that wants speakers has to re-derive them from cue start times against the transcript, which the editor does. That stops working with dual-speaker captions, because a second line has no time of its own.Wanted: each cue in
result.dataalso carries the speaker of each of its lines, e.g.speakers: ["speaker-A", "speaker-B"], with one entry per line and""where there is none. Two things are needed for that:"".vttandsrtstrings are unchanged by it.This is also the groundwork #284 (voice tags and speaker colours in the generated files) needs, since it cannot colour a line without knowing who speaks it.
Compatibility. With neither option given,
vtt,srtand the cue texts are byte-for-byte what 2.2.0 produces. The only difference is the newspeakersfield on each cue.caption.d.tsand the README document the options and the field.Acceptance.
-to start?/-Sure.as one caption when the pause allows. Otherwise it generatesto start?, thenSure. So to start off, Dr. Ashby,.speakershas one entry per line and names the right speaker, including sentences deep inside a long turn.paragraphBreakson, or with no speaker labels in the transcript, captions are what they are today.