Principle:AI Builder Club Skills Karaoke Caption Generation
| Knowledge Sources | |
|---|---|
| Domains | Subtitling, Video_Processing |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
A subtitle generation technique that transforms word-level timestamps into karaoke-style ASS subtitles with word-by-word sweeping color highlights and optional two-layer soft drop shadows.
Description
Karaoke caption generation bridges word-level transcription and the final burned-in video. The technique groups words into short phrases (one screen each) based on max words per line, silence gaps, and punctuation, then generates ASS Dialogue events where each word is highlighted in turn using inline \1c color override tags. The highlight holds until the next word starts (preventing flicker during minor gaps). Two rendering modes: soft shadow (two-layer: a Gaussian-blurred dark shadow on layer 0 + razor-sharp text with outline and highlight on layer 1, for a TikTok/Shorts aesthetic) or flat (single-layer text). Supports CJK text detection (no spaces between words, different separator), auto-resolution detection via ffprobe, and configurable typography (font, size, colors, alignment, margins).
Usage
Use after word-level transcription and style selection. The output ASS file is burned into video via FFmpeg libass. Apply when you need karaoke-style word-by-word highlight captions for short-form video content.
Theoretical Basis
The technique leverages the ASS subtitle format's inline override tags: \1c changes the primary color mid-line, allowing each word to be individually colored. By generating one Dialogue event per word position (all showing the same phrase, but highlighting a different word), the subtitle "sweeps" through the phrase in sync with the audio. The two-layer shadow technique exploits ASS's layer system: layer 0 renders behind layer 1, so a blurred shadow can sit behind sharp text.
# Abstract model:
def generate_karaoke(words, style):
phrases = group_words(words, max_per_line=4, max_gap=0.8, break_on_punct=True)
events = []
for phrase in phrases:
for i, word in enumerate(phrase):
start = word["start"]
end = phrase[i+1]["start"] if i+1 < len(phrase) else phrase[-1]["end"]
# Inline \1c override: highlight word i, keep others base color
highlighted = build_text_with_override(phrase, i, style.highlight_color, style.primary_color)
events.append((start, end, highlighted))
return ass_header(style) + events