@voqalize/avatar 0.4.4 → 0.5.1
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/README.md +65 -154
- package/dist/index.d.ts +37 -26
- package/dist/index.js +48 -25
- package/dist/pin.d.ts +2 -0
- package/dist/pin.js +3 -0
- package/dist/react.d.ts +21 -6
- package/dist/react.js +24 -6
- package/package.json +8 -67
- package/LICENSE-APACHE-2.0 +0 -201
- package/LICENSE-CC-BY-4.0 +0 -396
- package/assets/README.md +0 -60
- package/assets/tanvi.glb +0 -0
- package/assets/tanya.glb +0 -0
- package/assets/tara.glb +0 -0
- package/assets/tess.glb +0 -0
- package/assets/tushar.glb +0 -0
- package/client/Avatar.tsx +0 -57
- package/client/AvatarClient.ts +0 -818
- package/client/createAvatar.ts +0 -177
- package/client/index.ts +0 -44
- package/client/internal.ts +0 -132
- package/client/playout.ts +0 -95
- package/client/react.ts +0 -13
- package/client/supports.ts +0 -27
- package/client/three/assets.ts +0 -26
- package/client/three/budgets.ts +0 -27
- package/client/three/character-rig.ts +0 -1746
- package/client/three/createCharacter.ts +0 -109
- package/client/three/holds.ts +0 -69
- package/client/three/internal.ts +0 -55
- package/client/three/motion-limits.json +0 -124
- package/client/three/sequences.ts +0 -281
- package/client/three/tanvi-asset.ts +0 -6
- package/client/three/tanvi.ts +0 -30
- package/client/three/tanya-asset.ts +0 -6
- package/client/three/tanya.ts +0 -29
- package/client/three/tara-asset.ts +0 -25
- package/client/three/tara.ts +0 -36
- package/client/three/tess-asset.ts +0 -6
- package/client/three/tess.ts +0 -30
- package/client/three/tushar-asset.ts +0 -6
- package/client/three/tushar.ts +0 -28
- package/client/types.ts +0 -235
- package/client/useAvatar.ts +0 -74
- package/dist/Avatar.d.ts +0 -44
- package/dist/Avatar.d.ts.map +0 -1
- package/dist/Avatar.js +0 -7
- package/dist/Avatar.js.map +0 -1
- package/dist/AvatarClient.d.ts +0 -274
- package/dist/AvatarClient.d.ts.map +0 -1
- package/dist/AvatarClient.js +0 -712
- package/dist/AvatarClient.js.map +0 -1
- package/dist/createAvatar.d.ts +0 -135
- package/dist/createAvatar.d.ts.map +0 -1
- package/dist/createAvatar.js +0 -75
- package/dist/createAvatar.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -34
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js +0 -56
- package/dist/internal.js.map +0 -1
- package/dist/playout.d.ts +0 -42
- package/dist/playout.d.ts.map +0 -1
- package/dist/playout.js +0 -85
- package/dist/playout.js.map +0 -1
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/supports.d.ts +0 -19
- package/dist/supports.d.ts.map +0 -1
- package/dist/supports.js +0 -25
- package/dist/supports.js.map +0 -1
- package/dist/three/assets.d.ts +0 -10
- package/dist/three/assets.d.ts.map +0 -1
- package/dist/three/assets.js +0 -23
- package/dist/three/assets.js.map +0 -1
- package/dist/three/budgets.d.ts +0 -17
- package/dist/three/budgets.d.ts.map +0 -1
- package/dist/three/budgets.js +0 -21
- package/dist/three/budgets.js.map +0 -1
- package/dist/three/character-rig.d.ts +0 -366
- package/dist/three/character-rig.d.ts.map +0 -1
- package/dist/three/character-rig.js +0 -1644
- package/dist/three/character-rig.js.map +0 -1
- package/dist/three/createCharacter.d.ts +0 -60
- package/dist/three/createCharacter.d.ts.map +0 -1
- package/dist/three/createCharacter.js +0 -84
- package/dist/three/createCharacter.js.map +0 -1
- package/dist/three/holds.d.ts +0 -38
- package/dist/three/holds.d.ts.map +0 -1
- package/dist/three/holds.js +0 -61
- package/dist/three/holds.js.map +0 -1
- package/dist/three/internal.d.ts +0 -52
- package/dist/three/internal.d.ts.map +0 -1
- package/dist/three/internal.js +0 -49
- package/dist/three/internal.js.map +0 -1
- package/dist/three/motion-limits.json +0 -124
- package/dist/three/sequences.d.ts +0 -71
- package/dist/three/sequences.d.ts.map +0 -1
- package/dist/three/sequences.js +0 -262
- package/dist/three/sequences.js.map +0 -1
- package/dist/three/tanvi-asset.d.ts +0 -7
- package/dist/three/tanvi-asset.d.ts.map +0 -1
- package/dist/three/tanvi-asset.js +0 -7
- package/dist/three/tanvi-asset.js.map +0 -1
- package/dist/three/tanvi.d.ts +0 -24
- package/dist/three/tanvi.d.ts.map +0 -1
- package/dist/three/tanvi.js +0 -24
- package/dist/three/tanvi.js.map +0 -1
- package/dist/three/tanya-asset.d.ts +0 -7
- package/dist/three/tanya-asset.d.ts.map +0 -1
- package/dist/three/tanya-asset.js +0 -7
- package/dist/three/tanya-asset.js.map +0 -1
- package/dist/three/tanya.d.ts +0 -23
- package/dist/three/tanya.d.ts.map +0 -1
- package/dist/three/tanya.js +0 -23
- package/dist/three/tanya.js.map +0 -1
- package/dist/three/tara-asset.d.ts +0 -26
- package/dist/three/tara-asset.d.ts.map +0 -1
- package/dist/three/tara-asset.js +0 -26
- package/dist/three/tara-asset.js.map +0 -1
- package/dist/three/tara.d.ts +0 -30
- package/dist/three/tara.d.ts.map +0 -1
- package/dist/three/tara.js +0 -30
- package/dist/three/tara.js.map +0 -1
- package/dist/three/tess-asset.d.ts +0 -7
- package/dist/three/tess-asset.d.ts.map +0 -1
- package/dist/three/tess-asset.js +0 -7
- package/dist/three/tess-asset.js.map +0 -1
- package/dist/three/tess.d.ts +0 -24
- package/dist/three/tess.d.ts.map +0 -1
- package/dist/three/tess.js +0 -24
- package/dist/three/tess.js.map +0 -1
- package/dist/three/tushar-asset.d.ts +0 -7
- package/dist/three/tushar-asset.d.ts.map +0 -1
- package/dist/three/tushar-asset.js +0 -7
- package/dist/three/tushar-asset.js.map +0 -1
- package/dist/three/tushar.d.ts +0 -22
- package/dist/three/tushar.d.ts.map +0 -1
- package/dist/three/tushar.js +0 -22
- package/dist/three/tushar.js.map +0 -1
- package/dist/types.d.ts +0 -149
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -140
- package/dist/types.js.map +0 -1
- package/dist/useAvatar.d.ts +0 -39
- package/dist/useAvatar.d.ts.map +0 -1
- package/dist/useAvatar.js +0 -35
- package/dist/useAvatar.js.map +0 -1
- package/src/avatar.d.ts +0 -436
- package/src/avatar.js +0 -1378
- package/src/behavior.d.ts +0 -42
- package/src/behavior.js +0 -114
- package/src/camera.js +0 -29
- package/src/clips.js +0 -155
- package/src/conformance.js +0 -119
- package/src/emotions.js +0 -58
- package/src/face-core.js +0 -180
- package/src/face-myna.d.ts +0 -7
- package/src/face-myna.js +0 -786
- package/src/face-peep-control-plane.js +0 -167
- package/src/face-peep.d.ts +0 -7
- package/src/face-peep.js +0 -925
- package/src/face-wren.d.ts +0 -7
- package/src/face-wren.js +0 -468
- package/src/faces.d.ts +0 -12
- package/src/faces.js +0 -53
- package/src/gaze.js +0 -504
- package/src/hand.js +0 -709
- package/src/head.js +0 -134
- package/src/idle.js +0 -668
- package/src/interjections.js +0 -747
- package/src/line-art.js +0 -137
- package/src/params.js +0 -180
- package/src/perform.js +0 -107
- package/src/prosody.js +0 -741
- package/src/rig.d.ts +0 -31
- package/src/rig.js +0 -32
- package/src/speech-timing.js +0 -51
- package/src/visemes.js +0 -410
package/client/createAvatar.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `createAvatar` — the entire public surface of an avatar.
|
|
3
|
-
*
|
|
4
|
-
* const avatar = createAvatar({ mount: el, client: pipecatClient });
|
|
5
|
-
* // …
|
|
6
|
-
* avatar.destroy();
|
|
7
|
-
*
|
|
8
|
-
* An avatar is an embodiment of a `PipecatClient`. You hand it a mount and a
|
|
9
|
-
* live client; it subscribes and reacts. There is nothing else: no methods to
|
|
10
|
-
* drive it, no callbacks to observe it, no state to read back. Everything it
|
|
11
|
-
* needs to know is already on the wire — Pipecat's factual lifecycle events
|
|
12
|
-
* plus the avatar server-message envelope (docs/contract-wire.md).
|
|
13
|
-
*
|
|
14
|
-
* ## This is also the extension point
|
|
15
|
-
*
|
|
16
|
-
* There is no registry, no loader and no plug-in system. **You add an avatar by
|
|
17
|
-
* publishing a module that exports `createAvatar` with this signature**, and
|
|
18
|
-
* importing yours instead of ours:
|
|
19
|
-
*
|
|
20
|
-
* import { createAvatar } from "@acme/our-mascot";
|
|
21
|
-
*
|
|
22
|
-
* That is the whole mechanism, and it is deliberate. A registry would make us
|
|
23
|
-
* own resolution, versioning and asset paths for code we have never seen; a
|
|
24
|
-
* renderer interface would make us commit to a second public contract before we
|
|
25
|
-
* know what the second renderer actually needs. An ES module export we get for
|
|
26
|
-
* free from the platform.
|
|
27
|
-
*
|
|
28
|
-
* Everything past `mount` and `client` belongs to the implementation. Ours takes
|
|
29
|
-
* `SvgAvatarOptions`; yours takes whatever it likes, and `AvatarFactory<O>` is
|
|
30
|
-
* generic so the caller still gets your options checked.
|
|
31
|
-
*
|
|
32
|
-
* ## What an implementation owes the caller
|
|
33
|
-
*
|
|
34
|
-
* Only that `destroy()` leaves the mount as it found it and unsubscribes from
|
|
35
|
-
* the client. Not returning to rest, not honouring every action, not even
|
|
36
|
-
* having a mouth — a handless, mouthless avatar that only changes colour is a
|
|
37
|
-
* conforming avatar. The obligations that *matter* are perceptual, not typed,
|
|
38
|
-
* and they live in docs/contract-behavior.md.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
import type { PipecatClient } from "@pipecat-ai/client-js";
|
|
42
|
-
import { createAvatar as createSvgWidget } from "../src/avatar.js";
|
|
43
|
-
import type { Face, FaceTheme, Gain, HandSide } from "../src/avatar.js";
|
|
44
|
-
import type { BehaviorStateId } from "../src/behavior.js";
|
|
45
|
-
import { peep } from "../src/face-peep.js";
|
|
46
|
-
import { AvatarClient } from "./AvatarClient.js";
|
|
47
|
-
|
|
48
|
-
export type { Face, FaceTheme, Gain, HandSide };
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* What every `createAvatar` takes. Implementations extend it with their own
|
|
52
|
-
* options; the two named here are the only ones the caller can count on.
|
|
53
|
-
*/
|
|
54
|
-
export interface AvatarOptions {
|
|
55
|
-
/** The element to render into. The implementation owns its contents. */
|
|
56
|
-
readonly mount: HTMLElement;
|
|
57
|
-
/**
|
|
58
|
-
* A live `PipecatClient`. Required, and not nullable: an avatar with nothing
|
|
59
|
-
* to embody has no reason to exist yet. React callers get the forgiving
|
|
60
|
-
* version — `<Avatar>` waits for a non-null client before mounting.
|
|
61
|
-
*/
|
|
62
|
-
readonly client: PipecatClient;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** What every `createAvatar` returns. */
|
|
66
|
-
export interface AvatarInstance {
|
|
67
|
-
/** Unsubscribe from the client and remove everything from the mount. */
|
|
68
|
-
destroy(): void;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The shape a third-party avatar module exports, parameterised by its own
|
|
73
|
-
* options so a caller passing them gets them checked. `AvatarFactory` bare is
|
|
74
|
-
* the common denominator — the two options everyone shares.
|
|
75
|
-
*/
|
|
76
|
-
export type AvatarFactory<O extends AvatarOptions = AvatarOptions> =
|
|
77
|
-
(options: O) => AvatarInstance;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* What a mounted avatar answers to — the one *optional* export beside
|
|
81
|
-
* `createAvatar`.
|
|
82
|
-
*
|
|
83
|
-
* A page that drives an avatar has a problem an ordinary consumer does not.
|
|
84
|
-
* The wire's action id is open and an unknown one is ignored in silence
|
|
85
|
-
* (docs/contract-wire.md § Action), which is right for a protocol and useless
|
|
86
|
-
* for a control surface: a button per name cannot tell "this face has no such
|
|
87
|
-
* motion" from "nothing happened". This is the avatar answering that question
|
|
88
|
-
* for a driving UI, and nothing else reads it — `createAvatar` does not take
|
|
89
|
-
* it, the library never consults it, and an avatar that omits it is fully
|
|
90
|
-
* conforming. It is a *declaration*: nobody verifies it, so a list that has
|
|
91
|
-
* drifted from the drawing is a bug in the avatar and not something the
|
|
92
|
-
* library can catch.
|
|
93
|
-
*/
|
|
94
|
-
export interface AvatarSupport {
|
|
95
|
-
/**
|
|
96
|
-
* Every action id this avatar answers to, the two required ones included.
|
|
97
|
-
* An id absent from here is a documented no-op, never an error.
|
|
98
|
-
*/
|
|
99
|
-
readonly actions: readonly string[];
|
|
100
|
-
/**
|
|
101
|
-
* Which of the nine states this avatar draws *distinguishably*.
|
|
102
|
-
*
|
|
103
|
-
* Every avatar must accept all nine; a renderer that draws `CANT_HEAR` as
|
|
104
|
-
* ordinary listening is conforming (docs/contract-behavior.md). So this is
|
|
105
|
-
* the narrower claim — which of them a reviewer can expect to tell apart on
|
|
106
|
-
* the face — and omitting it claims all nine, which is what every avatar in
|
|
107
|
-
* this repo does.
|
|
108
|
-
*/
|
|
109
|
-
readonly states?: readonly BehaviorStateId[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** The bundled avatars' own `supports` value is in `supports.ts`, not here: it
|
|
113
|
-
* is a value, so this module's `peep` import would follow it into the bundle of
|
|
114
|
-
* anything that read it — including the canvas avatars, which draw no SVG face. */
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Options for the bundled SVG avatars — ours alone; nothing outside this
|
|
118
|
-
* package reads them.
|
|
119
|
-
*
|
|
120
|
-
* `face` is a value, not a name: a name needs a table, and a table needs every
|
|
121
|
-
* face imported to answer any lookup. Import the one you want and the other two
|
|
122
|
-
* never enter your bundle.
|
|
123
|
-
*
|
|
124
|
-
* import { createAvatar } from "@voqalize/avatar";
|
|
125
|
-
* import { wren } from "@voqalize/avatar/faces/wren";
|
|
126
|
-
*
|
|
127
|
-
* createAvatar({ mount, client, face: wren });
|
|
128
|
-
*/
|
|
129
|
-
export interface SvgAvatarOptions extends AvatarOptions {
|
|
130
|
-
/** Defaults to `peep`, the face this entry point already carries. */
|
|
131
|
-
readonly face?: Face;
|
|
132
|
-
/** Palette for that face. Its keys are the face's own; see `THEME` in its
|
|
133
|
-
* module, and CLAUDE.md on why `peep` has exactly one. */
|
|
134
|
-
readonly theme?: FaceTheme;
|
|
135
|
-
/** Viseme amplitude, 0..2. `1` is as authored. */
|
|
136
|
-
readonly mouthGain?: Gain;
|
|
137
|
-
/** Gesture-clip amplitude, 0..2. */
|
|
138
|
-
readonly gestureGain?: Gain;
|
|
139
|
-
/** Idle/liveness amplitude, 0..2. Low by design — see CLAUDE.md. */
|
|
140
|
-
readonly motionGain?: Gain;
|
|
141
|
-
/** Render the frame-edge hand at all. Default true. */
|
|
142
|
-
readonly hand?: boolean;
|
|
143
|
-
/** `1` puts it on the viewer's right, `-1` the other side. */
|
|
144
|
-
readonly handSide?: HandSide;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const GAINS = ["mouthGain", "gestureGain", "motionGain"] as const;
|
|
148
|
-
|
|
149
|
-
export function createAvatar(options: SvgAvatarOptions): AvatarInstance {
|
|
150
|
-
const { mount, client, face = peep, ...rest } = options;
|
|
151
|
-
if (!mount) throw new TypeError("createAvatar: `mount` is required");
|
|
152
|
-
if (!client) throw new TypeError("createAvatar: `client` is required");
|
|
153
|
-
// The one range TypeScript cannot state, checked where it is cheapest to fix:
|
|
154
|
-
// at construction, by the caller who typed the number.
|
|
155
|
-
for (const key of GAINS) {
|
|
156
|
-
const g = rest[key];
|
|
157
|
-
if (g === undefined) continue;
|
|
158
|
-
if (!Number.isFinite(g) || g < 0 || g > 2) {
|
|
159
|
-
throw new RangeError(`createAvatar: \`${key}\` must be 0..2, got ${String(g)}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const widget = createSvgWidget({ mount, face, ...rest });
|
|
164
|
-
const driver = new AvatarClient(widget);
|
|
165
|
-
const detach = driver.attach(client);
|
|
166
|
-
|
|
167
|
-
let destroyed = false;
|
|
168
|
-
return {
|
|
169
|
-
destroy() {
|
|
170
|
-
if (destroyed) return;
|
|
171
|
-
destroyed = true;
|
|
172
|
-
detach();
|
|
173
|
-
driver.destroy();
|
|
174
|
-
widget.destroy();
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
package/client/index.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@voqalize/avatar` — a talking head that embodies a `PipecatClient`.
|
|
3
|
-
*
|
|
4
|
-
* import { createAvatar } from "@voqalize/avatar";
|
|
5
|
-
*
|
|
6
|
-
* const avatar = createAvatar({ mount: el, client: pipecatClient });
|
|
7
|
-
*
|
|
8
|
-
* That is the whole public surface. Put an `AvatarProcessor` in the pipecat
|
|
9
|
-
* pipeline (`pip install voqalize-avatar`), mount this in the bot's tile, and
|
|
10
|
-
* the face listens, thinks, claims the floor and lipsyncs what the TTS says.
|
|
11
|
-
*
|
|
12
|
-
* Entry points, and the split is the design rather than packaging taste:
|
|
13
|
-
*
|
|
14
|
-
* - `@voqalize/avatar` — this one. Framework-free. `@pipecat-ai/client-js` is
|
|
15
|
-
* a type-only import, so even that peer is genuinely optional at runtime.
|
|
16
|
-
* It carries exactly one drawing: `peep`, the default face.
|
|
17
|
-
* - `@voqalize/avatar/faces/{peep,wren,myna}` — one drawing each. Import the
|
|
18
|
-
* one you want and pass it as `face`; the others never enter your bundle.
|
|
19
|
-
* - `@voqalize/avatar/react` — `<Avatar>`. Pulls React; nothing here does.
|
|
20
|
-
* - `@voqalize/avatar/internal` — the SVG widget, the behavior catalog and the
|
|
21
|
-
* viseme clock. **No semver promise**: these move in any minor. They are
|
|
22
|
-
* exported because an avatar author building on our renderer needs them, not
|
|
23
|
-
* because they are an interface.
|
|
24
|
-
*
|
|
25
|
-
* To ship your own avatar, publish a module exporting `createAvatar` and import
|
|
26
|
-
* that instead — see `createAvatar.ts` and docs/design-avatar-interface.md. A
|
|
27
|
-
* module may also export `supports`, which is how a page that *drives* an
|
|
28
|
-
* avatar learns which action ids this one answers to; every consumer that only
|
|
29
|
-
* mounts a face can ignore it.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
export { createAvatar } from "./createAvatar.js";
|
|
33
|
-
export { supports } from "./supports.js";
|
|
34
|
-
export type {
|
|
35
|
-
AvatarOptions,
|
|
36
|
-
AvatarInstance,
|
|
37
|
-
AvatarFactory,
|
|
38
|
-
AvatarSupport,
|
|
39
|
-
SvgAvatarOptions,
|
|
40
|
-
Face,
|
|
41
|
-
FaceTheme,
|
|
42
|
-
Gain,
|
|
43
|
-
HandSide,
|
|
44
|
-
} from "./createAvatar.js";
|
package/client/internal.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@voqalize/avatar/internal` — the parts of our own implementation that
|
|
3
|
-
* another avatar can build on.
|
|
4
|
-
*
|
|
5
|
-
* **Nothing here is covered by semver.** Names, signatures and semantics move
|
|
6
|
-
* in any minor release. It is exported because an avatar author who wants the
|
|
7
|
-
* SVG mixer, the behavior catalog or — most usefully — the viseme clock should
|
|
8
|
-
* not have to vendor a copy, not because any of it is an interface. The
|
|
9
|
-
* interface is `createAvatar`, and it is one function.
|
|
10
|
-
*
|
|
11
|
-
* The one thing here worth reaching for on purpose is `VisemeTrack`: someone
|
|
12
|
-
* has to turn a cue array plus a clock into "which mouth shape is on screen
|
|
13
|
-
* right now", every renderer needs exactly that, and it is a solved problem.
|
|
14
|
-
*
|
|
15
|
-
* const track = new VisemeTrack();
|
|
16
|
-
* track.start(cues, () => performance.now() - t0);
|
|
17
|
-
* // per frame:
|
|
18
|
-
* const s = track.sample(); // { letter: "D", intensity: 1, phone: "OW" } | null
|
|
19
|
-
*
|
|
20
|
-
* `docs/internal-rig.md` describes the pose-channel model the bundled SVG
|
|
21
|
-
* renderer uses internally. It is *not* the seam to implement — see
|
|
22
|
-
* docs/design-avatar-interface.md.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
// The bundled SVG widget. Not the faces: importing one from here would put
|
|
27
|
-
// all three in every bundle that wanted the viseme clock.
|
|
28
|
-
// `@voqalize/avatar/faces/<name>` is where a face comes from.
|
|
29
|
-
createAvatar as createSvgAvatar,
|
|
30
|
-
// The pose space a custom `rig` is handed on every frame, and the rests it is
|
|
31
|
-
// measured against.
|
|
32
|
-
REST,
|
|
33
|
-
CHANNELS,
|
|
34
|
-
RANGE,
|
|
35
|
-
STATES,
|
|
36
|
-
STATE_NAMES,
|
|
37
|
-
ACTIONS,
|
|
38
|
-
ACTION_IDS,
|
|
39
|
-
GAZE_NAMES,
|
|
40
|
-
GAZE_TARGETS,
|
|
41
|
-
EMOTION_NAMES,
|
|
42
|
-
// The viseme clock and its tables.
|
|
43
|
-
VisemeTrack,
|
|
44
|
-
VISEME_LETTERS,
|
|
45
|
-
VISEME_SHAPES,
|
|
46
|
-
SILENT,
|
|
47
|
-
LEAD_MS,
|
|
48
|
-
// The body's share of a held tilt, for a page driving a rig by hand.
|
|
49
|
-
SHOULDER_TILT,
|
|
50
|
-
// Stepping a gesture by hand: the catalogue, the player, and the smoothing
|
|
51
|
-
// law the mixer puts between a clip's keyframes and the face. A filmstrip
|
|
52
|
-
// instrument needs all three, and the one thing it must not do is fork the
|
|
53
|
-
// smoothing — that is the part a keyframe is authored against
|
|
54
|
-
// (docs/internal-mixer.md § Smoothing).
|
|
55
|
-
INTERNAL_CLIPS,
|
|
56
|
-
ClipPlayer,
|
|
57
|
-
TAU,
|
|
58
|
-
clamp,
|
|
59
|
-
approach,
|
|
60
|
-
// Posing a face directly, with no mixer, no clock and no client above it —
|
|
61
|
-
// what a pose sheet or a rig-conformance page does. `makeParams` fills the
|
|
62
|
-
// rests around a handful of overrides, `emotionPose` names a familiar set of
|
|
63
|
-
// them, `avatarFrame` wraps the result and `createSvgRig(face)` draws it.
|
|
64
|
-
makeParams,
|
|
65
|
-
emotionPose,
|
|
66
|
-
avatarFrame,
|
|
67
|
-
createSvgRig,
|
|
68
|
-
shapeFor,
|
|
69
|
-
// The one number that says how far the mandible falls for a given aperture.
|
|
70
|
-
// Anything composing a mouth pose without `shapeFor` — a retarget, a driver —
|
|
71
|
-
// needs it, and the amplitudes behind the lips are calibrated at it.
|
|
72
|
-
JAW_OF_OPEN,
|
|
73
|
-
normalizeCues,
|
|
74
|
-
textToCues,
|
|
75
|
-
ARPABET_TO_VISEME,
|
|
76
|
-
AZURE_VISEME_TO_LETTER,
|
|
77
|
-
} from "../src/avatar.js";
|
|
78
|
-
|
|
79
|
-
export type {
|
|
80
|
-
Clip,
|
|
81
|
-
ClipSample,
|
|
82
|
-
AvatarApi,
|
|
83
|
-
AvatarStateName,
|
|
84
|
-
AvatarActionId,
|
|
85
|
-
AvatarGazeName,
|
|
86
|
-
AvatarEmotionName,
|
|
87
|
-
AvatarAction,
|
|
88
|
-
AvatarMeta,
|
|
89
|
-
VisemeLetter,
|
|
90
|
-
Cue,
|
|
91
|
-
PoseChannel,
|
|
92
|
-
PoseOverrides,
|
|
93
|
-
CreateAvatarOptions as CreateSvgAvatarOptions,
|
|
94
|
-
} from "../src/avatar.js";
|
|
95
|
-
|
|
96
|
-
// The rig contract, for a renderer that implements `apply(frame)` directly
|
|
97
|
-
// instead of wearing the SVG adapter. `docs/internal-rig.md` — and note that
|
|
98
|
-
// this is the mixer's private seam, not the avatar interface.
|
|
99
|
-
export type {
|
|
100
|
-
AvatarFrame,
|
|
101
|
-
AvatarRig,
|
|
102
|
-
AvatarRigFactory,
|
|
103
|
-
HandFrame,
|
|
104
|
-
RigPose,
|
|
105
|
-
} from "../src/rig.js";
|
|
106
|
-
|
|
107
|
-
export {
|
|
108
|
-
BEHAVIOR_STATE_IDS,
|
|
109
|
-
BEHAVIOR_ACTIONS,
|
|
110
|
-
BEHAVIOR_ACTION_IDS,
|
|
111
|
-
WIRE_ACTION_TO_BEHAVIOR,
|
|
112
|
-
} from "../src/behavior.js";
|
|
113
|
-
|
|
114
|
-
export type { BehaviorStateId, BehaviorActionId } from "../src/behavior.js";
|
|
115
|
-
|
|
116
|
-
export { isAvatarMessage, CORE_ACTION_IDS } from "./types.js";
|
|
117
|
-
// The optional driving-UI declaration, as a type only. The bundled avatar's own
|
|
118
|
-
// `supports` value lives on the public entry point and importing it here would
|
|
119
|
-
// drag `peep`'s drawing in behind it — the same reason the faces are not
|
|
120
|
-
// exported from this module. Compose yours from `CORE_ACTION_IDS` and
|
|
121
|
-
// `ACTION_IDS` above, which cost nothing.
|
|
122
|
-
export type { AvatarSupport } from "./createAvatar.js";
|
|
123
|
-
// A renderer may reuse the one lifecycle/precedence ladder without gaining a
|
|
124
|
-
// second public avatar interface.
|
|
125
|
-
export { AvatarClient } from "./AvatarClient.js";
|
|
126
|
-
export type {
|
|
127
|
-
AvatarCommand,
|
|
128
|
-
AvatarCue,
|
|
129
|
-
AvatarCuesCmd,
|
|
130
|
-
CoreActionId,
|
|
131
|
-
} from "./types.js";
|
|
132
|
-
export type { AvatarClientOptions, AvatarDriver, AvatarPresenceState } from "./AvatarClient.js";
|
package/client/playout.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When the bot's audio actually begins, heard on the track the browser plays.
|
|
3
|
-
*
|
|
4
|
-
* `BotStartedSpeaking` and the audio reach the browser by different roads —
|
|
5
|
-
* the event on the data channel, the sound over RTP and through a jitter
|
|
6
|
-
* buffer — so the event is a statement about *which* audio is starting and
|
|
7
|
-
* not about when anyone hears it. Measured on two stacks, the event arrived
|
|
8
|
-
* 57 ms after the first sample on one and 160 ms before it on the other: the
|
|
9
|
-
* mouth lagged the voice on the first and ran ahead of it on the second, and
|
|
10
|
-
* no constant corrects both. So the turn clock is anchored to the sound.
|
|
11
|
-
*
|
|
12
|
-
* What makes "the sound began" observable is that between turns the decoded
|
|
13
|
-
* track is exact digital zero — Opus decodes silence to silence — so onset is
|
|
14
|
-
* the first sample off zero, not a speech detector's guess at a threshold. That
|
|
15
|
-
* matters: cue `t: 0` is the first sample the TTS produced, lead-in included,
|
|
16
|
-
* and a detector keyed to *speech* would anchor 20-50 ms into the lead-in.
|
|
17
|
-
*
|
|
18
|
-
* What this probe hears is the sound entering the page's audio graph, not
|
|
19
|
-
* leaving the speaker. For a wired speaker the difference is about what the
|
|
20
|
-
* compositor and display add to the picture, and the two cancel. A Bluetooth
|
|
21
|
-
* headset adds 150-250 ms that nothing on the picture side matches, so the
|
|
22
|
-
* probe also reports the device latency the browser admits to, and the
|
|
23
|
-
* client delays the mouth by the excess (`AvatarClient.ts`).
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export interface PlayoutProbe {
|
|
27
|
-
/**
|
|
28
|
-
* Where the bot's current sound began, on the caller's `now()` clock.
|
|
29
|
-
* `null`: the track is silent right now. `undefined`: this probe cannot say —
|
|
30
|
-
* the track has been sounding for longer than it can look back, or the
|
|
31
|
-
* audio graph is not running.
|
|
32
|
-
*/
|
|
33
|
-
onset(): number | null | undefined;
|
|
34
|
-
/** The output device's latency as this context reports it, in ms; 0 when it
|
|
35
|
-
* will not say. The probe shares the device the call's audio plays on. */
|
|
36
|
-
outputLatencyMs?(): number;
|
|
37
|
-
/** Ask a suspended graph to run. A browser that needs a gesture for it
|
|
38
|
-
* ignores the request outside one, so this is safe to call at any time. */
|
|
39
|
-
resume?(): void;
|
|
40
|
-
dispose(): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** 8192 samples is 170 ms at 48 kHz: past the 57 ms the sound has been seen to
|
|
44
|
-
* lead the event by, with room for a slower network. */
|
|
45
|
-
const WINDOW = 8192;
|
|
46
|
-
/** -80 dBFS. The gaps between turns are exact zero; this only keeps a
|
|
47
|
-
* denormal from reading as speech. */
|
|
48
|
-
const FLOOR = 1e-4;
|
|
49
|
-
|
|
50
|
-
export function createPlayoutProbe(track: MediaStreamTrack, now: () => number): PlayoutProbe | null {
|
|
51
|
-
const Ctx = globalThis.AudioContext;
|
|
52
|
-
if (!Ctx) return null;
|
|
53
|
-
let ctx: AudioContext;
|
|
54
|
-
let source: MediaStreamAudioSourceNode;
|
|
55
|
-
let analyser: AnalyserNode;
|
|
56
|
-
try {
|
|
57
|
-
ctx = new Ctx();
|
|
58
|
-
source = ctx.createMediaStreamSource(new MediaStream([track]));
|
|
59
|
-
analyser = ctx.createAnalyser();
|
|
60
|
-
analyser.fftSize = WINDOW;
|
|
61
|
-
source.connect(analyser);
|
|
62
|
-
} catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
// A context made after the user's connect click is allowed to run; one that
|
|
66
|
-
// is not simply answers `undefined`, and the event anchors the turn.
|
|
67
|
-
ctx.resume().catch(() => {});
|
|
68
|
-
const buf = new Float32Array(WINDOW);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
onset() {
|
|
72
|
-
if (ctx.state !== "running") return undefined;
|
|
73
|
-
analyser.getFloatTimeDomainData(buf);
|
|
74
|
-
const t = now();
|
|
75
|
-
let first = -1;
|
|
76
|
-
for (let i = 0; i < buf.length; i++) {
|
|
77
|
-
if (Math.abs(buf[i]!) > FLOOR) { first = i; break; }
|
|
78
|
-
}
|
|
79
|
-
if (first < 0) return null;
|
|
80
|
-
if (first === 0) return undefined;
|
|
81
|
-
return t - ((buf.length - first) / ctx.sampleRate) * 1000;
|
|
82
|
-
},
|
|
83
|
-
outputLatencyMs() {
|
|
84
|
-
const s = ctx.outputLatency;
|
|
85
|
-
return typeof s === "number" && Number.isFinite(s) ? s * 1000 : 0;
|
|
86
|
-
},
|
|
87
|
-
resume() {
|
|
88
|
-
if (ctx.state === "suspended") ctx.resume().catch(() => {});
|
|
89
|
-
},
|
|
90
|
-
dispose() {
|
|
91
|
-
source.disconnect();
|
|
92
|
-
ctx.close().catch(() => {});
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
package/client/react.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@voqalize/avatar/react` — the avatar as one component.
|
|
3
|
-
*
|
|
4
|
-
* import { Avatar } from "@voqalize/avatar/react";
|
|
5
|
-
*
|
|
6
|
-
* <Avatar client={session.client} className="avatar-tile" />
|
|
7
|
-
*
|
|
8
|
-
* Separate from the main entry so that `createAvatar` costs nothing to a
|
|
9
|
-
* caller who is not on React — React is an optional peer, and a barrel that
|
|
10
|
-
* re-exported this would make it a hard one.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export { Avatar, type AvatarProps } from "./Avatar.js";
|
package/client/supports.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `supports` for every avatar this package ships.
|
|
3
|
-
*
|
|
4
|
-
* It is one constant and one file because they are one renderer: every avatar
|
|
5
|
-
* mounts the same mixer with the same clip library, so a second list would be
|
|
6
|
-
* the same list with a second chance to be wrong. It is not in
|
|
7
|
-
* `createAvatar.ts`, where the type is documented, because a value is imported
|
|
8
|
-
* for real — reading it from there would pull `peep`'s drawing into every
|
|
9
|
-
* consumer's bundle.
|
|
10
|
-
*
|
|
11
|
-
* The two required ids first, then this renderer's own catalogue. `ACTION_IDS`
|
|
12
|
-
* already carries `RESPONSE_INTERRUPTED` as this renderer's shape for it, so
|
|
13
|
-
* the join dedupes rather than concatenating, and `ACKNOWLEDGE` is the one name
|
|
14
|
-
* here with no clip behind it because `action()` resolves it on the floor
|
|
15
|
-
* (docs/internal-mixer.md § Actions).
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { ACTION_IDS } from "../src/avatar.js";
|
|
19
|
-
import type { AvatarSupport } from "./createAvatar.js";
|
|
20
|
-
import { CORE_ACTION_IDS } from "./types.js";
|
|
21
|
-
|
|
22
|
-
export const supports: AvatarSupport = Object.freeze({
|
|
23
|
-
actions: Object.freeze([
|
|
24
|
-
...CORE_ACTION_IDS,
|
|
25
|
-
...ACTION_IDS.filter((id) => !(CORE_ACTION_IDS as readonly string[]).includes(id)),
|
|
26
|
-
]),
|
|
27
|
-
});
|
package/client/three/assets.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every compiled character as one table — for a page that enumerates them.
|
|
3
|
-
*
|
|
4
|
-
* Each URL lives in its own module (`tara-asset.ts` and its siblings) and this
|
|
5
|
-
* file only gathers them, because a bundler emits assets per module: anything
|
|
6
|
-
* importing *this* ships every GLB, which is right for a rig instrument that
|
|
7
|
-
* switches between characters and wrong for a consumer who mounted one.
|
|
8
|
-
* So the character modules never import this — they import their own — and the
|
|
9
|
-
* only reader is `/internal/three`, a separate entry point that ships nothing.
|
|
10
|
-
*/
|
|
11
|
-
import { TANYA_GLB } from "./tanya-asset.js";
|
|
12
|
-
import { TANVI_GLB } from "./tanvi-asset.js";
|
|
13
|
-
import { TESS_GLB } from "./tess-asset.js";
|
|
14
|
-
import { TARA_GLB } from "./tara-asset.js";
|
|
15
|
-
import { TUSHAR_GLB } from "./tushar-asset.js";
|
|
16
|
-
|
|
17
|
-
export const ASSETS = Object.freeze({
|
|
18
|
-
tara: TARA_GLB,
|
|
19
|
-
tushar: TUSHAR_GLB,
|
|
20
|
-
tanya: TANYA_GLB,
|
|
21
|
-
tess: TESS_GLB,
|
|
22
|
-
tanvi: TANVI_GLB,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/** Every compiled character, in build order. */
|
|
26
|
-
export type CharacterName = keyof typeof ASSETS;
|
package/client/three/budgets.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** Measurable limits for one 3-D avatar at its shipping surface. */
|
|
2
|
-
export const SHIPPING_SURFACE = Object.freeze({
|
|
3
|
-
cssWidth: 400,
|
|
4
|
-
cssHeight: 300,
|
|
5
|
-
maxDevicePixelRatio: 2,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
/** Keep the physical drawing buffer inside the shipping ceiling at any mount size. */
|
|
9
|
-
export function pixelRatioFor(width: number, height: number, devicePixelRatio: number): number {
|
|
10
|
-
const maxWidth = SHIPPING_SURFACE.cssWidth * SHIPPING_SURFACE.maxDevicePixelRatio;
|
|
11
|
-
const maxHeight = SHIPPING_SURFACE.cssHeight * SHIPPING_SURFACE.maxDevicePixelRatio;
|
|
12
|
-
return Math.max(0.1, Math.min(
|
|
13
|
-
SHIPPING_SURFACE.maxDevicePixelRatio,
|
|
14
|
-
devicePixelRatio,
|
|
15
|
-
maxWidth / Math.max(1, width),
|
|
16
|
-
maxHeight / Math.max(1, height),
|
|
17
|
-
));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Crossing one of these is a failed asset/runtime review, not a suggestion. */
|
|
21
|
-
export const HARD_BUDGET = Object.freeze({
|
|
22
|
-
assetBytes: 6 * 1024 * 1024,
|
|
23
|
-
triangles: 60_000,
|
|
24
|
-
drawCalls: 30,
|
|
25
|
-
bones: 40,
|
|
26
|
-
morphTargets: 45,
|
|
27
|
-
});
|