@streamoji/aitwin 0.2.9 → 0.3.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/dist/aitwin.cjs +3 -3
- package/dist/aitwin.js +1600 -1425
- package/dist/index.d.ts +61 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare type AiTwinHandle = {
|
|
|
19
19
|
disconnect: () => Promise<void>;
|
|
20
20
|
/** Whether a voice WebSocket session is active. */
|
|
21
21
|
isConnected: () => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Live MediaStream of the bot/twin voice for recording or mixing.
|
|
24
|
+
* Null until a voice session (or TTS playback) has primed audio.
|
|
25
|
+
*/
|
|
26
|
+
getVoiceStream: () => MediaStream | null;
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
export declare class AiTwinNotFoundError extends Error {
|
|
@@ -48,6 +53,8 @@ export declare type AiTwinProps = {
|
|
|
48
53
|
* When omitted, a dev token is fetched via getAuthToken.
|
|
49
54
|
*/
|
|
50
55
|
authToken?: string;
|
|
56
|
+
/** Avatar API base (TTS, session-value, voice). Default: package `DEFAULT_API_BASE`. */
|
|
57
|
+
apiBase?: string;
|
|
51
58
|
/** TTS engine when using `assets` or `avatarId`/`faceId` (default: Cartesia). */
|
|
52
59
|
ttsEngineId?: TtsEngineId;
|
|
53
60
|
/** TTS voice id override (engine-specific). */
|
|
@@ -72,6 +79,8 @@ export declare type AiTwinProps = {
|
|
|
72
79
|
onBotOutput?: (text: string) => void;
|
|
73
80
|
/** Voice lipsync debug (viseme segments, clock, queue). */
|
|
74
81
|
onRealtimeLipsyncDebug?: (snapshot: RealtimeLipsyncDebugSnapshot) => void;
|
|
82
|
+
/** Canvas render skip stats (RIFE transitions, draw coalescing, visemes). */
|
|
83
|
+
onFrameRenderStats?: (stats: FrameRenderStatsSnapshot) => void;
|
|
75
84
|
};
|
|
76
85
|
|
|
77
86
|
export declare type AiTwinRecord = {
|
|
@@ -109,6 +118,8 @@ export declare type AvatarTtsLipsyncController = {
|
|
|
109
118
|
getStreamMood: () => string;
|
|
110
119
|
getPlaybackElapsedMs: () => number;
|
|
111
120
|
isSpeaking: () => boolean;
|
|
121
|
+
/** Live MediaStream of the synthesized voice for recording/mixing (null until audio is primed). */
|
|
122
|
+
getVoiceStream: () => MediaStream | null;
|
|
112
123
|
setPlaybackSpeed: (rate: number) => void;
|
|
113
124
|
getPlaybackSpeed: () => number;
|
|
114
125
|
subscribe: (listener: () => void) => () => void;
|
|
@@ -139,6 +150,55 @@ export declare function fetchAiTwin(id: string, baseUrl?: string): Promise<AiTwi
|
|
|
139
150
|
/** Bearer token for /avatar_ttsWithPoses and /api/session-value. */
|
|
140
151
|
export declare function fetchDevAuthToken(): Promise<string>;
|
|
141
152
|
|
|
153
|
+
export declare type FrameRenderDrawContext = {
|
|
154
|
+
label: string;
|
|
155
|
+
elapsedMs: number;
|
|
156
|
+
mouthPath: string | null;
|
|
157
|
+
transitionMeta?: FrameRenderTransitionMeta;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export declare type FrameRenderStatsSnapshot = {
|
|
161
|
+
rafTicksSpeaking: number;
|
|
162
|
+
/** Same draw key as previous RAF sample (healthy coalescing). */
|
|
163
|
+
rafTicksDeduped: number;
|
|
164
|
+
drawsRequested: number;
|
|
165
|
+
drawsDisplayed: number;
|
|
166
|
+
queueSuperseded: number;
|
|
167
|
+
workerStale: number;
|
|
168
|
+
/** Real drops: queue + worker stale + undisplayed requests. */
|
|
169
|
+
renderLoss: number;
|
|
170
|
+
visemeSlotsTotal: number;
|
|
171
|
+
visemeSlotsCovered: number;
|
|
172
|
+
visemeCoveragePct: number;
|
|
173
|
+
transitionFramesUniqueSampled: number;
|
|
174
|
+
transitionFramesUniquePainted: number;
|
|
175
|
+
transitionFramesMissed: number;
|
|
176
|
+
rifeFramesOmittedByGap: number;
|
|
177
|
+
transitionFramesSampled: number;
|
|
178
|
+
transitionFramesDisplayed: number;
|
|
179
|
+
/** @deprecated Use `rafTicksDeduped`. */
|
|
180
|
+
drawsDeduped: number;
|
|
181
|
+
/** @deprecated Use `renderLoss`. */
|
|
182
|
+
renderSkips: number;
|
|
183
|
+
/** @deprecated Use `visemeSlotsCovered`. */
|
|
184
|
+
visemesShown: number;
|
|
185
|
+
/** @deprecated Use `visemeSlotsTotal - visemeSlotsCovered`. */
|
|
186
|
+
visemesSkipped: number;
|
|
187
|
+
/** @deprecated Use `transitionFramesMissed`. */
|
|
188
|
+
rifeTransitionFramesSkipped: number;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
declare type FrameRenderTransitionMeta = {
|
|
192
|
+
from: string;
|
|
193
|
+
to: string;
|
|
194
|
+
fromVtime: number;
|
|
195
|
+
toVtime: number;
|
|
196
|
+
frameIdx: number;
|
|
197
|
+
frameCount: number;
|
|
198
|
+
fullFrameCount: number;
|
|
199
|
+
omittedByGap: number;
|
|
200
|
+
};
|
|
201
|
+
|
|
142
202
|
/** Public CDN original portrait for custom-faces/{faceId}/ (same id as pipeline avatarId). */
|
|
143
203
|
export declare function getAiTwinSourceUrl(faceId: string, cdnBase?: string, extension?: string): string;
|
|
144
204
|
|
|
@@ -268,7 +328,7 @@ export declare type VoiceConnectOptions = {
|
|
|
268
328
|
speakingRate?: number;
|
|
269
329
|
/** Default true — server streams TTS + avatar messages. */
|
|
270
330
|
ttsStream?: boolean;
|
|
271
|
-
/** HTTP API base; default `https://ai.
|
|
331
|
+
/** HTTP API base; default `https://ai.aitwin.me`. */
|
|
272
332
|
apiBase?: string;
|
|
273
333
|
/** Full WebSocket URL override. Query params must be included. */
|
|
274
334
|
wsUrl?: string;
|