lipsync
Speech-to-viseme mouth track generator and Lottie precomp exporter with lip-sync QA gates.
Offline speech-to-mouth pipeline that runs SHA-256-pinned Rhubarb Lip Sync (or parses ElevenLabs character timestamps), enforces animation timing gates, and exports 10-shape Preston Blair Lottie precomps and Papagayo .dat files.
git clone https://github.com/BestRoiMedia/anim-toolkit.gitWhy we built it
Raw automatic lip-sync output often produces single-frame mouth blips, misses bilabial closures on M/B/P sounds, or leaves the mouth open during silence. We built lipsync to run deterministic timing and phoneme-closure gates before exporting game-ready Lottie precomps with cue markers.
Architecture & how it works
lipsync.py executes Rhubarb Lip Sync offline against a WAV file and transcript (or maps saved ElevenLabs alignment JSON timestamps by spelling rules without making network calls). It inspects Rhubarb's debug phone log and enforces five gates: MIN_HOLD (merges sub-2-frame blips at 24 fps), MBP_BEFORE_PB (inserts missed M/B/P closures as a warning), REST_BETWEEN_LINES, REST_ENDS, and AUDIO_OFFSET. It outputs <name>.lipsync.json, Papagayo .dat for OpenToonz, and exports a Lottie precomp in timeremap or visibility mode with IoU verification and an optional ffmpeg MP4 preview.
Key capabilities
- SHA-256-pinned Rhubarb Lip Sync installer and offline runner (RHUBARB_BIN override)
- Offline ElevenLabs alignment JSON fallback (--timestamps) with zero network calls
- Automated lip-sync QA gates: MIN_HOLD, MBP_BEFORE_PB, REST_BETWEEN_LINES, REST_ENDS, AUDIO_OFFSET
- 10-shape Preston Blair SVG mouth export (AI, E, O, U, FV, L, MBP, WQ, etc, rest)
- Lottie export in hold-keyed timeremap or visibility mode with cue markers and MP4 sync preview
Usage example
python3 anim/lipsync/lipsync.py doctor
python3 anim/lipsync/lipsync.py track ./voice.wav --text "Line one.|Line two." --fps 24
python3 anim/lipsync/lipsync.py check ./voice.lipsync.json
python3 anim/lipsync/lipsync.py export ./voice.lipsync.json --mouths ./mouths --audio ./voice.wav