Skip to content

Commit 4c09469

Browse files
committed
fix: one word per caption keeps fillers separate, seed saved style with the size
- At 1 word per caption the filler-skipping chunker no longer groups a filler with the word after it. - Picking Words Per Caption before the first transcription seeds the saved default caption style first, so generation does not skip it.
1 parent 68e2c25 commit 4c09469

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎apps/desktop-gpui/src/editor_tabs.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,10 @@ impl EditorWindow {
12011201
if seed_when_missing {
12021202
// The segment size is picked before the first transcription,
12031203
// so that write seeds the captions block instead of no-oping
1204-
// like the style settings do.
1204+
// like the style settings do. The saved default style goes in
1205+
// first, because generation only seeds it into a project that
1206+
// has no captions block yet.
1207+
crate::style_presets::seed_default_captions(project);
12051208
let captions = project
12061209
.captions
12071210
.get_or_insert_with(cap_project::CaptionsData::default);

‎crates/project/src/caption_words.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ pub fn caption_word_chunks_skipping_fillers_with(
173173
words: &[CaptionWord],
174174
words_per_segment: usize,
175175
) -> Vec<&[CaptionWord]> {
176+
// One word on screen at a time: a filler is its own caption, never
177+
// grouped with the word after it.
178+
if words_per_segment <= 1 {
179+
return caption_word_chunks_with(words, 1);
180+
}
176181
let spoken: Vec<usize> = words
177182
.iter()
178183
.enumerate()
@@ -676,4 +681,18 @@ mod tests {
676681
assert_eq!(caption_text_from_words(chunks[1]), "five six seven");
677682
assert_eq!(caption_text_from_words(chunks[2]), "eight nine");
678683
}
684+
685+
#[test]
686+
fn one_word_per_segment_keeps_fillers_out_of_the_next_word() {
687+
let words = ["I", "um", "think", "so"]
688+
.iter()
689+
.enumerate()
690+
.map(|(index, text)| word(text, index))
691+
.collect::<Vec<_>>();
692+
693+
let chunks = caption_word_chunks_skipping_fillers_with(&words, 1);
694+
695+
assert_eq!(chunks.len(), words.len());
696+
assert!(chunks.iter().all(|chunk| chunk.len() == 1));
697+
}
679698
}

0 commit comments

Comments
 (0)