@voqalize/avatar 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -661
- package/LICENSE-CC-BY-4.0 +396 -0
- package/README.md +191 -662
- package/assets/README.md +48 -0
- package/assets/tanya.glb +0 -0
- package/assets/tara.glb +0 -0
- package/assets/tushar.glb +0 -0
- package/client/Avatar.tsx +57 -0
- package/client/AvatarClient.ts +818 -0
- package/client/arjun.ts +26 -0
- package/client/createAvatar.ts +177 -0
- package/client/createCanvasAvatar.ts +72 -0
- package/client/index.ts +44 -0
- package/client/internal.ts +108 -0
- package/client/interviewer-female.ts +4 -0
- package/client/interviewer-male.ts +4 -0
- package/client/ishita.ts +26 -0
- package/client/kabir.ts +26 -0
- package/client/meera.ts +26 -0
- package/client/naina.ts +26 -0
- package/client/playout.ts +95 -0
- package/client/professional-female-a.ts +4 -0
- package/client/professional-female-b.ts +4 -0
- package/client/professional-male-a.ts +4 -0
- package/client/professional-male-b.ts +4 -0
- package/client/react.ts +13 -0
- package/client/supports.ts +28 -0
- package/client/three/assets.ts +24 -0
- package/client/three/budgets.ts +27 -0
- package/client/three/holds.ts +64 -0
- package/client/three/internal.ts +54 -0
- package/client/three/motion-limits.json +116 -0
- package/client/three/sequences.ts +281 -0
- package/client/three/tanya.ts +69 -0
- package/client/three/tara-rig.ts +1562 -0
- package/client/three/tara.ts +76 -0
- package/client/three/tushar.ts +65 -0
- package/client/types.ts +235 -0
- package/client/useAvatar.ts +74 -0
- package/client/vikram.ts +26 -0
- package/dist/Avatar.d.ts +44 -0
- package/dist/Avatar.d.ts.map +1 -0
- package/{client/dist → dist}/Avatar.js +2 -2
- package/dist/Avatar.js.map +1 -0
- package/dist/AvatarClient.d.ts +274 -0
- package/dist/AvatarClient.d.ts.map +1 -0
- package/dist/AvatarClient.js +712 -0
- package/dist/AvatarClient.js.map +1 -0
- package/dist/arjun.d.ts +7 -0
- package/dist/arjun.d.ts.map +1 -0
- package/dist/arjun.js +20 -0
- package/dist/arjun.js.map +1 -0
- package/dist/createAvatar.d.ts +135 -0
- package/dist/createAvatar.d.ts.map +1 -0
- package/dist/createAvatar.js +75 -0
- package/dist/createAvatar.js.map +1 -0
- package/dist/createCanvasAvatar.d.ts +22 -0
- package/dist/createCanvasAvatar.d.ts.map +1 -0
- package/dist/createCanvasAvatar.js +47 -0
- package/dist/createCanvasAvatar.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +34 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +41 -0
- package/dist/internal.js.map +1 -0
- package/dist/interviewer-female.d.ts +4 -0
- package/dist/interviewer-female.d.ts.map +1 -0
- package/dist/interviewer-female.js +3 -0
- package/dist/interviewer-female.js.map +1 -0
- package/dist/interviewer-male.d.ts +4 -0
- package/dist/interviewer-male.d.ts.map +1 -0
- package/dist/interviewer-male.js +3 -0
- package/dist/interviewer-male.js.map +1 -0
- package/dist/ishita.d.ts +7 -0
- package/dist/ishita.d.ts.map +1 -0
- package/dist/ishita.js +20 -0
- package/dist/ishita.js.map +1 -0
- package/dist/kabir.d.ts +7 -0
- package/dist/kabir.d.ts.map +1 -0
- package/dist/kabir.js +20 -0
- package/dist/kabir.js.map +1 -0
- package/dist/meera.d.ts +7 -0
- package/dist/meera.d.ts.map +1 -0
- package/dist/meera.js +20 -0
- package/dist/meera.js.map +1 -0
- package/dist/naina.d.ts +7 -0
- package/dist/naina.d.ts.map +1 -0
- package/dist/naina.js +20 -0
- package/dist/naina.js.map +1 -0
- package/dist/playout.d.ts +42 -0
- package/dist/playout.d.ts.map +1 -0
- package/dist/playout.js +85 -0
- package/dist/playout.js.map +1 -0
- package/dist/professional-female-a.d.ts +4 -0
- package/dist/professional-female-a.d.ts.map +1 -0
- package/dist/professional-female-a.js +3 -0
- package/dist/professional-female-a.js.map +1 -0
- package/dist/professional-female-b.d.ts +4 -0
- package/dist/professional-female-b.d.ts.map +1 -0
- package/dist/professional-female-b.js +3 -0
- package/dist/professional-female-b.js.map +1 -0
- package/dist/professional-male-a.d.ts +4 -0
- package/dist/professional-male-a.d.ts.map +1 -0
- package/dist/professional-male-a.js +3 -0
- package/dist/professional-male-a.js.map +1 -0
- package/dist/professional-male-b.d.ts +4 -0
- package/dist/professional-male-b.d.ts.map +1 -0
- package/dist/professional-male-b.js +3 -0
- package/dist/professional-male-b.js.map +1 -0
- package/dist/react.d.ts +13 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +13 -0
- package/dist/react.js.map +1 -0
- package/dist/supports.d.ts +20 -0
- package/dist/supports.d.ts.map +1 -0
- package/dist/supports.js +26 -0
- package/dist/supports.js.map +1 -0
- package/dist/three/assets.d.ts +24 -0
- package/dist/three/assets.d.ts.map +1 -0
- package/dist/three/assets.js +22 -0
- package/dist/three/assets.js.map +1 -0
- package/dist/three/budgets.d.ts +17 -0
- package/dist/three/budgets.d.ts.map +1 -0
- package/dist/three/budgets.js +21 -0
- package/dist/three/budgets.js.map +1 -0
- package/dist/three/holds.d.ts +33 -0
- package/dist/three/holds.d.ts.map +1 -0
- package/dist/three/holds.js +56 -0
- package/dist/three/holds.js.map +1 -0
- package/dist/three/internal.d.ts +52 -0
- package/dist/three/internal.d.ts.map +1 -0
- package/dist/three/internal.js +49 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/motion-limits.json +116 -0
- package/dist/three/sequences.d.ts +71 -0
- package/dist/three/sequences.d.ts.map +1 -0
- package/dist/three/sequences.js +262 -0
- package/dist/three/sequences.js.map +1 -0
- package/dist/three/tanya.d.ts +35 -0
- package/dist/three/tanya.d.ts.map +1 -0
- package/dist/three/tanya.js +51 -0
- package/dist/three/tanya.js.map +1 -0
- package/dist/three/tara-rig.d.ts +403 -0
- package/dist/three/tara-rig.d.ts.map +1 -0
- package/dist/three/tara-rig.js +1500 -0
- package/dist/three/tara-rig.js.map +1 -0
- package/dist/three/tara.d.ts +35 -0
- package/dist/three/tara.d.ts.map +1 -0
- package/dist/three/tara.js +58 -0
- package/dist/three/tara.js.map +1 -0
- package/dist/three/tushar.d.ts +31 -0
- package/dist/three/tushar.d.ts.map +1 -0
- package/dist/three/tushar.js +47 -0
- package/dist/three/tushar.js.map +1 -0
- package/dist/types.d.ts +149 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +140 -0
- package/dist/types.js.map +1 -0
- package/dist/useAvatar.d.ts +39 -0
- package/dist/useAvatar.d.ts.map +1 -0
- package/dist/useAvatar.js +35 -0
- package/dist/useAvatar.js.map +1 -0
- package/dist/vikram.d.ts +7 -0
- package/dist/vikram.d.ts.map +1 -0
- package/dist/vikram.js +20 -0
- package/dist/vikram.js.map +1 -0
- package/package.json +110 -25
- package/src/avatar.d.ts +218 -120
- package/src/avatar.js +950 -213
- package/src/behavior.d.ts +42 -0
- package/src/behavior.js +114 -0
- package/src/camera.js +29 -0
- package/src/canvas/author/parts/eye.mjs +722 -0
- package/src/canvas/author/parts/hand.mjs +1156 -0
- package/src/canvas/author/parts/mouth.mjs +741 -0
- package/src/canvas/author/parts/nose.mjs +100 -0
- package/src/canvas/author/parts/skin-detail.mjs +67 -0
- package/src/canvas/author/path.mjs +283 -0
- package/src/canvas/author/rig.mjs +405 -0
- package/src/canvas/avatars/round/face.d.mts +3 -0
- package/src/canvas/avatars/round/face.mjs +1307 -0
- package/src/canvas/create-rig.d.ts +15 -0
- package/src/canvas/create-rig.js +100 -0
- package/src/canvas/data/img/professional-female-a-hair-back.webp +0 -0
- package/src/canvas/data/img/professional-female-a-hair-front.webp +0 -0
- package/src/canvas/data/img/professional-female-a-top-body.webp +0 -0
- package/src/canvas/data/img/professional-female-b-hair-back.webp +0 -0
- package/src/canvas/data/img/professional-female-b-hair-front.webp +0 -0
- package/src/canvas/data/img/professional-female-b-top-body.webp +0 -0
- package/src/canvas/data/img/professional-male-a-hair-back.webp +0 -0
- package/src/canvas/data/img/professional-male-a-hair-front.webp +0 -0
- package/src/canvas/data/img/professional-male-a-top-body.webp +0 -0
- package/src/canvas/data/img/professional-male-b-hair-back.webp +0 -0
- package/src/canvas/data/img/professional-male-b-hair-front.webp +0 -0
- package/src/canvas/data/img/professional-male-b-top-body.webp +0 -0
- package/src/canvas/data/img/round-m3-hair-back.webp +0 -0
- package/src/canvas/data/img/round-m3-hair-front.webp +0 -0
- package/src/canvas/data/img/round-m3-top-body.webp +0 -0
- package/src/canvas/data/img/round-w1-hair-back.webp +0 -0
- package/src/canvas/data/img/round-w1-hair-front.webp +0 -0
- package/src/canvas/data/img/round-w1-top-body.webp +0 -0
- package/src/canvas/data/interviewer-female.rig.json +1 -0
- package/src/canvas/data/interviewer-male.rig.json +1 -0
- package/src/canvas/data/professional-female-a.rig.json +1 -0
- package/src/canvas/data/professional-female-b.rig.json +1 -0
- package/src/canvas/data/professional-male-a.rig.json +1 -0
- package/src/canvas/data/professional-male-b.rig.json +1 -0
- package/src/canvas/src/live.js +508 -0
- package/src/canvas/src/render2d.js +218 -0
- package/src/canvas/src/rig.js +297 -0
- package/src/canvas/src/vocab.js +96 -0
- package/src/clips.js +18 -7
- package/src/conformance.js +119 -0
- package/src/emotions.js +8 -5
- package/src/face-core.js +27 -1
- package/src/face-myna.d.ts +7 -0
- package/src/face-myna.js +192 -131
- package/src/face-peep-control-plane.js +167 -0
- package/src/face-peep.d.ts +7 -0
- package/src/face-peep.js +274 -116
- package/src/face-wren.d.ts +7 -0
- package/src/face-wren.js +17 -19
- package/src/faces.d.ts +12 -0
- package/src/faces.js +53 -0
- package/src/gaze.js +434 -58
- package/src/hand.js +120 -91
- package/src/head.js +134 -0
- package/src/idle.js +227 -119
- package/src/interjections.js +200 -31
- package/src/params.js +8 -4
- package/src/perform.js +7 -9
- package/src/prosody.js +647 -0
- package/src/rig.d.ts +24 -0
- package/src/rig.js +32 -0
- package/src/speech-timing.js +23 -0
- package/src/visemes.js +110 -24
- package/client/dist/Avatar.d.ts +0 -27
- package/client/dist/Avatar.d.ts.map +0 -1
- package/client/dist/Avatar.js.map +0 -1
- package/client/dist/AvatarClient.d.ts +0 -139
- package/client/dist/AvatarClient.d.ts.map +0 -1
- package/client/dist/AvatarClient.js +0 -223
- package/client/dist/AvatarClient.js.map +0 -1
- package/client/dist/index.d.ts +0 -22
- package/client/dist/index.d.ts.map +0 -1
- package/client/dist/index.js +0 -22
- package/client/dist/index.js.map +0 -1
- package/client/dist/types.d.ts +0 -86
- package/client/dist/types.d.ts.map +0 -1
- package/client/dist/types.js +0 -31
- package/client/dist/types.js.map +0 -1
- package/client/dist/useAvatar.d.ts +0 -42
- package/client/dist/useAvatar.d.ts.map +0 -1
- package/client/dist/useAvatar.js +0 -51
- package/client/dist/useAvatar.js.map +0 -1
- package/client/src/Avatar.tsx +0 -33
- package/client/src/AvatarClient.ts +0 -270
- package/client/src/index.ts +0 -22
- package/client/src/types.ts +0 -104
- package/client/src/useAvatar.ts +0 -85
- package/docs/contract-avatar.md +0 -371
- package/docs/contract-protocol.md +0 -461
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AvatarClient — the avatar's server-message dispatcher, turn clock, and cue
|
|
3
|
+
* splice, framework-free (no React; the hook and component wrap this).
|
|
4
|
+
*
|
|
5
|
+
* ## Turn clock anchoring
|
|
6
|
+
*
|
|
7
|
+
* Base Pipecat TTS gives each serialized TTS context an opaque `context_id`.
|
|
8
|
+
* The server uses it only to group and splice cue chunks. `botStartedSpeaking`
|
|
9
|
+
* has no context payload, so the browser FIFO-claims the next buffered context
|
|
10
|
+
* at that Pipecat output-lifecycle event. `botStoppedSpeaking` closes it. No
|
|
11
|
+
* avatar-specific speech marker exists.
|
|
12
|
+
*
|
|
13
|
+
* The event says *which* audio is starting, not *when* it is heard, and the
|
|
14
|
+
* turn clock is anchored to the sound itself (`playout.ts` has the
|
|
15
|
+
* measurements that forced it). `attach()` listens to the bot's audio track;
|
|
16
|
+
* at the event, the turn's zero is backdated to a sound that has already begun,
|
|
17
|
+
* or the mouth is held shut until one does. When the track cannot be heard —
|
|
18
|
+
* no `attach()`, no track, a suspended audio graph, or a sound that never
|
|
19
|
+
* arrives within `ONSET_WAIT_MS` — the event is the anchor, as it always was.
|
|
20
|
+
* Which one won is logged once per turn, at `info`, because a desync report is
|
|
21
|
+
* unanswerable without it.
|
|
22
|
+
*
|
|
23
|
+
* The clock then runs `VISUAL_LEAD_MS` ahead of the sound, since the mixer's
|
|
24
|
+
* smoothing makes every mouth shape late by about that much. It is pulled back
|
|
25
|
+
* by any output-device latency beyond what the display already matches (a
|
|
26
|
+
* Bluetooth headset). Within a turn, each resumption after a pause in the
|
|
27
|
+
* track is a second chance to hear where the sound really is — but a mouth
|
|
28
|
+
* opens before its sound, so a resumption heard within the track's usual
|
|
29
|
+
* anticipation of it agrees with the clock. Only a disagreement beyond that is
|
|
30
|
+
* slewed out, at no more than 10 % of clock rate, never jumped, because a
|
|
31
|
+
* mouth that skips is seen and one that runs briefly fast is not.
|
|
32
|
+
*
|
|
33
|
+
* `attach()` subscribes to the avatar server-message channel *and* Pipecat's
|
|
34
|
+
* standard lifecycle events. Server messages carry only what Pipecat cannot:
|
|
35
|
+
* correlated speech/cue timing and deliberate application instructions. The
|
|
36
|
+
* lifecycle events project the factual presence states locally. The server
|
|
37
|
+
* supplies only the three lower-priority states and deliberate,
|
|
38
|
+
* self-completing actions. This keeps the face tied to Pipecat's output truth
|
|
39
|
+
* even if a server state is delayed or stale.
|
|
40
|
+
*
|
|
41
|
+
* ## Cue splice
|
|
42
|
+
*
|
|
43
|
+
* The widget has two cue-track primitives: `speak({cues, clock})` (a full
|
|
44
|
+
* replace) and `pushCues(cues)` (a pure union that can only grow the track,
|
|
45
|
+
* never shrink it). Neither is "discard queued cues at or after `from_ms`,
|
|
46
|
+
* then append" on its own — `pushCues` has no way to drop a stale tail. So
|
|
47
|
+
* this client keeps the turn's canonical cue array itself (kept portion +
|
|
48
|
+
* every appended chunk, spliced on each `cues` message) and picks the cheapest
|
|
49
|
+
* widget call that stays correct:
|
|
50
|
+
*
|
|
51
|
+
* - if the splice's `from_ms` doesn't reach back into anything already
|
|
52
|
+
* queued — the common case past a turn's first sentence, since only the
|
|
53
|
+
* first sentence genuinely plays fast-leg cues — nothing needs discarding:
|
|
54
|
+
* `pushCues(newCues)` is the cheap, correct append.
|
|
55
|
+
* - if it does reach back (a real fast→accurate splice), `pushCues` cannot
|
|
56
|
+
* express the discard; we call `speak()` again with the full spliced
|
|
57
|
+
* canonical array on the turn's original clock. `speak()` is otherwise
|
|
58
|
+
* documented as also killing an in-flight spoken interjection and
|
|
59
|
+
* re-entering `SPEAKING` — both harmless mid-splice (an interjection
|
|
60
|
+
* should not be running while a server track owns the mouth; re-entering
|
|
61
|
+
* an unchanged state is a no-op past the profile/gaze reset the widget
|
|
62
|
+
* already does for a same-name `setState`).
|
|
63
|
+
*
|
|
64
|
+
* Cues commonly arrive **before** `botStartedSpeaking` — the fast leg starts
|
|
65
|
+
* the moment a sentence is handed to TTS, well before bot output begins.
|
|
66
|
+
* Chunks that arrive before the clock is anchored are spliced into the
|
|
67
|
+
* canonical array but not yet handed to the widget; `botStartedSpeaking` hands over
|
|
68
|
+
* whatever has accumulated as the turn's first `speak()` call. So "the first
|
|
69
|
+
* chunk of a turn starts speak()" means the first *widget* call, not
|
|
70
|
+
* necessarily the first *message*.
|
|
71
|
+
*/
|
|
72
|
+
import type { PipecatClient } from "@pipecat-ai/client-js";
|
|
73
|
+
import { type PlayoutProbe } from "./playout.js";
|
|
74
|
+
import { type AvatarCommand, type AvatarCue } from "./types.js";
|
|
75
|
+
/**
|
|
76
|
+
* How far the cue clock runs ahead of the sound. The mixer eases every mouth
|
|
77
|
+
* channel toward its target with a 42 ms time constant
|
|
78
|
+
* (`MOUTH_RESPONSE_TAU_S`), which delays a shape by about that much, and a
|
|
79
|
+
* frame is drawn on average half a frame after its time. Picture ahead of sound
|
|
80
|
+
* is the side people forgive (ITU-R BT.1359: sound leading is noticed at about
|
|
81
|
+
* 45 ms, picture leading at about 125 ms), so a small surplus is the safe error.
|
|
82
|
+
*/
|
|
83
|
+
export declare const VISUAL_LEAD_MS = 50;
|
|
84
|
+
/**
|
|
85
|
+
* The private renderer-side vocabulary the lifecycle driver actually uses.
|
|
86
|
+
*
|
|
87
|
+
* This stays narrower than `AvatarApi` on purpose. The latter is the SVG
|
|
88
|
+
* mixer's driving API; requiring a second renderer to impersonate every one
|
|
89
|
+
* of its inspection and authoring methods would turn that implementation
|
|
90
|
+
* detail into a renderer contract. The public seam remains `createAvatar`.
|
|
91
|
+
*/
|
|
92
|
+
export interface AvatarDriver {
|
|
93
|
+
setState(name: string): unknown;
|
|
94
|
+
/**
|
|
95
|
+
* One motion by name — a core intent or one of this avatar's own. **A name
|
|
96
|
+
* it does not have is a no-op, not a throw**: the wire's action vocabulary is
|
|
97
|
+
* open, so a face that cannot do the thing is as expected as a newer server.
|
|
98
|
+
*/
|
|
99
|
+
action(id: string): unknown;
|
|
100
|
+
speak(options: {
|
|
101
|
+
cues: AvatarCue[];
|
|
102
|
+
clock: () => number;
|
|
103
|
+
}): unknown;
|
|
104
|
+
pushCues(cues: AvatarCue[]): unknown;
|
|
105
|
+
stopSpeaking(): unknown;
|
|
106
|
+
setUserSpeaking(speaking: boolean | null): unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Internal. Not exported from the package — the public surface is
|
|
110
|
+
* `createAvatar({ mount, client })` and nothing else.
|
|
111
|
+
*
|
|
112
|
+
* There is deliberately no `accept` predicate here any more. Avatar commands
|
|
113
|
+
* travel in one envelope, `{type:"avatar"}`, in both directions and from every
|
|
114
|
+
* source: a `AvatarProcessor` in the pipeline and a brain driving the face
|
|
115
|
+
* out of band emit the same shape. A per-deployment predicate meant the
|
|
116
|
+
* library could not state what an avatar message *is*, which is the one thing
|
|
117
|
+
* a wire format has to be able to say.
|
|
118
|
+
*/
|
|
119
|
+
export interface AvatarClientOptions {
|
|
120
|
+
/** A dispatch threw (e.g. an unknown state or interjection id, which the
|
|
121
|
+
* widget throws on). Defaults to `console.warn`. */
|
|
122
|
+
onError?: (err: unknown, msg: AvatarCommand) => void;
|
|
123
|
+
/** Override for tests. Defaults to `performance.now`. */
|
|
124
|
+
now?: () => number;
|
|
125
|
+
/** Override for tests. Defaults to listening to the bot's audio track, once
|
|
126
|
+
* `attach()` has found one. */
|
|
127
|
+
playoutProbe?: PlayoutProbe;
|
|
128
|
+
/** Quiet time in listening before the client-owned idle loop begins. */
|
|
129
|
+
idleDelayMs?: number;
|
|
130
|
+
/** Timer seams keep lifecycle behavior deterministic in tests. */
|
|
131
|
+
setTimeout?: typeof setTimeout;
|
|
132
|
+
clearTimeout?: typeof clearTimeout;
|
|
133
|
+
/**
|
|
134
|
+
* Internal, for Studio's inspector — the resolved projection, so a developer
|
|
135
|
+
* tool can show what the lifecycle decided. It is *not* on the public
|
|
136
|
+
* surface and must not become one: a presence callback is a contract, and
|
|
137
|
+
* publishing it would oblige every avatar implementation to emit these seven
|
|
138
|
+
* states with this precedence, which is exactly the second public contract
|
|
139
|
+
* the design exists to avoid.
|
|
140
|
+
*/
|
|
141
|
+
onPresenceChange?: (state: AvatarPresenceState) => void;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The one `RTVIEvent` member `attach()` subscribes to, spelled as its value.
|
|
145
|
+
*
|
|
146
|
+
* Written out rather than imported because that enum was this module's *only*
|
|
147
|
+
* runtime reference to `@pipecat-ai/client-js`, and one runtime reference makes
|
|
148
|
+
* the whole `/pipecat` subpath fail to load without the peer installed — even
|
|
149
|
+
* for a host that drives `dispatch()` from its own transport and never calls
|
|
150
|
+
* `attach()`. The peer is declared optional; this is what makes that true
|
|
151
|
+
* rather than aspirational.
|
|
152
|
+
*
|
|
153
|
+
* String enums are nominal in TypeScript, so the compiler cannot check these
|
|
154
|
+
* against the real ones from a type-only import. `packages/avatar/test/AvatarClient.test.ts`
|
|
155
|
+
* does it instead, against the actual enum — the devDependency is present
|
|
156
|
+
* exactly where the check belongs and absent from what we ship.
|
|
157
|
+
*/
|
|
158
|
+
export declare const RTVI_EVENTS: {
|
|
159
|
+
readonly serverMessage: "serverMessage";
|
|
160
|
+
readonly connected: "connected";
|
|
161
|
+
readonly disconnected: "disconnected";
|
|
162
|
+
readonly botReady: "botReady";
|
|
163
|
+
readonly error: "error";
|
|
164
|
+
readonly userStartedSpeaking: "userStartedSpeaking";
|
|
165
|
+
readonly userStoppedSpeaking: "userStoppedSpeaking";
|
|
166
|
+
readonly botStartedSpeaking: "botStartedSpeaking";
|
|
167
|
+
readonly botStoppedSpeaking: "botStoppedSpeaking";
|
|
168
|
+
readonly trackStarted: "trackStarted";
|
|
169
|
+
readonly userMuteStarted: "userMuteStarted";
|
|
170
|
+
readonly userMuteStopped: "userMuteStopped";
|
|
171
|
+
};
|
|
172
|
+
/** The resolved, factual presence state a host may render around the avatar. */
|
|
173
|
+
export type AvatarPresenceState = "IDLE" | "LISTENING" | "CANT_HEAR" | "THINKING" | "WORKING" | "MUTED" | "SPEAKING" | "DEGRADED" | "OFFLINE";
|
|
174
|
+
export declare class AvatarClient {
|
|
175
|
+
private readonly avatar;
|
|
176
|
+
/** Maps factual/wire intent into the broader client behavior catalog. */
|
|
177
|
+
private readonly behavior;
|
|
178
|
+
private readonly opts;
|
|
179
|
+
private readonly now;
|
|
180
|
+
private turn;
|
|
181
|
+
private readonly turns;
|
|
182
|
+
private readonly pendingCtxs;
|
|
183
|
+
private readonly closedCtxs;
|
|
184
|
+
private projected;
|
|
185
|
+
private serverState;
|
|
186
|
+
private userSpeaking;
|
|
187
|
+
private botSpeaking;
|
|
188
|
+
private muted;
|
|
189
|
+
private listening;
|
|
190
|
+
private idle;
|
|
191
|
+
private failure;
|
|
192
|
+
private idleTimer;
|
|
193
|
+
private pendingInterruptedAction;
|
|
194
|
+
private discardQueuedContextsOnBotStop;
|
|
195
|
+
private readonly idleDelayMs;
|
|
196
|
+
private readonly setTimer;
|
|
197
|
+
private readonly clearTimer;
|
|
198
|
+
private probe;
|
|
199
|
+
private probeTrack;
|
|
200
|
+
/** Whether the probe has ever heard an onset. One that has not, and times
|
|
201
|
+
* out, is deaf to this track rather than early to it. */
|
|
202
|
+
private probeHeard;
|
|
203
|
+
private onsetTimer;
|
|
204
|
+
private reanchorTimer;
|
|
205
|
+
constructor(avatar: AvatarDriver, opts?: AvatarClientOptions);
|
|
206
|
+
/** The active turn's ctx, or `null` between turns. For tests and telemetry. */
|
|
207
|
+
get turnCtx(): string | null;
|
|
208
|
+
/** The active turn's canonical (already-spliced) cue track. For tests and telemetry. */
|
|
209
|
+
get turnCues(): AvatarCue[];
|
|
210
|
+
/** Current resolved projection. Internal — for tests and Studio's inspector.
|
|
211
|
+
* Before the first lifecycle fact the renderer is simply at its ready rest
|
|
212
|
+
* pose, so `LISTENING` is the safe value; it is not a session status. */
|
|
213
|
+
get presenceState(): AvatarPresenceState;
|
|
214
|
+
/** Re-apply the currently resolved factual projection after an embedding
|
|
215
|
+
* tool has temporarily used raw renderer controls. This does not invent a
|
|
216
|
+
* lifecycle event or cancel a finite action. */
|
|
217
|
+
restoreProjection(): void;
|
|
218
|
+
/** Dispatch one server message. Anything that isn't in the avatar envelope
|
|
219
|
+
* is not ours and is ignored; so is an envelope carrying a `cmd` this build
|
|
220
|
+
* has never heard of, per the wire protocol's forward-compat rule. */
|
|
221
|
+
dispatch(raw: unknown): void;
|
|
222
|
+
private handleState;
|
|
223
|
+
private handleAction;
|
|
224
|
+
private playAction;
|
|
225
|
+
private ensureTurn;
|
|
226
|
+
private handleCues;
|
|
227
|
+
private activateNextTurn;
|
|
228
|
+
/** Put the turn's zero where its sound began — see the header. */
|
|
229
|
+
private anchor;
|
|
230
|
+
private anchored;
|
|
231
|
+
/** The lead for a turn starting now — see `VISUAL_LEAD_MS`. */
|
|
232
|
+
private leadMs;
|
|
233
|
+
/** The first resumption after `after` (track ms) that follows a pause long
|
|
234
|
+
* enough to be heard as one. */
|
|
235
|
+
private nextResumption;
|
|
236
|
+
/** Listen for the sound at the turn's next resumption, once. */
|
|
237
|
+
private scheduleReanchor;
|
|
238
|
+
private clearReanchorTimer;
|
|
239
|
+
private clearOnsetTimer;
|
|
240
|
+
private dropProbe;
|
|
241
|
+
/** Listen to the bot's audio track, if the transport has one yet. */
|
|
242
|
+
private listenTo;
|
|
243
|
+
private discardQueuedTurns;
|
|
244
|
+
private lifecycleState;
|
|
245
|
+
private applyProjection;
|
|
246
|
+
private clearIdleTimer;
|
|
247
|
+
private armIdleIfEligible;
|
|
248
|
+
private eligibleForIdle;
|
|
249
|
+
private enterListening;
|
|
250
|
+
private clearServerStateForTurnBoundary;
|
|
251
|
+
private maybePlayInterrupted;
|
|
252
|
+
private clearRecoverableFailure;
|
|
253
|
+
private onUserStartedSpeaking;
|
|
254
|
+
private onUserStoppedSpeaking;
|
|
255
|
+
private onBotStartedSpeaking;
|
|
256
|
+
private onBotStoppedSpeaking;
|
|
257
|
+
private onUserMuteStarted;
|
|
258
|
+
private onUserMuteStopped;
|
|
259
|
+
private onError;
|
|
260
|
+
private onDisconnected;
|
|
261
|
+
private onConnectedOrReady;
|
|
262
|
+
/**
|
|
263
|
+
* Subscribe to a live `PipecatClient`. Standard client events own the normal
|
|
264
|
+
* lifecycle projection; avatar server-messages carry correlated visemes and
|
|
265
|
+
* explicit application intent. Never throws on malformed or irrelevant
|
|
266
|
+
* server messages.
|
|
267
|
+
*
|
|
268
|
+
* @returns an unsubscribe function; call it on unmount or disconnect.
|
|
269
|
+
*/
|
|
270
|
+
attach(client: PipecatClient): () => void;
|
|
271
|
+
/** Dispose controller-owned timers when its mounted avatar is destroyed. */
|
|
272
|
+
destroy(): void;
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=AvatarClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvatarClient.d.ts","sourceRoot":"","sources":["../client/AvatarClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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