Align script text to audio with karaoke-style word timestamps using Qwen3-ForcedAligner + jieba
Align existing script text to audio for karaoke-style captions. Uses Qwen3-ForcedAligner-0.6B (~30ms precision) and jieba for Chinese word segmentation (groups characters into natural words).
Script + Audio
β
Qwen3-ForcedAligner (character-level timestamps)
β
Jieba word segmentation (characters β Chinese words)
β
Position-based phrase matching (words β phrases)
β
Output: phrases with embedded word timestamps
# Align script to audio (phrase-level output with word timestamps)
python skills/align-captions/align.py voiceover.wav --script "ε½ε
¨δΈηι½ε¨θΏ½AIηζΆε..."
# Save to file
python skills/align-captions/align.py voiceover.wav --script "..." --output captions.json
# Word-level only (no phrase grouping)
python skills/align-captions/align.py voiceover.wav --script "..." --word-level
Designed for Remotion karaoke rendering:
{
"segments": [
{
"text": "ε½ε
¨δΈη...",
"startMs": 240, "endMs": 2080,
"words": [
{"text": "ε½", "startMs": 240, "endMs": 400},
{"text": "ε
¨δΈη", "startMs": 400, "endMs": 880}
]
}
],
"word_segments": [...],
"language": "Chinese",
"model": "Qwen3-ForcedAligner-0.6B"
}
from align import align_captions
# Get phrases with embedded word timestamps
result = align_captions(
"voiceover.wav",
script="ε½ε
¨δΈηι½ε¨θΏ½AIηζΆε...",
language="Chinese"
)
# Each phrase has a 'words' array for karaoke highlighting
for phrase in result["segments"]:
print(f"{phrase['text']}: {len(phrase['words'])} words")
The make_video.py script automatically uses align-captions when:
caption_mode is "auto" or "asr"The output is passed to Remotion's RollingCaption component for karaoke rendering.
FileNotFoundError -- check project.json for the correct voiceover path.~/.cache/huggingface/).pip install jieba. Without it, Chinese text falls back to character-level timestamps (no word grouping).