LokutorLipSync plays them on the clock of what is being heard, so the mouth stays in time through buffers, pauses and interruptions. Visemes are on by default.
Set it up
Add aLokutorLipSync node beside the LokutorAgent (or above it, under the same character) and drag the face meshes into Faces. The agent finds it by itself. Teeth and tongue meshes go there too if they have the shapes.
The mouth is recognised by the names of its blend shapes. Upper and lower case do not matter, nor what an FBX exporter puts in front (Face.viseme_aa):
Your own names
Mapping says which of your shapes make each viseme, and how much of each:Lokutor.VISEMES: sil PP FF TH DD kk CH SS nn RR aa E ih oh ou. sil is the mouth at rest and needs no shape.
A jaw, or a drawing
- Jaw: a
Node3Drotated around its local X axis. Or Skeleton and Jaw Bone for a bone.jaw_max_angle_degreesis its widest. Jaws and blend shapes can be used together. - Sprite: a
Sprite2D, anAnimatedSprite2Dor any node with aframe. Frames 0 to 3 are closed, slightly open, open and round. With other drawings, Sprite Frames gives the frame of each viseme:{"sil": 0, "PP": 1, "aa": 2, "oh": 3}.
mouth_open (0 to 1), current (the strongest viseme) or weights (the 15 of them), or connect viseme_changed.
The feel
Several voices, one mouth
A character can have aLokutorAgent for conversation and a LokutorVoice for written lines on the same LokutorLipSync. Each voice keeps its own visemes and the mouth follows whoever is speaking; stopping one does not close the mouth of the other.
Without visemes
When a voice has none, the mouth follows its loudness (gain sets how much). To drive a mouth from audio of your own, call push_visemes() with its visemes, if it has them, and advance() every frame with how much of it has been heard: