Face Animations
DeskBot's face animations produce timed sequences of face-model deltas
(gaze, mouth shape, eye openness, etc.) that the
FaceOrchestrator applies to the face renderer. They are
standalone, stateless animation objects that can be driven independently
of the event bus.
The three built-in face animations are:
| Animation | Purpose | Trigger |
|---|---|---|
ThinkingDotsAnimation |
Periodic gaze-shift pattern | LLM streaming response |
SpeakingAnimation |
Viseme-based mouth shapes | TTS playback |
WakeAnimation |
4-phase attention-getting flash | Wake word detection |
All animations follow the same pattern: construct, then call
step(dt) in a loop to get the current frame.
ThinkingDotsAnimation
Produces a gentle left-right-up gaze-shift pattern that gives the face a "thinking" look while the LLM is generating a response. The animation cycles through 7 keyframes, holding each for a configurable duration and smoothly interpolating between positions.
from robot.face.animations.thinking_dots import ThinkingDotsAnimation
anim = ThinkingDotsAnimation()
# In a render loop, advance by dt seconds each tick:
gaze = anim.step(dt=0.033)
# gaze.x, gaze.y - feed these into the face model
# Reset when LLM streaming finishes
anim.reset()
Keyframe pattern
The default pattern cycles through these gaze positions:
| # | Gaze (x, y) | Hold (s) | Description |
|---|---|---|---|
| 1 | (0.20, -0.20) | 0.40 | Up-right - classic "thinking" pose |
| 2 | (0.05, -0.15) | 0.30 | Slightly left |
| 3 | (-0.10, -0.10) | 0.35 | Look left |
| 4 | (0.00, -0.05) | 0.25 | Center-up |
| 5 | (-0.05, 0.05) | 0.30 | Slightly down-left |
| 6 | (0.15, -0.25) | 0.40 | Up-right again |
| 7 | (0.00, 0.00) | 0.50 | Return to center |
Transitions begin at 70% of each hold period and use a smoothstep interpolation for a natural feel.
Custom patterns
You can provide your own keyframe pattern:
custom_pattern = [
(-0.3, 0.1, 0.5), # left, slightly down
(0.3, -0.2, 0.5), # right, slightly up
(0.0, 0.0, 0.3), # center
]
anim = ThinkingDotsAnimation(pattern=custom_pattern)
SpeakingAnimation
Produces mouth open/close keyframes driven by a simplified viseme model that maps English text to mouth shapes. Each viseme has a target openness and width, and the animation steps through frames at a configurable speed.
Viseme set
The animation uses 13 simplified visemes:
| Viseme | Sound | Openness | Width |
|---|---|---|---|
IDLE |
silence | 0.0 | 0.5 |
PP |
p, b, m | 0.0 | 0.4 |
FF |
f, v | 0.15 | 0.45 |
TH |
th | 0.2 | 0.5 |
DD |
t, d | 0.25 | 0.5 |
KK |
k, g | 0.3 | 0.5 |
CH |
ch, j, sh | 0.35 | 0.45 |
SS |
s, z | 0.15 | 0.5 |
NN |
n, ng | 0.2 | 0.5 |
RR |
r | 0.25 | 0.4 |
AA |
a | 0.7 | 0.7 |
EE |
e, i | 0.3 | 0.7 |
OO |
o, u | 0.4 | 0.35 |
Usage
from robot.face.animations.speaking import SpeakingAnimation
# From text
anim = SpeakingAnimation(text="Hello there!", speed=1.0)
while anim.has_frames:
frame = anim.step(dt=0.033)
# frame.openness - mouth openness (0.0–1.0)
# frame.width - mouth width (0.0–1.0)
# frame.viseme - current Viseme enum
# frame.duration_s - how long this frame should be held
# From explicit viseme sequence
from robot.face.animations.speaking import SpeakingAnimation, Viseme
anim2 = SpeakingAnimation.from_visemes(
[(Viseme.AA, 0.1), (Viseme.PP, 0.06), (Viseme.SS, 0.08)],
speed=1.2,
)
Timing defaults
| Parameter | Default | Description |
|---|---|---|
default_phoneme_duration |
0.08 s | Duration per phoneme |
pause_duration |
0.15 s | Duration for commas/semicolons |
sentence_pause_duration |
0.25 s | Duration for periods/exclamation marks |
speed |
1.0 | Speed multiplier (0.5 = half speed, 2.0 = double) |
WakeAnimation
A 4-phase attention-getting animation that plays when the robot detects a wake word. The sequence creates a bright "I'm awake!" effect:
| Phase | Duration | What happens |
|---|---|---|
| Eyes open | 0.10 s | Eyes snap to center and open wide |
| Double blink | 0.30 s | Two rapid blinks |
| Mouth surprise | 0.20 s | Mouth opens to an "O" shape |
| Transition | 0.30 s | Smooth transition to a "curious" look |
Usage
from robot.face.animations.wake import WakeAnimation
anim = WakeAnimation()
while not anim.done:
frame = anim.step(dt=0.033)
# frame.gaze - Gaze(x, y) target
# frame.eye_openness - how open the eyes are (0.0–1.2)
# frame.eyelid_top - eyelid position
# frame.mouth_shape - MouthShape enum
# frame.mouth_openness - mouth openness
# frame.mouth_width - mouth width
# frame.eyebrow_shape - EyebrowShape enum
# frame.eyebrow_raise - eyebrow raise amount
# frame.phase - current WakePhase
# Reset for next wake
anim.reset()
Standalone usage
All three animations are pure data objects with no dependencies on the event bus or hardware. You can use them independently:
import time
from robot.face.animations.thinking_dots import ThinkingDotsAnimation
anim = ThinkingDotsAnimation()
last = time.monotonic()
while True:
now = time.monotonic()
dt = now - last
last = now
gaze = anim.step(dt)
# Apply gaze to your own face model or renderer
print(f"Gaze: ({gaze.x:.2f}, {gaze.y:.2f})")
API reference
robot.face.animations.thinking_dots.ThinkingDotsAnimation
dataclass
Produces a sequence of gaze positions for the "thinking dots" effect.
The animation advances through keyframes each time :meth:step
is called, returning the current gaze position. The caller is
responsible for applying the gaze to the face model and publishing
any events.
Source code in src/robot/face/animations/thinking_dots.py
current_position
property
Return the current gaze (x, y) without advancing.
reset()
step(dt)
Advance the animation by dt seconds and return the current gaze.
Parameters
dt: Time elapsed since the last call, in seconds.
Source code in src/robot/face/animations/thinking_dots.py
robot.face.animations.speaking.SpeakingAnimation
dataclass
Produces a sequence of mouth shapes for lip-synced speech.
The animation converts text into a sequence of :class:VisemeFrame
objects, one per phoneme, with timing that approximates natural
speech cadence.
Usage::
anim = SpeakingAnimation(text="Hello there!")
while anim.has_frames:
frame = anim.step(dt=0.033)
face_model = face_model.with_mouth(
Mouth(shape=MouthShape.NEUTRAL, openness=frame.openness, width=frame.width)
)
Source code in src/robot/face/animations/speaking.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
has_frames
property
Whether there are still frames to animate.
total_duration
property
Total animation duration in seconds.
from_visemes(visemes, speed=1.0)
classmethod
Create an animation from an explicit viseme sequence.
Each tuple is (viseme, duration_s).
Source code in src/robot/face/animations/speaking.py
reset()
step(dt)
Advance the animation by dt seconds.
Returns the current :class:VisemeFrame. If the animation has
finished, returns :class:Viseme.IDLE frame.
Source code in src/robot/face/animations/speaking.py
robot.face.animations.speaking.Viseme
Bases: str, Enum
Simplified viseme set for English speech.
Maps approximately to the Prestonon viseme set (13 visemes) but grouped for a small round display. Each viseme has a target mouth openness (0.0 = closed, 1.0 = wide open) and width.
Source code in src/robot/face/animations/speaking.py
robot.face.animations.speaking.VisemeFrame
dataclass
A single frame of the speaking animation.
Attributes
openness: How open the mouth is (0.0 = closed, 1.0 = wide open). width: How wide the mouth is (0.0 = narrow, 1.0 = wide). duration_s: How long this viseme should be held, in seconds. viseme: The viseme this frame represents.
Source code in src/robot/face/animations/speaking.py
robot.face.animations.wake.WakeAnimation
dataclass
Produces a sequence of :class:WakeFrame objects for the wake animation.
Usage::
anim = WakeAnimation()
while not anim.done:
frame = anim.step(dt=0.033)
# Apply frame to face model...
Source code in src/robot/face/animations/wake.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
done
property
Whether the animation has completed.
reset()
step(dt)
Advance the animation by dt seconds and return the current frame.
Source code in src/robot/face/animations/wake.py
robot.face.animations.wake.WakeFrame
dataclass
A single frame of the wake animation.
Provides target values for the face model at a given animation time. The caller interpolates between the current state and this target.
Source code in src/robot/face/animations/wake.py
robot.face.animations.wake.WakePhase
Bases: str, Enum
Phases of the wake animation.