Menu

1 / 2

Why auto-generated captions break English lines in the wrong place (and how to fix it with spaCy)

DEV Community: nlp·yosuga·8 days ago
#U9cfKRG1
#devtonlp#devto#dev#line#captions
Reading 0:00
15s threshold

Netflix has written rules for where a subtitle line may break. Most caption tools ignore them. Here is a 100-line spaCy implementation, and the API I built around it.

I build apps and APIs that generate how-to and ad videos automatically, and captions are always the hardest part to get right. Transcription is automatic now, but the line breaks it produces look like this:

Today I'll show you how to add captions to any video in just one click.

Enter fullscreen mode

Exit fullscreen mode

Nothing is misspelled, yet the line ends on "to" and its object starts the next line. Your eye has to jump back to rejoin "to any video". On a phone, in a Short that is on screen for two seconds, that small stumble is the difference between reading the caption and giving up on it.

This post covers the rules professional subtitlers use, a runnable Python implementation with spaCy, the same idea for word-by-word Shorts captions, and what is still missing before you have production subtitles.

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.