Skip to content

Translate captions as whole sentences - #174

Merged
bpacholek merged 1 commit into
mainfrom
translate-sentences
Nov 1, 2026
Merged

bpacholek merged 1 commit into
mainfrom
translate-sentences

Conversation

@bpacholek

Copy link
Copy Markdown
Contributor

Found while translating the captions of a 75 s Polish talk into English on the emulator (Whisper Base, then the offline Polish → English model, #47).

Before: each caption went to Marian alone. Captions often end mid-sentence, so the fragments came back as fragments, capitalised as if each were a sentence:

And here is an explanation, because / Although we will talk about / technical things, / Technological, why her / goes to the tips section, not tech.

After: CaptionSentences.group joins consecutive captions up to a sentence's end (., ?, !, …; at most six captions, so run-on speech stays a reasonable input), and the view model translates those. CaptionSentences.split shares each translation back over its captions in proportion to their length, breaking between words, with a word for every caption while there are enough. TranslateCaptions is unchanged: each copy keeps its caption's time, and its words share it by length.

And here is an explanation, / because although we will talk / about the technical, / technological thing, why does it go / to the tips section and not the tech.

Test plan

  • New unit tests in CaptionTranslationTest: grouping on the Polish captions, and splitting by length. :core:model:test, :feature:captions:testDebugUnitTest and spotlessCheck pass.
  • On the emulator: the talk's 31 captions translated into English read as continuous sentences. The one stray capital left ("The world,") is where a sentence ran longer than six captions.

🤖 Generated with Claude Code

Each caption went to the translator alone, and a caption often ends
mid-sentence: a Polish talk's "chociaż będziemy rozmawiać o" came back
as "Although we will talk about", and its next line as "Technological,
why her". Consecutive captions are now joined up to a sentence's end
(at most six), translated together, and the translation is shared back
over them by length, broken between words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bpacholek
bpacholek merged commit 778bbc8 into main Nov 1, 2026
1 check passed
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