@streamoji/aitwin 0.2.6 → 0.2.7
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 +3 -1
- package/dist/aitwin.cjs +2 -2
- package/dist/aitwin.js +977 -953
- package/dist/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/aitwin.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { PipecatClient as
|
|
4
|
-
import { WebSocketTransport as
|
|
5
|
-
const
|
|
6
|
-
publicBase:
|
|
7
|
-
},
|
|
8
|
-
version:
|
|
9
|
-
},
|
|
10
|
-
function
|
|
1
|
+
import { jsxs as vn, jsx as Rt } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as bn, useRef as O, useState as Be, useCallback as ae, useEffect as ve, useMemo as Dt, useImperativeHandle as Tn } from "react";
|
|
3
|
+
import { PipecatClient as An } from "@pipecat-ai/client-js";
|
|
4
|
+
import { WebSocketTransport as In, DailyMediaManager as Rn } from "@pipecat-ai/websocket-transport";
|
|
5
|
+
const Dn = "https://pub-607ad1fc22e2400eb57d17240aab857c.r2.dev", Qt = {
|
|
6
|
+
publicBase: Dn
|
|
7
|
+
}, Cn = "0.2.7", xn = {
|
|
8
|
+
version: Cn
|
|
9
|
+
}, Mn = {}, Te = "https://ai.streamoji.com", ft = `${Qt.publicBase}/custom-faces`, Pn = `${Qt.publicBase}/aitwin-workers/v${xn.version}/visemeDiffPreview.worker.js`;
|
|
10
|
+
function Bn(e) {
|
|
11
11
|
if (e) return e;
|
|
12
|
-
const t = typeof import.meta < "u" ?
|
|
13
|
-
return t?.trim() ? t.trim() :
|
|
14
|
-
}
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]),
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
},
|
|
23
|
-
google:
|
|
24
|
-
inworld:
|
|
25
|
-
cartesia:
|
|
12
|
+
const t = typeof import.meta < "u" ? Mn?.VITE_AITWIN_WORKER_URL : void 0;
|
|
13
|
+
return t?.trim() ? t.trim() : Pn;
|
|
14
|
+
}
|
|
15
|
+
const Ln = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAiTwin", Xt = "eng_a7f2b9c1", dt = "eng_d4e8f3a2", Ie = "eng_c9b1e6d4", Ae = Ie, On = /* @__PURE__ */ new Set([
|
|
16
|
+
dt,
|
|
17
|
+
Ie
|
|
18
|
+
]), Zt = {
|
|
19
|
+
[Xt]: "oculus_direct",
|
|
20
|
+
[Ie]: "oculus_direct",
|
|
21
|
+
[dt]: "inworld_word"
|
|
22
|
+
}, Ct = {
|
|
23
|
+
google: Xt,
|
|
24
|
+
inworld: dt,
|
|
25
|
+
cartesia: Ie
|
|
26
26
|
};
|
|
27
|
-
function On(e) {
|
|
28
|
-
return Xt[e];
|
|
29
|
-
}
|
|
30
27
|
function Fn(e) {
|
|
31
|
-
return e
|
|
28
|
+
return Zt[e];
|
|
32
29
|
}
|
|
33
30
|
function Un(e) {
|
|
34
|
-
|
|
31
|
+
return e === Ie;
|
|
32
|
+
}
|
|
33
|
+
function Nn(e) {
|
|
34
|
+
if (e.ttsEngineId && e.ttsEngineId in Zt)
|
|
35
35
|
return e.ttsEngineId;
|
|
36
36
|
const t = e.tts?.toLowerCase();
|
|
37
|
-
return t && t in
|
|
37
|
+
return t && t in Ct ? Ct[t] : Ae;
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class st extends Error {
|
|
40
40
|
constructor(t = "AI twin not found") {
|
|
41
41
|
super(t), this.name = "AiTwinNotFoundError";
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
async function
|
|
44
|
+
async function Vn(e, t = Ln) {
|
|
45
45
|
const n = new URL(t);
|
|
46
46
|
n.searchParams.set("id", e);
|
|
47
47
|
const r = await fetch(n.toString());
|
|
48
48
|
if (r.status === 404)
|
|
49
|
-
throw new
|
|
49
|
+
throw new st();
|
|
50
50
|
if (!r.ok)
|
|
51
51
|
throw new Error(`getAiTwin failed (${r.status})`);
|
|
52
52
|
const s = await r.json();
|
|
53
53
|
if (!s.success)
|
|
54
|
-
throw new
|
|
54
|
+
throw new st(s.error ?? "AI twin not found");
|
|
55
55
|
const { tts: i, ...o } = s.data;
|
|
56
56
|
return {
|
|
57
57
|
...o,
|
|
58
|
-
ttsEngineId:
|
|
58
|
+
ttsEngineId: Nn(s.data)
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
async function
|
|
63
|
-
const e = await fetch(
|
|
61
|
+
const $n = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAuthToken", Wn = "client_6TNvp3SCs4Og0a1ijm9TommXLql1", Hn = "kk8Fq8EmexzP10jMIEwY3R44M5RKUEm1", qn = "6TNvp3SCs4Og0a1ijm9TommXLql1", Kn = "Swaraj Mali";
|
|
62
|
+
async function nt() {
|
|
63
|
+
const e = await fetch($n, {
|
|
64
64
|
method: "POST",
|
|
65
65
|
headers: {
|
|
66
66
|
"Content-Type": "application/json",
|
|
67
|
-
"Client-Id":
|
|
68
|
-
"Client-Secret":
|
|
67
|
+
"Client-Id": Wn,
|
|
68
|
+
"Client-Secret": Hn
|
|
69
69
|
},
|
|
70
70
|
body: JSON.stringify({
|
|
71
|
-
userId:
|
|
72
|
-
userName:
|
|
71
|
+
userId: qn,
|
|
72
|
+
userName: Kn
|
|
73
73
|
})
|
|
74
74
|
});
|
|
75
75
|
if (!e.ok)
|
|
@@ -79,7 +79,7 @@ async function et() {
|
|
|
79
79
|
throw new Error("getAuthToken returned no token");
|
|
80
80
|
return n;
|
|
81
81
|
}
|
|
82
|
-
async function
|
|
82
|
+
async function jn(e, t = Te) {
|
|
83
83
|
const n = await fetch(`${t.replace(/\/$/, "")}/api/session-value`, {
|
|
84
84
|
headers: { Authorization: `Bearer ${e}` }
|
|
85
85
|
});
|
|
@@ -89,7 +89,7 @@ async function Kn(e, t = be) {
|
|
|
89
89
|
if (!r.value) throw new Error("Session value response missing value");
|
|
90
90
|
return r;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Gn(e) {
|
|
93
93
|
const t = e.trim();
|
|
94
94
|
if (t.length % 2 !== 0) throw new Error("Invalid hex key");
|
|
95
95
|
const n = new Uint8Array(t.length / 2);
|
|
@@ -97,20 +97,20 @@ function jn(e) {
|
|
|
97
97
|
n[r / 2] = Number.parseInt(t.slice(r, r + 2), 16);
|
|
98
98
|
return n;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function Ne(e) {
|
|
101
101
|
return Uint8Array.from(e);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function zn(e, t) {
|
|
104
104
|
const n = new Uint8Array(e.length + t.length);
|
|
105
105
|
return n.set(e, 0), n.set(t, e.length), n;
|
|
106
106
|
}
|
|
107
|
-
async function
|
|
107
|
+
async function Yn(e, t) {
|
|
108
108
|
if (!t) throw new Error("Asset key is required for encrypted assets");
|
|
109
109
|
if (e.byteLength < 28)
|
|
110
110
|
throw new Error("Encrypted payload too small");
|
|
111
|
-
const n = new Uint8Array(e), r =
|
|
111
|
+
const n = new Uint8Array(e), r = Ne(n.subarray(0, 12)), s = Ne(n.subarray(12, 28)), i = Ne(n.subarray(28)), o = Ne(zn(i, s)), a = await crypto.subtle.importKey(
|
|
112
112
|
"raw",
|
|
113
|
-
|
|
113
|
+
Gn(t),
|
|
114
114
|
{ name: "AES-GCM" },
|
|
115
115
|
!1,
|
|
116
116
|
["decrypt"]
|
|
@@ -121,35 +121,35 @@ async function zn(e, t) {
|
|
|
121
121
|
o
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
|
-
let
|
|
125
|
-
const
|
|
126
|
-
function
|
|
124
|
+
let it = null;
|
|
125
|
+
const ot = /* @__PURE__ */ new Set();
|
|
126
|
+
function Ve(e) {
|
|
127
127
|
return e.includes("/custom-faces/");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function He(e) {
|
|
130
130
|
const t = e.binBase.trim().replace(/\/$/, ""), n = e.twinBase.trim().replace(/\/$/, "");
|
|
131
|
-
if (!(e.encrypted ||
|
|
131
|
+
if (!(e.encrypted || Ve(t) || Ve(n)))
|
|
132
132
|
return { twinBase: n, binBase: t, encrypted: !1 };
|
|
133
|
-
const s =
|
|
133
|
+
const s = Ve(t) ? t : Ve(n) ? n : t;
|
|
134
134
|
return { twinBase: s, binBase: s, encrypted: !0 };
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
136
|
+
function Re(e) {
|
|
137
|
+
return He(e).encrypted;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function xt(e, t = ft) {
|
|
140
140
|
const n = `${t.replace(/\/$/, "")}/${e}`;
|
|
141
141
|
return { twinBase: n, binBase: n, encrypted: !0 };
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function Jn(e, t) {
|
|
144
144
|
return (e ?? t)?.trim() || void 0;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
for (const t of
|
|
146
|
+
function Qn(e) {
|
|
147
|
+
it = He(e);
|
|
148
|
+
for (const t of ot) t();
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function Xn(e, t) {
|
|
151
151
|
const n = typeof globalThis.location < "u" ? globalThis.location.href : void 0;
|
|
152
|
-
if (!n) return
|
|
152
|
+
if (!n) return He(e);
|
|
153
153
|
const r = (s) => {
|
|
154
154
|
try {
|
|
155
155
|
return new URL(s, n).href.replace(/\/$/, "");
|
|
@@ -157,44 +157,44 @@ function Qn(e, t) {
|
|
|
157
157
|
return s;
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
-
return
|
|
160
|
+
return He({
|
|
161
161
|
twinBase: r(e.twinBase),
|
|
162
162
|
binBase: r(e.binBase),
|
|
163
163
|
encrypted: e.encrypted
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
function Ee() {
|
|
167
|
-
if (!
|
|
167
|
+
if (!it)
|
|
168
168
|
throw new Error("Twin assets not configured; call setActiveTwinAssets first");
|
|
169
|
-
return
|
|
169
|
+
return it;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
171
|
+
function Zn(e) {
|
|
172
|
+
return ot.add(e), () => ot.delete(e);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function Mt() {
|
|
175
175
|
const e = Ee();
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
function Zn() {
|
|
179
|
-
const e = Ee();
|
|
180
|
-
return Ie(e) ? `${e.binBase}/idle.bin` : `${e.twinBase}/idle.mp4`;
|
|
176
|
+
return Re(e) ? `${e.binBase}/sil.bin` : `${e.twinBase}/sil.png`;
|
|
181
177
|
}
|
|
182
178
|
function er() {
|
|
183
179
|
const e = Ee();
|
|
184
|
-
return
|
|
185
|
-
}
|
|
186
|
-
function Ge() {
|
|
187
|
-
return Ie(Ee());
|
|
180
|
+
return Re(e) ? `${e.binBase}/idle.bin` : `${e.twinBase}/idle.mp4`;
|
|
188
181
|
}
|
|
189
182
|
function tr() {
|
|
190
183
|
const e = Ee();
|
|
191
|
-
return
|
|
184
|
+
return Re(e) ? e.binBase : e.twinBase;
|
|
185
|
+
}
|
|
186
|
+
function je() {
|
|
187
|
+
return Re(Ee());
|
|
192
188
|
}
|
|
193
189
|
function nr() {
|
|
194
190
|
const e = Ee();
|
|
195
|
-
return
|
|
191
|
+
return Re(e) ? `${e.binBase}/atlas.bin` : `${e.twinBase}/atlas.json`;
|
|
196
192
|
}
|
|
197
|
-
function rr(
|
|
193
|
+
function rr() {
|
|
194
|
+
const e = Ee();
|
|
195
|
+
return Re(e) ? `${e.binBase}/expression_atlas.bin` : `${e.twinBase}/expression_atlas.json`;
|
|
196
|
+
}
|
|
197
|
+
function sr(e) {
|
|
198
198
|
const t = e.split(/\r?\n/);
|
|
199
199
|
let n = "", r = "";
|
|
200
200
|
for (const i of t)
|
|
@@ -209,7 +209,7 @@ function rr(e) {
|
|
|
209
209
|
}
|
|
210
210
|
return { event: n, data: s };
|
|
211
211
|
}
|
|
212
|
-
const
|
|
212
|
+
const ir = [
|
|
213
213
|
"aa",
|
|
214
214
|
"CH",
|
|
215
215
|
"DD",
|
|
@@ -225,14 +225,14 @@ const sr = [
|
|
|
225
225
|
"kk",
|
|
226
226
|
"nn",
|
|
227
227
|
"sil"
|
|
228
|
-
],
|
|
229
|
-
|
|
228
|
+
], or = new Map(
|
|
229
|
+
ir.map((e) => [e.toLowerCase(), e])
|
|
230
230
|
);
|
|
231
|
-
function
|
|
231
|
+
function ar(e) {
|
|
232
232
|
const t = (e ?? "").trim();
|
|
233
|
-
return t ?
|
|
233
|
+
return t ? or.get(t.toLowerCase()) ?? "sil" : "sil";
|
|
234
234
|
}
|
|
235
|
-
const
|
|
235
|
+
const cr = {
|
|
236
236
|
aei: ["aa", "E", "I"],
|
|
237
237
|
o: ["O", "U"],
|
|
238
238
|
ee: ["I"],
|
|
@@ -244,12 +244,12 @@ const ar = {
|
|
|
244
244
|
qw: ["U", "O"],
|
|
245
245
|
cdgknstxyz: ["DD", "SS", "kk", "CH"]
|
|
246
246
|
};
|
|
247
|
-
function
|
|
247
|
+
function ur(e) {
|
|
248
248
|
if (!e) return ["sil"];
|
|
249
249
|
const t = e.toLowerCase();
|
|
250
|
-
return
|
|
250
|
+
return cr[t] ?? ["sil"];
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function lr(e, t) {
|
|
253
253
|
const n = e.word.length;
|
|
254
254
|
if (n <= 0) return 0;
|
|
255
255
|
const r = e.wduration;
|
|
@@ -257,33 +257,33 @@ function ur(e, t) {
|
|
|
257
257
|
const s = Math.max(0, Math.min(1, (t - e.wtime) / r));
|
|
258
258
|
return Math.min(n - 1, Math.floor(s * n));
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ge(e, t) {
|
|
261
261
|
const n = Math.max(0, Math.min(e.length - 1, t));
|
|
262
262
|
return e[n] ?? "";
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
const n = e.toLowerCase(), r =
|
|
264
|
+
function fr(e, t) {
|
|
265
|
+
const n = e.toLowerCase(), r = Ge(n, t), s = n.slice(Math.max(0, t - 1), t + 2);
|
|
266
266
|
return r === "i" || r === "y" ? "I" : s.includes("ee") || r === "e" || n.includes("ea") ? "E" : "aa";
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function dr(e, t) {
|
|
269
269
|
const n = e.toLowerCase(), r = n.slice(
|
|
270
270
|
Math.max(0, t - 1),
|
|
271
271
|
Math.min(n.length, t + 3)
|
|
272
272
|
);
|
|
273
273
|
if (/oo|ou|uw/.test(r)) return "U";
|
|
274
|
-
const s =
|
|
274
|
+
const s = Ge(n, t);
|
|
275
275
|
return s === "u" || s === "w" ? "U" : "O";
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function hr(e, t) {
|
|
278
278
|
const n = e.toLowerCase(), r = n.slice(Math.max(0, t - 2), t + 1);
|
|
279
279
|
if (/qu/.test(r)) return "U";
|
|
280
280
|
const s = n.slice(
|
|
281
281
|
Math.max(0, t - 1),
|
|
282
282
|
Math.min(n.length, t + 3)
|
|
283
283
|
);
|
|
284
|
-
return /wo|wh/.test(s) ||
|
|
284
|
+
return /wo|wh/.test(s) || Ge(n, t) === "o" ? "O" : "U";
|
|
285
285
|
}
|
|
286
|
-
const
|
|
286
|
+
const $e = {
|
|
287
287
|
d: "DD",
|
|
288
288
|
t: "DD",
|
|
289
289
|
n: "DD",
|
|
@@ -295,46 +295,46 @@ const We = {
|
|
|
295
295
|
x: "CH",
|
|
296
296
|
j: "CH"
|
|
297
297
|
};
|
|
298
|
-
function
|
|
299
|
-
const n = e.toLowerCase(), r =
|
|
300
|
-
if (
|
|
298
|
+
function mr(e, t) {
|
|
299
|
+
const n = e.toLowerCase(), r = Ge(n, t);
|
|
300
|
+
if ($e[r]) return $e[r];
|
|
301
301
|
for (let s = 0; s < n.length; s++) {
|
|
302
302
|
const i = n[s];
|
|
303
|
-
if (
|
|
303
|
+
if ($e[i]) return $e[i];
|
|
304
304
|
}
|
|
305
305
|
return "DD";
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const r =
|
|
307
|
+
function wr(e, t, n) {
|
|
308
|
+
const r = ur(e);
|
|
309
309
|
if (r.length === 1) return r[0];
|
|
310
310
|
const s = t.trim();
|
|
311
311
|
if (!s) return r[0];
|
|
312
312
|
const i = (e ?? "").toLowerCase(), o = Math.max(0, n);
|
|
313
313
|
switch (i) {
|
|
314
314
|
case "aei":
|
|
315
|
-
return lr(s, o);
|
|
316
|
-
case "o":
|
|
317
315
|
return fr(s, o);
|
|
318
|
-
case "
|
|
316
|
+
case "o":
|
|
319
317
|
return dr(s, o);
|
|
320
|
-
case "
|
|
318
|
+
case "qw":
|
|
321
319
|
return hr(s, o);
|
|
320
|
+
case "cdgknstxyz":
|
|
321
|
+
return mr(s, o);
|
|
322
322
|
default:
|
|
323
323
|
return r[0];
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
const
|
|
327
|
-
function
|
|
326
|
+
const gr = 24e3;
|
|
327
|
+
function _r(e) {
|
|
328
328
|
let t = e.trim();
|
|
329
329
|
const n = t.indexOf(",");
|
|
330
330
|
t.startsWith("data:") && n >= 0 && (t = t.slice(n + 1)), t = t.replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/");
|
|
331
331
|
const r = t.length % 4;
|
|
332
332
|
return r !== 0 && (t += "=".repeat(4 - r)), t;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function pr(e) {
|
|
335
335
|
return e.length >= 4 && e[0] === 82 && e[1] === 73 && e[2] === 70 && e[3] === 70;
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function Pt(e, t, n = gr) {
|
|
338
338
|
const r = t.byteOffset % 2 === 0 ? t : t.slice(), s = new Int16Array(
|
|
339
339
|
r.buffer,
|
|
340
340
|
r.byteOffset,
|
|
@@ -345,15 +345,15 @@ function xt(e, t, n = wr) {
|
|
|
345
345
|
const o = e.createBuffer(1, i.length, n);
|
|
346
346
|
return o.copyToChannel(i, 0), o;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
349
|
-
const t =
|
|
348
|
+
function yr(e) {
|
|
349
|
+
const t = _r(e), n = window.atob(t), r = new Uint8Array(n.length);
|
|
350
350
|
for (let s = 0; s < n.length; s++)
|
|
351
351
|
r[s] = n.charCodeAt(s);
|
|
352
352
|
return r;
|
|
353
353
|
}
|
|
354
|
-
async function
|
|
355
|
-
const n =
|
|
356
|
-
if (
|
|
354
|
+
async function Er(e, t) {
|
|
355
|
+
const n = yr(t);
|
|
356
|
+
if (pr(n)) {
|
|
357
357
|
const r = n.buffer.slice(
|
|
358
358
|
n.byteOffset,
|
|
359
359
|
n.byteOffset + n.byteLength
|
|
@@ -361,7 +361,7 @@ async function yr(e, t) {
|
|
|
361
361
|
return e.decodeAudioData(r);
|
|
362
362
|
}
|
|
363
363
|
if (n.length >= 2 && n.length % 2 === 0)
|
|
364
|
-
return
|
|
364
|
+
return Pt(e, n);
|
|
365
365
|
try {
|
|
366
366
|
const r = n.buffer.slice(
|
|
367
367
|
n.byteOffset,
|
|
@@ -369,26 +369,26 @@ async function yr(e, t) {
|
|
|
369
369
|
);
|
|
370
370
|
return await e.decodeAudioData(r);
|
|
371
371
|
} catch {
|
|
372
|
-
return
|
|
372
|
+
return Pt(e, n);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function Bt(e) {
|
|
376
376
|
let t = 0;
|
|
377
377
|
for (const n of e)
|
|
378
378
|
t = Math.max(t, n.vtime + n.vduration);
|
|
379
379
|
return t;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function Sr(e, t) {
|
|
382
382
|
for (const n of e)
|
|
383
383
|
if (t >= n.wtime && t < n.wtime + n.wduration)
|
|
384
384
|
return n;
|
|
385
385
|
return null;
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function en(e, t) {
|
|
388
388
|
const n = [], r = [];
|
|
389
|
-
let s = null, i = !1, o = !1, a = !1, f = !1, l = 0, w = 0, _ = 0, m = 0,
|
|
389
|
+
let s = null, i = !1, o = !1, a = !1, f = !1, l = 0, w = 0, _ = 0, m = 0, v = null, k = 1, u = t, p = !1;
|
|
390
390
|
const d = () => {
|
|
391
|
-
|
|
391
|
+
v != null && (clearTimeout(v), v = null);
|
|
392
392
|
}, I = () => {
|
|
393
393
|
for (const g of r)
|
|
394
394
|
try {
|
|
@@ -396,73 +396,73 @@ function Zt(e, t) {
|
|
|
396
396
|
} catch {
|
|
397
397
|
}
|
|
398
398
|
r.length = 0;
|
|
399
|
-
},
|
|
399
|
+
}, S = () => {
|
|
400
400
|
for (const g of r)
|
|
401
|
-
g.playbackRate.value =
|
|
401
|
+
g.playbackRate.value = k;
|
|
402
402
|
}, R = () => {
|
|
403
403
|
!f || i || r.length > 0 || n.length > 0 || (o = !1, d(), e.onSpeakingDone(), e.onNotify());
|
|
404
|
-
},
|
|
405
|
-
const
|
|
406
|
-
if (
|
|
404
|
+
}, q = (g) => {
|
|
405
|
+
const x = Bt(g);
|
|
406
|
+
if (x <= 0) {
|
|
407
407
|
e.onSpeakingDone(), e.onNotify();
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
410
|
o = !0, l = performance.now(), e.onSpeakingStart(), e.onNotify(), d();
|
|
411
|
-
const b =
|
|
412
|
-
|
|
413
|
-
p || (o = !1,
|
|
411
|
+
const b = k > 0 ? x / k : x;
|
|
412
|
+
v = setTimeout(() => {
|
|
413
|
+
p || (o = !1, v = null, e.onSpeakingDone(), e.onNotify());
|
|
414
414
|
}, b);
|
|
415
|
-
},
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
if (!
|
|
419
|
-
const W = Math.round((A.start ?? 0) * 1e3),
|
|
415
|
+
}, N = (g, x, b, D) => {
|
|
416
|
+
x.length !== 0 && (D && (_ = b), x.forEach((A) => {
|
|
417
|
+
const F = String(A.word ?? "").trim();
|
|
418
|
+
if (!F) return;
|
|
419
|
+
const W = Math.round((A.start ?? 0) * 1e3), G = A.duration != null ? Math.round(A.duration * 1e3) : A.end != null ? Math.max(1, Math.round((A.end - (A.start ?? 0)) * 1e3)) : 0;
|
|
420
420
|
g.push({
|
|
421
|
-
word:
|
|
421
|
+
word: F,
|
|
422
422
|
wtime: _ + W,
|
|
423
|
-
wduration:
|
|
423
|
+
wduration: G,
|
|
424
424
|
queueIndex: g.length,
|
|
425
425
|
gesture: A.gesture ?? null,
|
|
426
426
|
emphasis: A.emphasis === !0
|
|
427
427
|
});
|
|
428
428
|
}));
|
|
429
|
-
},
|
|
430
|
-
b.length !== 0 && (A && (_ = D), b.forEach((
|
|
431
|
-
const W = String(
|
|
429
|
+
}, V = (g, x, b, D, A, P) => {
|
|
430
|
+
b.length !== 0 && (A && (_ = D), b.forEach((F) => {
|
|
431
|
+
const W = String(F.symbol ?? F.viseme ?? "").trim();
|
|
432
432
|
if (!W) return;
|
|
433
|
-
const
|
|
434
|
-
let
|
|
435
|
-
if (
|
|
436
|
-
|
|
433
|
+
const G = Math.round((F.start ?? 0) * 1e3), H = Math.max(1, Math.round((F.duration ?? 0) * 1e3)), Y = _ + G;
|
|
434
|
+
let J;
|
|
435
|
+
if (Fn(P) === "oculus_direct")
|
|
436
|
+
J = ar(W);
|
|
437
437
|
else {
|
|
438
|
-
const
|
|
439
|
-
|
|
438
|
+
const he = Sr(x, Y), te = he ? lr(he, Y) : 0;
|
|
439
|
+
J = wr(
|
|
440
440
|
W,
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
he?.word ?? "",
|
|
442
|
+
te
|
|
443
443
|
);
|
|
444
444
|
}
|
|
445
445
|
g.push({
|
|
446
|
-
viseme:
|
|
446
|
+
viseme: J,
|
|
447
447
|
weight: 1,
|
|
448
|
-
vtime:
|
|
449
|
-
vduration:
|
|
448
|
+
vtime: Y,
|
|
449
|
+
vduration: H
|
|
450
450
|
});
|
|
451
451
|
}), e.onNotify());
|
|
452
|
-
},
|
|
453
|
-
|
|
452
|
+
}, z = (g, x, b, D, A, P, F) => {
|
|
453
|
+
N(x, D, A, P), V(
|
|
454
454
|
g,
|
|
455
|
-
|
|
455
|
+
x,
|
|
456
456
|
b,
|
|
457
457
|
A,
|
|
458
458
|
P,
|
|
459
|
-
|
|
459
|
+
F
|
|
460
460
|
);
|
|
461
|
-
}, y = async (g,
|
|
461
|
+
}, y = async (g, x, b, D, A, P, F) => {
|
|
462
462
|
if (p || !b?.trim()) {
|
|
463
|
-
(D.length > 0 || A.length > 0) && !a &&
|
|
463
|
+
(D.length > 0 || A.length > 0) && !a && z(
|
|
464
464
|
g,
|
|
465
|
-
|
|
465
|
+
x,
|
|
466
466
|
D,
|
|
467
467
|
A,
|
|
468
468
|
_,
|
|
@@ -484,32 +484,32 @@ function Zt(e, t) {
|
|
|
484
484
|
try {
|
|
485
485
|
const W = window.AudioContext || window.webkitAudioContext;
|
|
486
486
|
s || (s = new W());
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
const
|
|
487
|
+
const G = s;
|
|
488
|
+
G.state === "suspended" && await G.resume();
|
|
489
|
+
const H = await Er(G, b);
|
|
490
490
|
a = !0;
|
|
491
|
-
const
|
|
492
|
-
let
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
491
|
+
const Y = G.currentTime;
|
|
492
|
+
let J = m;
|
|
493
|
+
const he = !o;
|
|
494
|
+
J < Y && (J = Y + 0.1), m = J + H.duration;
|
|
495
|
+
const te = G.createBufferSource();
|
|
496
|
+
if (te.buffer = H, te.playbackRate.value = k, te.connect(G.destination), r.push(te), p) {
|
|
497
497
|
r.pop();
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
500
|
-
if (
|
|
501
|
-
o = !0, e.onSpeakingStart(), w =
|
|
502
|
-
const
|
|
503
|
-
l = performance.now() +
|
|
500
|
+
if (he) {
|
|
501
|
+
o = !0, e.onSpeakingStart(), w = J, _ = 0, g.length = 0, x.length = 0, F?.();
|
|
502
|
+
const E = (J - Y) * 1e3;
|
|
503
|
+
l = performance.now() + E;
|
|
504
504
|
}
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
},
|
|
509
|
-
const c = (
|
|
510
|
-
|
|
505
|
+
te.onended = () => {
|
|
506
|
+
const E = r.indexOf(te);
|
|
507
|
+
E >= 0 && r.splice(E, 1), R(), e.onNotify();
|
|
508
|
+
}, te.start(J);
|
|
509
|
+
const c = (J - w) * 1e3;
|
|
510
|
+
z(
|
|
511
511
|
g,
|
|
512
|
-
|
|
512
|
+
x,
|
|
513
513
|
D,
|
|
514
514
|
A,
|
|
515
515
|
c,
|
|
@@ -523,12 +523,12 @@ function Zt(e, t) {
|
|
|
523
523
|
const W = n.shift();
|
|
524
524
|
W ? await y(
|
|
525
525
|
g,
|
|
526
|
-
|
|
526
|
+
x,
|
|
527
527
|
W.audio,
|
|
528
528
|
W.visemes,
|
|
529
529
|
W.words,
|
|
530
530
|
W.isNewSegment,
|
|
531
|
-
|
|
531
|
+
F
|
|
532
532
|
) : R();
|
|
533
533
|
}
|
|
534
534
|
};
|
|
@@ -537,9 +537,9 @@ function Zt(e, t) {
|
|
|
537
537
|
u = g;
|
|
538
538
|
},
|
|
539
539
|
setPlaybackSpeed: (g) => {
|
|
540
|
-
|
|
540
|
+
k = Math.max(0.1, Math.min(1, g)), S();
|
|
541
541
|
},
|
|
542
|
-
getPlaybackSpeed: () =>
|
|
542
|
+
getPlaybackSpeed: () => k,
|
|
543
543
|
resetForNewStream: (g) => {
|
|
544
544
|
p = !1, f = !1, u = g;
|
|
545
545
|
},
|
|
@@ -553,17 +553,17 @@ function Zt(e, t) {
|
|
|
553
553
|
},
|
|
554
554
|
markStreamComplete: (g) => {
|
|
555
555
|
if (f = !0, !a && g.length > 0) {
|
|
556
|
-
|
|
556
|
+
q(g);
|
|
557
557
|
return;
|
|
558
558
|
}
|
|
559
559
|
R();
|
|
560
560
|
},
|
|
561
561
|
playAudioChunk: y,
|
|
562
|
-
queueTimingsOnly: (g,
|
|
562
|
+
queueTimingsOnly: (g, x, b, D, A) => {
|
|
563
563
|
let P = _;
|
|
564
|
-
A && g.length > 0 && (P =
|
|
564
|
+
A && g.length > 0 && (P = Bt(g)), z(
|
|
565
565
|
g,
|
|
566
|
-
|
|
566
|
+
x,
|
|
567
567
|
b,
|
|
568
568
|
D,
|
|
569
569
|
P,
|
|
@@ -574,7 +574,7 @@ function Zt(e, t) {
|
|
|
574
574
|
getPlaybackElapsedMs: () => o ? a && s && w > 0 ? Math.max(
|
|
575
575
|
0,
|
|
576
576
|
(s.currentTime - w) * 1e3
|
|
577
|
-
) : Math.max(0, (performance.now() - l) *
|
|
577
|
+
) : Math.max(0, (performance.now() - l) * k) : 0,
|
|
578
578
|
isSpeaking: () => o,
|
|
579
579
|
getPlaybackStartPerf: () => l,
|
|
580
580
|
/** User spoke over the bot — drop in-flight chunks until the next utterance. */
|
|
@@ -586,90 +586,101 @@ function Zt(e, t) {
|
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function ze(e, t) {
|
|
590
590
|
let n = null;
|
|
591
591
|
for (const r of e)
|
|
592
592
|
t < r.vtime || t >= r.vtime + r.vduration || (!n || r.vtime >= n.vtime) && (n = r);
|
|
593
593
|
return n ? n.viseme : "sil";
|
|
594
594
|
}
|
|
595
|
-
function
|
|
595
|
+
function kr(e, t, n = 120) {
|
|
596
|
+
const r = ze(e, t);
|
|
597
|
+
if (r !== "sil") return r;
|
|
598
|
+
let s = null;
|
|
599
|
+
for (const i of e) {
|
|
600
|
+
if (i.vtime > t) break;
|
|
601
|
+
const o = i.vtime + i.vduration;
|
|
602
|
+
o <= t && t - o <= n && (s = i);
|
|
603
|
+
}
|
|
604
|
+
return s?.viseme ?? "sil";
|
|
605
|
+
}
|
|
606
|
+
function Ys(e, t) {
|
|
596
607
|
for (const n of e)
|
|
597
608
|
if (t >= n.wtime && t < n.wtime + n.wduration)
|
|
598
609
|
return n;
|
|
599
610
|
return null;
|
|
600
611
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
612
|
+
const tn = 0.5, nn = 1.5, rn = "Olivia", vr = "f786b574-daa5-4673-aa0c-cbe3e8534c02", ht = 0.85;
|
|
613
|
+
function Lt(e, t = Te) {
|
|
603
614
|
const n = `${t.replace(/\/$/, "")}/avatar_ttsWithPoses`, r = [], s = [], i = [];
|
|
604
|
-
let o = "neutral", a = "", f =
|
|
605
|
-
const l = /* @__PURE__ */ new Set(), w = () => l.forEach((
|
|
615
|
+
let o = "neutral", a = "", f = Ae;
|
|
616
|
+
const l = /* @__PURE__ */ new Set(), w = () => l.forEach((k) => k()), _ = en(
|
|
606
617
|
{
|
|
607
618
|
onSpeakingStart: () => e("speaking"),
|
|
608
619
|
onSpeakingDone: () => e("done"),
|
|
609
620
|
onNotify: w
|
|
610
621
|
},
|
|
611
|
-
|
|
622
|
+
Ae
|
|
612
623
|
), m = () => {
|
|
613
624
|
_.stop(), r.length = 0, s.length = 0, i.length = 0, o = "neutral", e("idle"), w();
|
|
614
625
|
};
|
|
615
626
|
return {
|
|
616
|
-
setDeveloperToken: (
|
|
617
|
-
a =
|
|
627
|
+
setDeveloperToken: (k) => {
|
|
628
|
+
a = k;
|
|
618
629
|
},
|
|
619
|
-
setTtsEngineId: (
|
|
620
|
-
f =
|
|
630
|
+
setTtsEngineId: (k) => {
|
|
631
|
+
f = k;
|
|
621
632
|
},
|
|
622
633
|
getTtsEngineId: () => f,
|
|
623
|
-
speak: async (
|
|
634
|
+
speak: async (k, u) => {
|
|
624
635
|
m(), e("loading");
|
|
625
636
|
const p = a.trim();
|
|
626
637
|
if (!p)
|
|
627
638
|
throw new Error("Developer token required for avatar_ttsWithPoses");
|
|
628
|
-
const d = u?.ttsEngineId ?? f ??
|
|
639
|
+
const d = u?.ttsEngineId ?? f ?? Ae;
|
|
629
640
|
_.resetForNewStream(d), _.setStreamTtsEngineId(d);
|
|
630
|
-
const I = u?.voiceId ??
|
|
631
|
-
|
|
632
|
-
Math.min(
|
|
633
|
-
),
|
|
634
|
-
user_query:
|
|
641
|
+
const I = u?.voiceId ?? rn, S = u?.speakingRate ?? ht, R = Math.max(
|
|
642
|
+
tn,
|
|
643
|
+
Math.min(nn, S)
|
|
644
|
+
), q = {
|
|
645
|
+
user_query: k,
|
|
635
646
|
ttsEngineId: d,
|
|
636
647
|
speakingRate: R,
|
|
637
648
|
tenant: "aiTwin"
|
|
638
649
|
};
|
|
639
|
-
|
|
650
|
+
On.has(d) && (q.voice_id = I);
|
|
640
651
|
try {
|
|
641
|
-
const
|
|
652
|
+
const N = await fetch(n, {
|
|
642
653
|
method: "POST",
|
|
643
654
|
headers: {
|
|
644
655
|
"Content-Type": "application/json",
|
|
645
656
|
Authorization: `Bearer ${p}`
|
|
646
657
|
},
|
|
647
|
-
body: JSON.stringify(
|
|
658
|
+
body: JSON.stringify(q)
|
|
648
659
|
});
|
|
649
|
-
if (!
|
|
650
|
-
throw new Error(`avatar_ttsWithPoses failed (${
|
|
651
|
-
const
|
|
652
|
-
if (
|
|
653
|
-
const
|
|
660
|
+
if (!N.ok)
|
|
661
|
+
throw new Error(`avatar_ttsWithPoses failed (${N.status})`);
|
|
662
|
+
const V = N.body;
|
|
663
|
+
if (!V) throw new Error("No response body");
|
|
664
|
+
const z = V.getReader(), y = new TextDecoder();
|
|
654
665
|
let T = "";
|
|
655
|
-
const g = async (
|
|
656
|
-
const b =
|
|
666
|
+
const g = async (x) => {
|
|
667
|
+
const b = sr(x);
|
|
657
668
|
if (b) {
|
|
658
669
|
if (b.event === "audio") {
|
|
659
|
-
const D = b.data.chunk, A = b.data.visemes ?? [], P = b.data.words ?? [],
|
|
670
|
+
const D = b.data.chunk, A = b.data.visemes ?? [], P = b.data.words ?? [], F = b.data.is_new_segment ?? !1;
|
|
660
671
|
D ? await _.playAudioChunk(
|
|
661
672
|
r,
|
|
662
673
|
s,
|
|
663
674
|
D,
|
|
664
675
|
A,
|
|
665
676
|
P,
|
|
666
|
-
|
|
677
|
+
F
|
|
667
678
|
) : (A.length > 0 || P.length > 0) && _.queueTimingsOnly(
|
|
668
679
|
r,
|
|
669
680
|
s,
|
|
670
681
|
A,
|
|
671
682
|
P,
|
|
672
|
-
|
|
683
|
+
F
|
|
673
684
|
);
|
|
674
685
|
} else if (b.event === "metadata") {
|
|
675
686
|
const D = b.data.mood;
|
|
@@ -679,14 +690,14 @@ function Bt(e, t = be) {
|
|
|
679
690
|
i.length = 0;
|
|
680
691
|
for (const P of A) {
|
|
681
692
|
if (!P || typeof P != "object") continue;
|
|
682
|
-
const
|
|
693
|
+
const F = P;
|
|
683
694
|
i.push({
|
|
684
|
-
sentence_index: Number(
|
|
685
|
-
text: String(
|
|
686
|
-
sentiment: typeof
|
|
687
|
-
emotion: String(
|
|
688
|
-
start_word: Number(
|
|
689
|
-
end_word: Number(
|
|
695
|
+
sentence_index: Number(F.sentence_index ?? 0),
|
|
696
|
+
text: String(F.text ?? ""),
|
|
697
|
+
sentiment: typeof F.sentiment == "string" ? F.sentiment : void 0,
|
|
698
|
+
emotion: String(F.emotion ?? o),
|
|
699
|
+
start_word: Number(F.start_word ?? 0),
|
|
700
|
+
end_word: Number(F.end_word ?? 0)
|
|
690
701
|
});
|
|
691
702
|
}
|
|
692
703
|
}
|
|
@@ -698,20 +709,20 @@ function Bt(e, t = be) {
|
|
|
698
709
|
}
|
|
699
710
|
};
|
|
700
711
|
for (; ; ) {
|
|
701
|
-
const { done:
|
|
712
|
+
const { done: x, value: b } = await z.read();
|
|
702
713
|
b && (T += y.decode(b, { stream: !0 }));
|
|
703
714
|
const D = T.split(`
|
|
704
715
|
|
|
705
716
|
`);
|
|
706
717
|
T = D.pop() ?? "";
|
|
707
718
|
for (const A of D) await g(A);
|
|
708
|
-
if (
|
|
719
|
+
if (x) {
|
|
709
720
|
T.trim() && await g(T.trim()), _.markStreamComplete(r);
|
|
710
721
|
break;
|
|
711
722
|
}
|
|
712
723
|
}
|
|
713
|
-
} catch (
|
|
714
|
-
throw console.error("[avatarTtsLipsync]",
|
|
724
|
+
} catch (N) {
|
|
725
|
+
throw console.error("[avatarTtsLipsync]", N), m(), e("error"), N;
|
|
715
726
|
}
|
|
716
727
|
},
|
|
717
728
|
stop: m,
|
|
@@ -721,15 +732,15 @@ function Bt(e, t = be) {
|
|
|
721
732
|
getStreamMood: () => o,
|
|
722
733
|
getPlaybackElapsedMs: () => _.getPlaybackElapsedMs(),
|
|
723
734
|
isSpeaking: () => _.isSpeaking(),
|
|
724
|
-
setPlaybackSpeed: (
|
|
725
|
-
_.setPlaybackSpeed(
|
|
735
|
+
setPlaybackSpeed: (k) => {
|
|
736
|
+
_.setPlaybackSpeed(k);
|
|
726
737
|
},
|
|
727
738
|
getPlaybackSpeed: () => _.getPlaybackSpeed(),
|
|
728
|
-
subscribe: (
|
|
739
|
+
subscribe: (k) => (l.add(k), () => l.delete(k))
|
|
729
740
|
};
|
|
730
741
|
}
|
|
731
|
-
const
|
|
732
|
-
class
|
|
742
|
+
const sn = 16e3, on = 24e3;
|
|
743
|
+
class br extends Rn {
|
|
733
744
|
constructor() {
|
|
734
745
|
super(
|
|
735
746
|
!0,
|
|
@@ -737,40 +748,42 @@ class kr extends In {
|
|
|
737
748
|
void 0,
|
|
738
749
|
void 0,
|
|
739
750
|
512,
|
|
740
|
-
|
|
741
|
-
|
|
751
|
+
sn,
|
|
752
|
+
on
|
|
742
753
|
);
|
|
743
754
|
}
|
|
744
755
|
/** Pipecat protobuf bot audio is unused — playback comes from avatar_audio_chunk. */
|
|
745
756
|
bufferBotAudio(t, n) {
|
|
746
757
|
}
|
|
747
758
|
}
|
|
748
|
-
const
|
|
749
|
-
function
|
|
750
|
-
return
|
|
759
|
+
const Tr = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
760
|
+
function Ar(e) {
|
|
761
|
+
return Tr.test(e.trim());
|
|
751
762
|
}
|
|
752
|
-
function
|
|
763
|
+
function Ir(e) {
|
|
753
764
|
const t = e.replace(/\/$/, "");
|
|
754
765
|
return t.startsWith("https://") ? `wss://${t.slice(8)}` : t.startsWith("http://") ? `ws://${t.slice(7)}` : t;
|
|
755
766
|
}
|
|
756
|
-
function
|
|
767
|
+
function Rr(e) {
|
|
757
768
|
if (e.wsUrl?.trim()) return e.wsUrl.trim();
|
|
758
769
|
const t = e.authToken?.trim();
|
|
759
770
|
if (!t)
|
|
760
771
|
throw new Error(
|
|
761
772
|
"Voice connect requires authToken (same JWT as SSE Authorization Bearer)."
|
|
762
773
|
);
|
|
763
|
-
const n = e.apiBase ??
|
|
764
|
-
r.searchParams.set("authToken", t);
|
|
774
|
+
const n = e.apiBase ?? Te, r = new URL(`${Ir(n)}/ws/voice`);
|
|
775
|
+
r.searchParams.set("authToken", t), r.searchParams.set("tenant", "aiTwin");
|
|
765
776
|
const s = e.voiceId?.trim();
|
|
766
|
-
s &&
|
|
767
|
-
const i = e.
|
|
777
|
+
s && Ar(s) && r.searchParams.set("voiceId", s);
|
|
778
|
+
const i = e.personaId?.trim();
|
|
779
|
+
i && r.searchParams.set("personaId", i);
|
|
780
|
+
const o = e.speakingRate ?? ht;
|
|
768
781
|
return r.searchParams.set(
|
|
769
782
|
"speaking_rate",
|
|
770
|
-
String(Math.max(
|
|
783
|
+
String(Math.max(tn, Math.min(nn, o)))
|
|
771
784
|
), e.ttsStream === !1 ? r.searchParams.set("tts_stream", "false") : r.searchParams.set("tts_stream", "true"), r.toString();
|
|
772
785
|
}
|
|
773
|
-
function
|
|
786
|
+
function Ot(e, t) {
|
|
774
787
|
if (!Array.isArray(e)) return [];
|
|
775
788
|
const n = [];
|
|
776
789
|
for (const r of e)
|
|
@@ -784,115 +797,115 @@ function Lt(e, t) {
|
|
|
784
797
|
});
|
|
785
798
|
return n;
|
|
786
799
|
}
|
|
787
|
-
function
|
|
800
|
+
function Dr(e) {
|
|
788
801
|
if (!e || typeof e != "object") return null;
|
|
789
802
|
const t = e, n = t.data;
|
|
790
803
|
return n && typeof n == "object" ? n : t;
|
|
791
804
|
}
|
|
792
|
-
function
|
|
805
|
+
function Cr(e, t = {}) {
|
|
793
806
|
const n = [], r = [], s = [], i = [];
|
|
794
|
-
let o = "", a = "neutral", f =
|
|
807
|
+
let o = "", a = "neutral", f = Ie, l = !1, w = null, _ = null, m = { ...t }, v = 0, k = null;
|
|
795
808
|
const u = /* @__PURE__ */ new Set(), p = [];
|
|
796
809
|
let d = !1, I = null;
|
|
797
|
-
const
|
|
810
|
+
const S = () => u.forEach((c) => c()), R = en(
|
|
798
811
|
{
|
|
799
812
|
onSpeakingStart: () => e("speaking"),
|
|
800
813
|
onSpeakingDone: () => e("done"),
|
|
801
|
-
onNotify:
|
|
814
|
+
onNotify: S
|
|
802
815
|
},
|
|
803
816
|
f
|
|
804
|
-
),
|
|
817
|
+
), q = () => {
|
|
805
818
|
if (I) return I;
|
|
806
819
|
const c = new MessageChannel();
|
|
807
820
|
return c.port1.onmessage = () => {
|
|
808
|
-
const
|
|
809
|
-
|
|
821
|
+
const E = p.shift();
|
|
822
|
+
E !== void 0 && W(E), p.length > 0 ? c.port2.postMessage(null) : d = !1;
|
|
810
823
|
}, I = c, c;
|
|
811
|
-
},
|
|
812
|
-
p.push(c), !d && (d = !0,
|
|
813
|
-
},
|
|
824
|
+
}, N = (c) => {
|
|
825
|
+
p.push(c), !d && (d = !0, q().port2.postMessage(null));
|
|
826
|
+
}, V = () => R.getPlaybackElapsedMs(), z = (c, E = o) => {
|
|
814
827
|
if (!m.onLipsyncDebug) return;
|
|
815
|
-
const L =
|
|
828
|
+
const L = V(), X = n;
|
|
816
829
|
m.onLipsyncDebug({
|
|
817
830
|
event: c,
|
|
818
|
-
spokenText:
|
|
831
|
+
spokenText: E,
|
|
819
832
|
mood: a,
|
|
820
833
|
playbackAnchorPerf: R.getPlaybackStartPerf(),
|
|
821
834
|
playbackElapsedMs: L,
|
|
822
|
-
queueLength:
|
|
823
|
-
activeViseme:
|
|
835
|
+
queueLength: X.length,
|
|
836
|
+
activeViseme: ze(X, L),
|
|
824
837
|
segments: i.map((ne) => ({
|
|
825
838
|
...ne,
|
|
826
839
|
visemes: [...ne.visemes]
|
|
827
840
|
}))
|
|
828
841
|
});
|
|
829
|
-
}, y = (c,
|
|
830
|
-
m.onLipsyncDebug && (
|
|
831
|
-
|
|
832
|
-
const L =
|
|
833
|
-
|
|
842
|
+
}, y = (c, E) => {
|
|
843
|
+
m.onLipsyncDebug && (k = { event: c, spokenText: E }, v === 0 && (v = requestAnimationFrame(() => {
|
|
844
|
+
v = 0;
|
|
845
|
+
const L = k;
|
|
846
|
+
k = null, L && z(L.event, L.spokenText);
|
|
834
847
|
})));
|
|
835
848
|
}, T = () => {
|
|
836
849
|
n.length = 0, r.length = 0, i.length = 0, o = "", a = "neutral", s.length = 0;
|
|
837
850
|
}, g = () => {
|
|
838
|
-
R.stop(), T(), y("reset"),
|
|
839
|
-
},
|
|
840
|
-
g(), e("idle"),
|
|
841
|
-
}, b = (c,
|
|
842
|
-
typeof c.mood == "string" && c.mood.trim() && (a = c.mood.trim()), Array.isArray(c.sentence_emotions) && c.sentence_emotions.length > 0 && (
|
|
843
|
-
...
|
|
851
|
+
R.stop(), T(), y("reset"), S();
|
|
852
|
+
}, x = () => {
|
|
853
|
+
g(), e("idle"), S();
|
|
854
|
+
}, b = (c, E) => {
|
|
855
|
+
typeof c.mood == "string" && c.mood.trim() && (a = c.mood.trim()), Array.isArray(c.sentence_emotions) && c.sentence_emotions.length > 0 && (E && (s.length = 0), s.push(
|
|
856
|
+
...Ot(c.sentence_emotions, a)
|
|
844
857
|
));
|
|
845
858
|
}, D = (c) => {
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
...
|
|
849
|
-
), Array.isArray(c.gestures) && c.gestures, y("metadata",
|
|
850
|
-
}, A = (c,
|
|
859
|
+
const E = String(c.spoken_text ?? c.text ?? "").trim();
|
|
860
|
+
E && (o = E), R.resetForNewStream(f), typeof c.mood == "string" && c.mood.trim() && (a = c.mood.trim()), s.length = 0, s.push(
|
|
861
|
+
...Ot(c.sentence_emotions, a)
|
|
862
|
+
), Array.isArray(c.gestures) && c.gestures, y("metadata", E), S();
|
|
863
|
+
}, A = (c, E, L, X) => {
|
|
851
864
|
if (!m.onLipsyncDebug) return;
|
|
852
|
-
const ne = n.slice(L),
|
|
853
|
-
(
|
|
865
|
+
const ne = n.slice(L), Se = X.filter(
|
|
866
|
+
(se) => String(se.symbol ?? se.viseme ?? "").trim()
|
|
854
867
|
);
|
|
855
868
|
i.push({
|
|
856
|
-
spokenText:
|
|
869
|
+
spokenText: E,
|
|
857
870
|
audioOffsetMs: ne[0]?.vtime ?? 0,
|
|
858
871
|
isNewSegment: !!c.is_new_segment,
|
|
859
872
|
chunkDurationMs: c.chunk_duration_ms != null ? Number(c.chunk_duration_ms) : null,
|
|
860
873
|
receivedAtMs: performance.now(),
|
|
861
|
-
visemes: ne.map((
|
|
862
|
-
const
|
|
874
|
+
visemes: ne.map((se, ue) => {
|
|
875
|
+
const le = Se[ue];
|
|
863
876
|
return {
|
|
864
|
-
rawSymbol: String(
|
|
865
|
-
viseme:
|
|
866
|
-
startSec: Number(
|
|
867
|
-
durationSec: Number(
|
|
868
|
-
vtimeMs:
|
|
869
|
-
vdurationMs:
|
|
877
|
+
rawSymbol: String(le?.symbol ?? le?.viseme ?? se.viseme).trim(),
|
|
878
|
+
viseme: se.viseme,
|
|
879
|
+
startSec: Number(le?.start ?? 0),
|
|
880
|
+
durationSec: Number(le?.duration ?? 0),
|
|
881
|
+
vtimeMs: se.vtime,
|
|
882
|
+
vdurationMs: se.vduration
|
|
870
883
|
};
|
|
871
884
|
})
|
|
872
885
|
});
|
|
873
886
|
}, P = (c) => {
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
const
|
|
887
|
+
const E = String(c.spoken_text ?? c.text ?? "").trim(), L = !!c.is_new_segment || Number(c.chunk_index ?? -1) === 0, X = c.visemes ?? [], ne = c.words ?? [], Se = String(c.chunk ?? "").trim();
|
|
888
|
+
E && (o = E), b(c, L), L && R.resetForNewStream(f);
|
|
889
|
+
const se = n.length;
|
|
877
890
|
R.playAudioChunk(
|
|
878
891
|
n,
|
|
879
892
|
r,
|
|
880
|
-
|
|
881
|
-
|
|
893
|
+
Se,
|
|
894
|
+
X,
|
|
882
895
|
ne,
|
|
883
896
|
L,
|
|
884
897
|
() => {
|
|
885
898
|
i.length = 0;
|
|
886
899
|
}
|
|
887
900
|
).then(() => {
|
|
888
|
-
A(c,
|
|
901
|
+
A(c, E, se, X), y("audio_chunk", E);
|
|
889
902
|
});
|
|
890
|
-
},
|
|
903
|
+
}, F = (c) => {
|
|
891
904
|
console.warn(
|
|
892
905
|
"[realtimeVoice] avatar_lipsync is deprecated — expect avatar_audio_chunk"
|
|
893
906
|
);
|
|
894
|
-
const
|
|
895
|
-
|
|
907
|
+
const E = String(c.spoken_text ?? c.text ?? "").trim();
|
|
908
|
+
E && (o = E), b(c, !!c.is_new_segment);
|
|
896
909
|
const L = n.length;
|
|
897
910
|
R.queueTimingsOnly(
|
|
898
911
|
n,
|
|
@@ -902,66 +915,66 @@ function Rr(e, t = {}) {
|
|
|
902
915
|
!!c.is_new_segment
|
|
903
916
|
), A(
|
|
904
917
|
c,
|
|
905
|
-
|
|
918
|
+
E,
|
|
906
919
|
L,
|
|
907
920
|
c.visemes ?? []
|
|
908
|
-
), y("lipsync",
|
|
921
|
+
), y("lipsync", E), S();
|
|
909
922
|
}, W = (c) => {
|
|
910
|
-
const
|
|
911
|
-
if (!
|
|
923
|
+
const E = Dr(c);
|
|
924
|
+
if (!E) {
|
|
912
925
|
console.warn("[realtimeVoice] server message with no payload", c);
|
|
913
926
|
return;
|
|
914
927
|
}
|
|
915
|
-
const L = String(
|
|
916
|
-
switch (L !== "avatar_metadata" && L !== "avatar_audio_chunk" && L !== "avatar_lipsync" && L !== "error" && console.debug("[realtimeVoice] server message", L,
|
|
928
|
+
const L = String(E.type ?? "unknown");
|
|
929
|
+
switch (L !== "avatar_metadata" && L !== "avatar_audio_chunk" && L !== "avatar_lipsync" && L !== "error" && console.debug("[realtimeVoice] server message", L, E), L) {
|
|
917
930
|
case "avatar_metadata":
|
|
918
|
-
D(
|
|
931
|
+
D(E);
|
|
919
932
|
break;
|
|
920
933
|
case "avatar_audio_chunk":
|
|
921
|
-
P(
|
|
934
|
+
P(E);
|
|
922
935
|
break;
|
|
923
936
|
case "avatar_lipsync":
|
|
924
|
-
|
|
937
|
+
F(E);
|
|
925
938
|
break;
|
|
926
939
|
case "error": {
|
|
927
|
-
const
|
|
928
|
-
console.error("[realtimeVoice] server error:",
|
|
940
|
+
const X = String(E.message ?? "Voice session error");
|
|
941
|
+
console.error("[realtimeVoice] server error:", X), e("error"), S();
|
|
929
942
|
break;
|
|
930
943
|
}
|
|
931
944
|
case "avatar_speak":
|
|
932
945
|
console.warn(
|
|
933
946
|
"[realtimeVoice] avatar_speak received; tts_stream=false Mode B is not wired yet:",
|
|
934
|
-
|
|
947
|
+
E.text
|
|
935
948
|
);
|
|
936
949
|
break;
|
|
937
950
|
}
|
|
938
|
-
},
|
|
939
|
-
transport: new
|
|
951
|
+
}, G = () => w || (_ = new br(), w = new An({
|
|
952
|
+
transport: new In({
|
|
940
953
|
mediaManager: _,
|
|
941
|
-
recorderSampleRate:
|
|
942
|
-
playerSampleRate:
|
|
954
|
+
recorderSampleRate: sn,
|
|
955
|
+
playerSampleRate: on
|
|
943
956
|
}),
|
|
944
957
|
enableCam: !1,
|
|
945
958
|
enableMic: !0,
|
|
946
959
|
callbacks: {
|
|
947
960
|
onBotReady: () => {
|
|
948
|
-
l = !0, e("idle"),
|
|
961
|
+
l = !0, e("idle"), S();
|
|
949
962
|
},
|
|
950
963
|
onDisconnected: () => {
|
|
951
|
-
l = !1,
|
|
964
|
+
l = !1, x();
|
|
952
965
|
},
|
|
953
966
|
onError: (c) => {
|
|
954
|
-
const
|
|
955
|
-
console.error("[realtimeVoice]",
|
|
967
|
+
const E = typeof c == "object" && c !== null && "data" in c ? String(c.data ?? c) : String(c);
|
|
968
|
+
console.error("[realtimeVoice]", E, c), e("error"), S();
|
|
956
969
|
},
|
|
957
970
|
onTransportStateChanged: (c) => {
|
|
958
|
-
c === "error" && (e("error"),
|
|
971
|
+
c === "error" && (e("error"), S());
|
|
959
972
|
},
|
|
960
973
|
onServerMessage: (c) => {
|
|
961
|
-
|
|
974
|
+
N(c);
|
|
962
975
|
},
|
|
963
976
|
onUserStartedSpeaking: () => {
|
|
964
|
-
R.bargeIn(), T(), e("idle"), y("user_started"),
|
|
977
|
+
R.bargeIn(), T(), e("idle"), y("user_started"), S();
|
|
965
978
|
},
|
|
966
979
|
onBotStartedSpeaking: () => {
|
|
967
980
|
y("bot_started");
|
|
@@ -984,7 +997,7 @@ function Rr(e, t = {}) {
|
|
|
984
997
|
f = c, R.setStreamTtsEngineId(c);
|
|
985
998
|
},
|
|
986
999
|
getTtsEngineId: () => f,
|
|
987
|
-
speak: async (c,
|
|
1000
|
+
speak: async (c, E) => {
|
|
988
1001
|
const L = c.trim();
|
|
989
1002
|
if (L) {
|
|
990
1003
|
if (!w || !l)
|
|
@@ -995,7 +1008,7 @@ function Rr(e, t = {}) {
|
|
|
995
1008
|
}
|
|
996
1009
|
},
|
|
997
1010
|
stop: () => {
|
|
998
|
-
g(), e("idle"),
|
|
1011
|
+
g(), e("idle"), S();
|
|
999
1012
|
},
|
|
1000
1013
|
connect: async (c) => {
|
|
1001
1014
|
if (c && (m = { ...m, ...c }), !m.authToken?.trim())
|
|
@@ -1003,18 +1016,18 @@ function Rr(e, t = {}) {
|
|
|
1003
1016
|
"Voice connect requires authToken (same JWT as SSE Authorization Bearer)."
|
|
1004
1017
|
);
|
|
1005
1018
|
e("loading");
|
|
1006
|
-
const
|
|
1007
|
-
await
|
|
1008
|
-
const L =
|
|
1019
|
+
const E = G();
|
|
1020
|
+
await E.initDevices();
|
|
1021
|
+
const L = Rr(m);
|
|
1009
1022
|
console.info("[realtimeVoice] connecting (avatar_audio_chunk RTVI):", L);
|
|
1010
1023
|
try {
|
|
1011
|
-
await
|
|
1012
|
-
} catch (
|
|
1013
|
-
l = !1, e("error"),
|
|
1014
|
-
const ne =
|
|
1024
|
+
await E.connect({ wsUrl: L });
|
|
1025
|
+
} catch (X) {
|
|
1026
|
+
l = !1, e("error"), S();
|
|
1027
|
+
const ne = X instanceof Error ? X.message : "Realtime voice connect failed (WebSocket 101 only means upgrade OK — check authToken/origin/RTVI handshake)";
|
|
1015
1028
|
throw new Error(`${ne} — ${L}`);
|
|
1016
1029
|
}
|
|
1017
|
-
l = !0, e("idle"),
|
|
1030
|
+
l = !0, e("idle"), S();
|
|
1018
1031
|
},
|
|
1019
1032
|
disconnect: async () => {
|
|
1020
1033
|
if (p.length = 0, d = !1, w)
|
|
@@ -1023,7 +1036,7 @@ function Rr(e, t = {}) {
|
|
|
1023
1036
|
} catch (c) {
|
|
1024
1037
|
console.error("[realtimeVoice] disconnect failed:", c);
|
|
1025
1038
|
}
|
|
1026
|
-
l = !1,
|
|
1039
|
+
l = !1, x();
|
|
1027
1040
|
},
|
|
1028
1041
|
isConnected: () => l,
|
|
1029
1042
|
unlockAudio: async () => {
|
|
@@ -1033,7 +1046,7 @@ function Rr(e, t = {}) {
|
|
|
1033
1046
|
getWordQueue: () => r,
|
|
1034
1047
|
getSentenceEmotions: () => s,
|
|
1035
1048
|
getStreamMood: () => a,
|
|
1036
|
-
getPlaybackElapsedMs:
|
|
1049
|
+
getPlaybackElapsedMs: V,
|
|
1037
1050
|
isSpeaking: () => R.isSpeaking(),
|
|
1038
1051
|
setPlaybackSpeed: (c) => {
|
|
1039
1052
|
R.setPlaybackSpeed(c);
|
|
@@ -1042,7 +1055,7 @@ function Rr(e, t = {}) {
|
|
|
1042
1055
|
subscribe: (c) => (u.add(c), () => u.delete(c))
|
|
1043
1056
|
};
|
|
1044
1057
|
}
|
|
1045
|
-
function
|
|
1058
|
+
function xr(e, t, n) {
|
|
1046
1059
|
return {
|
|
1047
1060
|
width: e.crop?.source_width ?? t,
|
|
1048
1061
|
height: e.crop?.source_height ?? n
|
|
@@ -1057,21 +1070,21 @@ function Mr(e, t) {
|
|
|
1057
1070
|
height: t?.source_h ?? n?.height ?? e.frame_height ?? 0
|
|
1058
1071
|
};
|
|
1059
1072
|
}
|
|
1060
|
-
function
|
|
1073
|
+
function Pr(e) {
|
|
1061
1074
|
return e ? (e.w ?? 0) > 0 && (e.h ?? 0) > 0 : !1;
|
|
1062
1075
|
}
|
|
1063
1076
|
async function Ye(e, t) {
|
|
1064
1077
|
const n = await fetch(e);
|
|
1065
1078
|
if (!n.ok) throw new Error(`Failed to load encrypted asset: ${e}`);
|
|
1066
1079
|
const r = await n.arrayBuffer();
|
|
1067
|
-
return
|
|
1080
|
+
return Yn(r, t);
|
|
1068
1081
|
}
|
|
1069
|
-
async function
|
|
1082
|
+
async function Br(e, t) {
|
|
1070
1083
|
if (!t) throw new Error("Missing asset key for encrypted JSON");
|
|
1071
1084
|
const n = await Ye(e, t), r = new TextDecoder().decode(n);
|
|
1072
1085
|
return JSON.parse(r);
|
|
1073
1086
|
}
|
|
1074
|
-
async function
|
|
1087
|
+
async function Lr(e) {
|
|
1075
1088
|
const t = new Blob([e], { type: "image/webp" }), n = URL.createObjectURL(t);
|
|
1076
1089
|
return new Promise((r, s) => {
|
|
1077
1090
|
const i = new Image();
|
|
@@ -1082,7 +1095,7 @@ async function Pr(e) {
|
|
|
1082
1095
|
}, i.src = n;
|
|
1083
1096
|
});
|
|
1084
1097
|
}
|
|
1085
|
-
async function
|
|
1098
|
+
async function Or(e) {
|
|
1086
1099
|
const t = new Blob([e], { type: "image/png" }), n = URL.createObjectURL(t);
|
|
1087
1100
|
return new Promise((r, s) => {
|
|
1088
1101
|
const i = new Image();
|
|
@@ -1093,28 +1106,28 @@ async function Br(e) {
|
|
|
1093
1106
|
}, i.src = n;
|
|
1094
1107
|
});
|
|
1095
1108
|
}
|
|
1096
|
-
function
|
|
1109
|
+
function Fr(e) {
|
|
1097
1110
|
const t = new Blob([e], { type: "video/mp4" });
|
|
1098
1111
|
return URL.createObjectURL(t);
|
|
1099
1112
|
}
|
|
1100
|
-
async function
|
|
1101
|
-
const t =
|
|
1102
|
-
if (!
|
|
1113
|
+
async function Ur(e) {
|
|
1114
|
+
const t = er();
|
|
1115
|
+
if (!je()) return t;
|
|
1103
1116
|
if (!e) throw new Error("Missing asset key for encrypted idle video");
|
|
1104
1117
|
const n = await Ye(t, e);
|
|
1105
|
-
return
|
|
1118
|
+
return Fr(n);
|
|
1106
1119
|
}
|
|
1107
|
-
function
|
|
1120
|
+
function mt(e, t) {
|
|
1108
1121
|
return `${e}/${t}_minus_sil.png`;
|
|
1109
1122
|
}
|
|
1110
|
-
const
|
|
1111
|
-
function
|
|
1123
|
+
const an = 5;
|
|
1124
|
+
function cn(e) {
|
|
1112
1125
|
const t = e?.composite_threshold;
|
|
1113
1126
|
if (typeof t == "number" && t > 0) return t;
|
|
1114
1127
|
const n = e?.crop?.content_threshold;
|
|
1115
|
-
return typeof n == "number" && n > 0 ? n :
|
|
1128
|
+
return typeof n == "number" && n > 0 ? n : an;
|
|
1116
1129
|
}
|
|
1117
|
-
const
|
|
1130
|
+
const Js = [
|
|
1118
1131
|
"aa",
|
|
1119
1132
|
"E",
|
|
1120
1133
|
"I",
|
|
@@ -1129,11 +1142,11 @@ const Gs = [
|
|
|
1129
1142
|
"RR",
|
|
1130
1143
|
"kk",
|
|
1131
1144
|
"nn"
|
|
1132
|
-
],
|
|
1145
|
+
], at = [
|
|
1133
1146
|
"t01_0.25",
|
|
1134
1147
|
"t02_0.50",
|
|
1135
1148
|
"t03_0.75"
|
|
1136
|
-
],
|
|
1149
|
+
], Nr = at.length, Ft = /* @__PURE__ */ new Set([
|
|
1137
1150
|
"aa__kk",
|
|
1138
1151
|
"aa__nn",
|
|
1139
1152
|
"aa__sil",
|
|
@@ -1240,75 +1253,75 @@ const Gs = [
|
|
|
1240
1253
|
"U__nn",
|
|
1241
1254
|
"U__sil"
|
|
1242
1255
|
]);
|
|
1243
|
-
function
|
|
1256
|
+
function Ut(e, t) {
|
|
1244
1257
|
return `${e}__${t}`;
|
|
1245
1258
|
}
|
|
1246
|
-
function
|
|
1259
|
+
function Nt(e, t) {
|
|
1247
1260
|
return `pairs/${e}/${t}_minus_sil.png`;
|
|
1248
1261
|
}
|
|
1249
|
-
function
|
|
1262
|
+
function qe(e) {
|
|
1250
1263
|
return `${e}_minus_sil.png`;
|
|
1251
1264
|
}
|
|
1252
|
-
function
|
|
1265
|
+
function Vr(e, t) {
|
|
1253
1266
|
if (t.has(e)) return e;
|
|
1254
1267
|
const n = /^pairs\/([^/]+)\//.exec(e);
|
|
1255
1268
|
if (!n) return null;
|
|
1256
1269
|
const r = n[1].split("__")[1];
|
|
1257
1270
|
if (!r || r === "sil") return null;
|
|
1258
|
-
const s =
|
|
1271
|
+
const s = qe(r);
|
|
1259
1272
|
return t.has(s) ? s : null;
|
|
1260
1273
|
}
|
|
1261
|
-
function
|
|
1274
|
+
function un(e, t) {
|
|
1262
1275
|
return e.filter((n) => t.has(n));
|
|
1263
1276
|
}
|
|
1264
|
-
function
|
|
1265
|
-
const r =
|
|
1266
|
-
return
|
|
1277
|
+
function $r(e, t, n) {
|
|
1278
|
+
const r = wt(e, t);
|
|
1279
|
+
return un(r, n).length > 0;
|
|
1267
1280
|
}
|
|
1268
|
-
function
|
|
1281
|
+
function wt(e, t) {
|
|
1269
1282
|
if (e === t) return [];
|
|
1270
|
-
const n = [], r =
|
|
1271
|
-
if (
|
|
1272
|
-
for (const i of
|
|
1273
|
-
n.push(
|
|
1283
|
+
const n = [], r = Ut(e, t);
|
|
1284
|
+
if (Ft.has(r)) {
|
|
1285
|
+
for (const i of at)
|
|
1286
|
+
n.push(Nt(r, i));
|
|
1274
1287
|
return n;
|
|
1275
1288
|
}
|
|
1276
|
-
const s =
|
|
1277
|
-
if (
|
|
1278
|
-
for (let i =
|
|
1279
|
-
n.push(
|
|
1289
|
+
const s = Ut(t, e);
|
|
1290
|
+
if (Ft.has(s)) {
|
|
1291
|
+
for (let i = Nr - 1; i >= 0; i--)
|
|
1292
|
+
n.push(Nt(s, at[i]));
|
|
1280
1293
|
return n;
|
|
1281
1294
|
}
|
|
1282
1295
|
return [];
|
|
1283
1296
|
}
|
|
1284
|
-
function
|
|
1297
|
+
function Wr(e) {
|
|
1285
1298
|
return e < 16 ? [] : e < 35 ? [1] : e < 51 ? [0, 2] : [0, 1, 2];
|
|
1286
1299
|
}
|
|
1287
|
-
function
|
|
1288
|
-
return
|
|
1300
|
+
function Hr(e, t) {
|
|
1301
|
+
return Wr(t).map((r) => e[r]).filter((r) => r != null);
|
|
1289
1302
|
}
|
|
1290
|
-
function
|
|
1303
|
+
function qr(e, t, n, r) {
|
|
1291
1304
|
if (r <= 0) return 0;
|
|
1292
1305
|
const i = Math.max(1, n - t) / r, o = e - t, a = Math.floor(o / i);
|
|
1293
1306
|
return Math.min(r - 1, Math.max(0, a));
|
|
1294
1307
|
}
|
|
1295
|
-
function
|
|
1308
|
+
function Kr(e, t, n) {
|
|
1296
1309
|
if (!n) return `${e}/${t}`;
|
|
1297
1310
|
const r = t.split("/").pop() ?? t, s = r.includes(".") ? r.slice(0, r.lastIndexOf(".")) : r;
|
|
1298
1311
|
return `${e}/${s}.bin`;
|
|
1299
1312
|
}
|
|
1300
|
-
const
|
|
1313
|
+
const jr = [0.32, 0.24, 0.16, 0.08, 0], Gr = jr.map(
|
|
1301
1314
|
(e) => `eyes_${e.toFixed(2)}`
|
|
1302
|
-
),
|
|
1315
|
+
), zr = [
|
|
1303
1316
|
"eyes_0.32",
|
|
1304
1317
|
"eyes_0.16",
|
|
1305
1318
|
"eyes_0.00"
|
|
1306
|
-
],
|
|
1319
|
+
], Yr = [
|
|
1307
1320
|
"eyes_0.32",
|
|
1308
1321
|
"eyes_0.16",
|
|
1309
1322
|
"eyes_0.08",
|
|
1310
1323
|
"eyes_0.00"
|
|
1311
|
-
],
|
|
1324
|
+
], Vt = 2, Jr = -30, ct = 20, Qr = {
|
|
1312
1325
|
fear: -30,
|
|
1313
1326
|
anger: -20,
|
|
1314
1327
|
sad: -10,
|
|
@@ -1317,24 +1330,24 @@ const qr = [0.32, 0.24, 0.16, 0.08, 0], Kr = qr.map(
|
|
|
1317
1330
|
happy: 0,
|
|
1318
1331
|
disgust: 20
|
|
1319
1332
|
};
|
|
1320
|
-
function
|
|
1333
|
+
function gt(e) {
|
|
1321
1334
|
return `brow_${e}`;
|
|
1322
1335
|
}
|
|
1323
|
-
function
|
|
1324
|
-
return
|
|
1336
|
+
function _t(e) {
|
|
1337
|
+
return Qr[e];
|
|
1325
1338
|
}
|
|
1326
1339
|
function ye(e) {
|
|
1327
|
-
return Math.max(
|
|
1340
|
+
return Math.max(Jr, Math.min(ct, e));
|
|
1328
1341
|
}
|
|
1329
|
-
function
|
|
1342
|
+
function Xr(e, t) {
|
|
1330
1343
|
if (e === t) return [];
|
|
1331
|
-
const n = e < t ?
|
|
1344
|
+
const n = e < t ? Vt : -Vt, r = [];
|
|
1332
1345
|
let s = e;
|
|
1333
1346
|
for (; s !== t; )
|
|
1334
1347
|
s += n, r.push(s);
|
|
1335
1348
|
return r;
|
|
1336
1349
|
}
|
|
1337
|
-
const
|
|
1350
|
+
const Zr = {
|
|
1338
1351
|
fear: "fear",
|
|
1339
1352
|
afraid: "fear",
|
|
1340
1353
|
anxiety: "fear",
|
|
@@ -1357,63 +1370,63 @@ const Qr = {
|
|
|
1357
1370
|
disgust: "disgust",
|
|
1358
1371
|
disgusted: "disgust"
|
|
1359
1372
|
};
|
|
1360
|
-
function
|
|
1373
|
+
function be(e, t = "neutral") {
|
|
1361
1374
|
const n = String(e ?? "").trim().toLowerCase();
|
|
1362
|
-
return n ?
|
|
1363
|
-
}
|
|
1364
|
-
function un(e) {
|
|
1365
|
-
return e === 0 ? null : ht(wt(e), "eyes_standard");
|
|
1375
|
+
return n ? Zr[n] ?? t : t;
|
|
1366
1376
|
}
|
|
1367
1377
|
function ln(e) {
|
|
1368
|
-
return
|
|
1378
|
+
return e === 0 ? null : mt(gt(e), "eyes_standard");
|
|
1369
1379
|
}
|
|
1370
|
-
function
|
|
1371
|
-
|
|
1372
|
-
return !t || t === "eyes_standard" ? ln(e) : e === "neutral" && t === "eyes_standard" ? null : ht(n, t);
|
|
1380
|
+
function fn(e) {
|
|
1381
|
+
return ln(_t(e));
|
|
1373
1382
|
}
|
|
1374
|
-
function
|
|
1383
|
+
function $t(e, t) {
|
|
1384
|
+
const n = gt(_t(e));
|
|
1385
|
+
return !t || t === "eyes_standard" ? fn(e) : e === "neutral" && t === "eyes_standard" ? null : mt(n, t);
|
|
1386
|
+
}
|
|
1387
|
+
function es(e, t) {
|
|
1375
1388
|
const n = [];
|
|
1376
1389
|
for (const r of t)
|
|
1377
|
-
n.push(
|
|
1390
|
+
n.push($t(e, r));
|
|
1378
1391
|
for (let r = t.length - 2; r >= 0; r--)
|
|
1379
|
-
n.push(
|
|
1380
|
-
return n.push(
|
|
1392
|
+
n.push($t(e, t[r]));
|
|
1393
|
+
return n.push(fn(e)), n;
|
|
1381
1394
|
}
|
|
1382
|
-
function
|
|
1383
|
-
return e === 0 ? null :
|
|
1395
|
+
function ts(e) {
|
|
1396
|
+
return e === 0 ? null : mt(gt(e), "eyes_standard");
|
|
1384
1397
|
}
|
|
1385
|
-
function es(e, t) {
|
|
1386
|
-
return Jr(e, t).map(Zr).filter((n) => n != null);
|
|
1387
|
-
}
|
|
1388
|
-
const ts = 6;
|
|
1389
1398
|
function ns(e, t) {
|
|
1399
|
+
return Xr(e, t).map(ts).filter((n) => n != null);
|
|
1400
|
+
}
|
|
1401
|
+
const rs = 6;
|
|
1402
|
+
function ss(e, t) {
|
|
1390
1403
|
for (const n of e)
|
|
1391
1404
|
if (t >= n.wtime && t < n.wtime + n.wduration)
|
|
1392
1405
|
return n;
|
|
1393
1406
|
return null;
|
|
1394
1407
|
}
|
|
1395
|
-
function
|
|
1408
|
+
function is(e) {
|
|
1396
1409
|
const t = ye(e);
|
|
1397
|
-
return t >=
|
|
1410
|
+
return t >= ct ? ct : ye(t + rs);
|
|
1398
1411
|
}
|
|
1399
|
-
function
|
|
1412
|
+
function os(e, t, n) {
|
|
1400
1413
|
const r = ye(n);
|
|
1401
|
-
return
|
|
1414
|
+
return ss(t, e)?.emphasis ? is(r) : r;
|
|
1402
1415
|
}
|
|
1403
|
-
function
|
|
1416
|
+
function Wt(e) {
|
|
1404
1417
|
if (!e) return 0;
|
|
1405
1418
|
const t = e.match(/^brow_(-?\d+)\//);
|
|
1406
1419
|
if (!t?.[1]) return null;
|
|
1407
1420
|
const n = Number.parseInt(t[1], 10);
|
|
1408
1421
|
return Number.isFinite(n) ? ye(n) : null;
|
|
1409
1422
|
}
|
|
1410
|
-
function
|
|
1423
|
+
function Oe(e, t) {
|
|
1411
1424
|
return e + Math.random() * (t - e);
|
|
1412
1425
|
}
|
|
1413
|
-
function
|
|
1414
|
-
return
|
|
1426
|
+
function We() {
|
|
1427
|
+
return Oe(14, 32);
|
|
1415
1428
|
}
|
|
1416
|
-
function
|
|
1429
|
+
function as(e = {}) {
|
|
1417
1430
|
const {
|
|
1418
1431
|
initialDelayMs: t = 800 + Math.random() * 1200,
|
|
1419
1432
|
intervalMinMs: n = 2200,
|
|
@@ -1425,130 +1438,130 @@ function is(e = {}) {
|
|
|
1425
1438
|
postEmotionChangeDelayMs: f = 380,
|
|
1426
1439
|
minDwellMs: l = 550
|
|
1427
1440
|
} = e;
|
|
1428
|
-
let w = "neutral", _ = "neutral", m = 0,
|
|
1441
|
+
let w = "neutral", _ = "neutral", m = 0, v = 0, k = 0, u = {
|
|
1429
1442
|
kind: "idle",
|
|
1430
1443
|
nextBlinkAt: performance.now() + t
|
|
1431
1444
|
}, p = null, d = "__eyes_open__|neutral|brow:0";
|
|
1432
1445
|
function I(y = w) {
|
|
1433
|
-
d = `${p ?? "__eyes_open__"}|${y}|brow:${
|
|
1446
|
+
d = `${p ?? "__eyes_open__"}|${y}|brow:${v}`;
|
|
1434
1447
|
}
|
|
1435
|
-
function
|
|
1448
|
+
function S(y, T = w) {
|
|
1436
1449
|
p = y;
|
|
1437
|
-
const g =
|
|
1438
|
-
g != null ?
|
|
1450
|
+
const g = Wt(y);
|
|
1451
|
+
g != null ? v = g : y == null && (v = 0), I(T);
|
|
1439
1452
|
}
|
|
1440
1453
|
function R(y) {
|
|
1441
|
-
return
|
|
1454
|
+
return ln(y);
|
|
1442
1455
|
}
|
|
1443
|
-
function
|
|
1444
|
-
const
|
|
1445
|
-
if (m = b,
|
|
1446
|
-
|
|
1456
|
+
function q(y, T, g) {
|
|
1457
|
+
const x = ye(T), b = ye(g);
|
|
1458
|
+
if (m = b, x === b) {
|
|
1459
|
+
S(R(b));
|
|
1447
1460
|
return;
|
|
1448
1461
|
}
|
|
1449
1462
|
const D = [
|
|
1450
|
-
...
|
|
1463
|
+
...ns(x, b),
|
|
1451
1464
|
R(b)
|
|
1452
1465
|
];
|
|
1453
1466
|
u = {
|
|
1454
1467
|
kind: "browBlend",
|
|
1455
1468
|
paths: D,
|
|
1456
1469
|
index: 0,
|
|
1457
|
-
holdUntil: y +
|
|
1470
|
+
holdUntil: y + We(),
|
|
1458
1471
|
targetBrow: b
|
|
1459
|
-
},
|
|
1472
|
+
}, S(D[0] ?? null);
|
|
1460
1473
|
}
|
|
1461
|
-
function
|
|
1474
|
+
function N(y, T) {
|
|
1462
1475
|
u = {
|
|
1463
1476
|
kind: "idle",
|
|
1464
|
-
nextBlinkAt: y +
|
|
1465
|
-
}, _ = T,
|
|
1477
|
+
nextBlinkAt: y + Oe(n, r)
|
|
1478
|
+
}, _ = T, S(R(m), T);
|
|
1466
1479
|
}
|
|
1467
|
-
function
|
|
1468
|
-
const
|
|
1480
|
+
function V(y, T, g) {
|
|
1481
|
+
const x = g ? zr : Math.random() < a ? Gr : Yr;
|
|
1469
1482
|
u = {
|
|
1470
1483
|
kind: "playing",
|
|
1471
|
-
paths:
|
|
1484
|
+
paths: es(T, x),
|
|
1472
1485
|
index: 0,
|
|
1473
|
-
holdUntil: y +
|
|
1486
|
+
holdUntil: y + We(),
|
|
1474
1487
|
after: "idle",
|
|
1475
1488
|
blinkEmotion: T
|
|
1476
|
-
}, _ = T,
|
|
1489
|
+
}, _ = T, S(u.paths[0] ?? null, T);
|
|
1477
1490
|
}
|
|
1478
|
-
function
|
|
1491
|
+
function z(y) {
|
|
1479
1492
|
if (u.kind === "browBlend") {
|
|
1480
1493
|
for (; y >= u.holdUntil && u.index < u.paths.length - 1; )
|
|
1481
|
-
u.index += 1, u.holdUntil = y +
|
|
1494
|
+
u.index += 1, u.holdUntil = y + We();
|
|
1482
1495
|
const T = u.paths[u.index] ?? null;
|
|
1483
|
-
|
|
1496
|
+
S(T), y >= u.holdUntil && u.index >= u.paths.length - 1 && (v = u.targetBrow, m = u.targetBrow, S(R(u.targetBrow)), u = {
|
|
1484
1497
|
kind: "idle",
|
|
1485
1498
|
nextBlinkAt: y + f
|
|
1486
1499
|
});
|
|
1487
1500
|
return;
|
|
1488
1501
|
}
|
|
1489
1502
|
if (u.kind === "idle") {
|
|
1490
|
-
|
|
1503
|
+
S(R(m), _), y >= u.nextBlinkAt && V(y, _, !1);
|
|
1491
1504
|
return;
|
|
1492
1505
|
}
|
|
1493
1506
|
if (u.kind === "doublePause") {
|
|
1494
|
-
|
|
1507
|
+
S(R(m), u.blinkEmotion), y >= u.resumeAt && V(y, u.blinkEmotion, !0);
|
|
1495
1508
|
return;
|
|
1496
1509
|
}
|
|
1497
1510
|
if (u.kind === "playing") {
|
|
1498
1511
|
for (; y >= u.holdUntil && u.index < u.paths.length - 1; )
|
|
1499
|
-
u.index += 1, u.holdUntil = y +
|
|
1500
|
-
if (
|
|
1512
|
+
u.index += 1, u.holdUntil = y + We();
|
|
1513
|
+
if (S(u.paths[u.index] ?? null, u.blinkEmotion), y >= u.holdUntil && u.index >= u.paths.length - 1) {
|
|
1501
1514
|
if (u.after === "resumeIdle") {
|
|
1502
|
-
|
|
1515
|
+
N(y + f, w);
|
|
1503
1516
|
return;
|
|
1504
1517
|
}
|
|
1505
1518
|
if (u.after === "doublePause") {
|
|
1506
1519
|
u = {
|
|
1507
1520
|
kind: "doublePause",
|
|
1508
|
-
resumeAt: y +
|
|
1521
|
+
resumeAt: y + Oe(i, o),
|
|
1509
1522
|
blinkEmotion: u.blinkEmotion
|
|
1510
|
-
},
|
|
1523
|
+
}, S(R(m), u.blinkEmotion);
|
|
1511
1524
|
return;
|
|
1512
1525
|
}
|
|
1513
1526
|
if (u.after === "idle" && Math.random() < s) {
|
|
1514
1527
|
u = {
|
|
1515
1528
|
kind: "doublePause",
|
|
1516
|
-
resumeAt: y +
|
|
1529
|
+
resumeAt: y + Oe(i, o),
|
|
1517
1530
|
blinkEmotion: u.blinkEmotion
|
|
1518
|
-
},
|
|
1531
|
+
}, S(R(m), u.blinkEmotion);
|
|
1519
1532
|
return;
|
|
1520
1533
|
}
|
|
1521
|
-
|
|
1534
|
+
N(y, u.blinkEmotion);
|
|
1522
1535
|
}
|
|
1523
1536
|
}
|
|
1524
1537
|
}
|
|
1525
1538
|
return {
|
|
1526
|
-
advance:
|
|
1539
|
+
advance: z,
|
|
1527
1540
|
setTargetEmotion(y) {
|
|
1528
|
-
const T =
|
|
1541
|
+
const T = be(y, w);
|
|
1529
1542
|
if (T === w) return;
|
|
1530
1543
|
const g = performance.now();
|
|
1531
|
-
l > 0 && T !== w && !(w === "neutral" && T !== "neutral") && g -
|
|
1544
|
+
l > 0 && T !== w && !(w === "neutral" && T !== "neutral") && g - k < l || (w = T, _ = T, k = g);
|
|
1532
1545
|
},
|
|
1533
1546
|
setTargetEyebrow(y) {
|
|
1534
1547
|
const T = ye(y);
|
|
1535
1548
|
if (T === m && u.kind !== "browBlend") return;
|
|
1536
|
-
const g = performance.now(),
|
|
1537
|
-
m = T, !(T ===
|
|
1549
|
+
const g = performance.now(), x = u.kind === "browBlend" ? Wt(p) ?? v : v;
|
|
1550
|
+
m = T, !(T === x && u.kind !== "browBlend") && (u.kind === "playing" || u.kind === "doublePause" || q(g, x, T));
|
|
1538
1551
|
},
|
|
1539
1552
|
getTargetEmotion: () => w,
|
|
1540
1553
|
getTargetEyebrow: () => m,
|
|
1541
1554
|
getExpressionPath: () => p,
|
|
1542
1555
|
getDrawKey: () => d,
|
|
1543
1556
|
reset() {
|
|
1544
|
-
w = "neutral", _ = "neutral", m = 0,
|
|
1545
|
-
performance.now() +
|
|
1557
|
+
w = "neutral", _ = "neutral", m = 0, v = 0, k = 0, N(
|
|
1558
|
+
performance.now() + Oe(n, r),
|
|
1546
1559
|
"neutral"
|
|
1547
1560
|
);
|
|
1548
1561
|
}
|
|
1549
1562
|
};
|
|
1550
1563
|
}
|
|
1551
|
-
function
|
|
1564
|
+
function cs() {
|
|
1552
1565
|
const e = document.createElement("video");
|
|
1553
1566
|
e.muted = !0, e.playsInline = !0, e.preload = "auto", e.setAttribute("playsinline", ""), e.loop = !0;
|
|
1554
1567
|
let t = !1, n = null, r = "";
|
|
@@ -1591,17 +1604,17 @@ function os() {
|
|
|
1591
1604
|
}
|
|
1592
1605
|
};
|
|
1593
1606
|
}
|
|
1594
|
-
const
|
|
1595
|
-
function
|
|
1607
|
+
const us = 50, dn = 400;
|
|
1608
|
+
function ls(e, t, n) {
|
|
1596
1609
|
return e.filter((r) => {
|
|
1597
1610
|
const s = r.queueIndex ?? -1;
|
|
1598
1611
|
return s >= t && s <= n;
|
|
1599
1612
|
});
|
|
1600
1613
|
}
|
|
1601
|
-
function
|
|
1614
|
+
function fs(e, t) {
|
|
1602
1615
|
const n = [];
|
|
1603
1616
|
for (const r of e) {
|
|
1604
|
-
const s =
|
|
1617
|
+
const s = ls(
|
|
1605
1618
|
t,
|
|
1606
1619
|
r.start_word,
|
|
1607
1620
|
r.end_word
|
|
@@ -1610,30 +1623,30 @@ function us(e, t) {
|
|
|
1610
1623
|
const i = s[0], o = s[s.length - 1];
|
|
1611
1624
|
n.push({
|
|
1612
1625
|
sentence: r,
|
|
1613
|
-
startMs: Math.max(0, i.wtime -
|
|
1614
|
-
endMs: o.wtime + o.wduration +
|
|
1626
|
+
startMs: Math.max(0, i.wtime - us),
|
|
1627
|
+
endMs: o.wtime + o.wduration + dn
|
|
1615
1628
|
});
|
|
1616
1629
|
}
|
|
1617
1630
|
return n.sort((r, s) => r.startMs - s.startMs);
|
|
1618
1631
|
}
|
|
1619
|
-
function
|
|
1620
|
-
const s =
|
|
1632
|
+
function ds(e, t, n, r = "neutral") {
|
|
1633
|
+
const s = be(r);
|
|
1621
1634
|
if (t.length === 0) return s;
|
|
1622
1635
|
if (n.length === 0 || e < n[0].wtime)
|
|
1623
|
-
return
|
|
1624
|
-
const i =
|
|
1636
|
+
return be(t[0]?.emotion, s);
|
|
1637
|
+
const i = fs(t, n);
|
|
1625
1638
|
let o = null;
|
|
1626
1639
|
for (const l of i)
|
|
1627
1640
|
e >= l.startMs && e <= l.endMs && (o = l);
|
|
1628
1641
|
if (o)
|
|
1629
|
-
return
|
|
1642
|
+
return be(o.sentence.emotion, s);
|
|
1630
1643
|
const a = n[n.length - 1], f = a.wtime + a.wduration;
|
|
1631
|
-
return e > f +
|
|
1644
|
+
return e > f + dn ? be(
|
|
1632
1645
|
t[t.length - 1]?.emotion,
|
|
1633
1646
|
s
|
|
1634
1647
|
) : s;
|
|
1635
1648
|
}
|
|
1636
|
-
function
|
|
1649
|
+
function hn(e, t, n, r, s = an) {
|
|
1637
1650
|
const i = new OffscreenCanvas(n, r), o = i.getContext("2d", { willReadFrequently: !0 });
|
|
1638
1651
|
o.drawImage(e, 0, 0, n, r);
|
|
1639
1652
|
const a = o.getImageData(0, 0, n, r), f = o.createImageData(n, r);
|
|
@@ -1642,45 +1655,45 @@ function dn(e, t, n, r, s = on) {
|
|
|
1642
1655
|
for (const _ of t) {
|
|
1643
1656
|
w.clearRect(0, 0, n, r), w.drawImage(_, 0, 0, n, r);
|
|
1644
1657
|
const m = w.getImageData(0, 0, n, r);
|
|
1645
|
-
for (let
|
|
1646
|
-
const
|
|
1647
|
-
Math.max(
|
|
1658
|
+
for (let v = 0; v < f.data.length; v += 4) {
|
|
1659
|
+
const k = m.data[v], u = m.data[v + 1], p = m.data[v + 2];
|
|
1660
|
+
Math.max(k, u, p) > s && (f.data[v] = k, f.data[v + 1] = u, f.data[v + 2] = p, f.data[v + 3] = 255);
|
|
1648
1661
|
}
|
|
1649
1662
|
}
|
|
1650
1663
|
return o.putImageData(f, 0, 0), i;
|
|
1651
1664
|
}
|
|
1652
|
-
let pe = null,
|
|
1653
|
-
const
|
|
1654
|
-
function
|
|
1655
|
-
pe = null,
|
|
1665
|
+
let pe = null, Fe = null;
|
|
1666
|
+
const Ke = /* @__PURE__ */ new Map();
|
|
1667
|
+
function hs() {
|
|
1668
|
+
pe = null, Fe = null, Ke.clear();
|
|
1656
1669
|
}
|
|
1657
|
-
|
|
1658
|
-
function
|
|
1659
|
-
return e ??
|
|
1670
|
+
Zn(hs);
|
|
1671
|
+
function ms(e) {
|
|
1672
|
+
return e ?? Fe ?? void 0;
|
|
1660
1673
|
}
|
|
1661
|
-
function
|
|
1674
|
+
function pt(e) {
|
|
1662
1675
|
return new Promise((t, n) => {
|
|
1663
1676
|
const r = new Image();
|
|
1664
1677
|
r.decoding = "async", r.onload = () => t(r), r.onerror = () => n(new Error(`Failed to load image: ${e}`)), r.src = e;
|
|
1665
1678
|
});
|
|
1666
1679
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
return
|
|
1669
|
-
await Ye(
|
|
1670
|
-
) :
|
|
1680
|
+
async function ws(e) {
|
|
1681
|
+
return je() ? Or(
|
|
1682
|
+
await Ye(Mt(), e ?? "")
|
|
1683
|
+
) : pt(Mt());
|
|
1671
1684
|
}
|
|
1672
|
-
async function
|
|
1673
|
-
const s = n ? await
|
|
1685
|
+
async function Ht(e, t, n, r) {
|
|
1686
|
+
const s = n ? await Br(e, r) : await fetch(e).then((l) => {
|
|
1674
1687
|
if (!l.ok) throw new Error(`Failed to load ${e}`);
|
|
1675
1688
|
return l.json();
|
|
1676
1689
|
}), i = s.sheets?.[0];
|
|
1677
1690
|
if (!i?.path) throw new Error(`${e} has no sheets[0].path`);
|
|
1678
|
-
const o = n ? await
|
|
1691
|
+
const o = n ? await Lr(
|
|
1679
1692
|
await Ye(
|
|
1680
|
-
|
|
1693
|
+
Kr(t, i.path, n),
|
|
1681
1694
|
r ?? ""
|
|
1682
1695
|
)
|
|
1683
|
-
) : await
|
|
1696
|
+
) : await pt(`${t}/${i.path}`), a = /* @__PURE__ */ new Map();
|
|
1684
1697
|
for (const l of s.cells ?? [])
|
|
1685
1698
|
l.path && a.set(l.path, l);
|
|
1686
1699
|
const f = /* @__PURE__ */ new Map();
|
|
@@ -1688,30 +1701,30 @@ async function Wt(e, t, n, r) {
|
|
|
1688
1701
|
f.set(l.index, l);
|
|
1689
1702
|
return { atlas: o, atlasMeta: s, cellByPath: a, sheetByIndex: f, diffBase: t };
|
|
1690
1703
|
}
|
|
1691
|
-
async function
|
|
1692
|
-
const t =
|
|
1704
|
+
async function ut(e) {
|
|
1705
|
+
const t = ms(e), n = je();
|
|
1693
1706
|
if (n && !t)
|
|
1694
1707
|
throw new Error("Encrypted assets enabled but no key provided");
|
|
1695
|
-
if (pe && (!n ||
|
|
1708
|
+
if (pe && (!n || Fe === (t ?? null))) {
|
|
1696
1709
|
const i = await pe;
|
|
1697
1710
|
return {
|
|
1698
|
-
...
|
|
1711
|
+
...Ue(i),
|
|
1699
1712
|
visemePaths: [...i.viseme.cellByPath.keys()]
|
|
1700
1713
|
};
|
|
1701
1714
|
}
|
|
1702
|
-
|
|
1703
|
-
const r =
|
|
1715
|
+
Fe = t ?? null, Ke.clear();
|
|
1716
|
+
const r = tr();
|
|
1704
1717
|
pe = (async () => {
|
|
1705
|
-
const i = await
|
|
1706
|
-
|
|
1718
|
+
const i = await ws(t), o = await Ht(
|
|
1719
|
+
nr(),
|
|
1707
1720
|
r,
|
|
1708
1721
|
n,
|
|
1709
1722
|
t
|
|
1710
1723
|
);
|
|
1711
1724
|
let a = null;
|
|
1712
1725
|
try {
|
|
1713
|
-
a = await
|
|
1714
|
-
|
|
1726
|
+
a = await Ht(
|
|
1727
|
+
rr(),
|
|
1715
1728
|
r,
|
|
1716
1729
|
n,
|
|
1717
1730
|
t
|
|
@@ -1722,89 +1735,89 @@ async function at(e) {
|
|
|
1722
1735
|
return { sil: i, viseme: o, expression: a };
|
|
1723
1736
|
})();
|
|
1724
1737
|
const s = await pe;
|
|
1725
|
-
return { ...
|
|
1738
|
+
return { ...Ue(s), visemePaths: [...s.viseme.cellByPath.keys()] };
|
|
1726
1739
|
}
|
|
1727
|
-
async function
|
|
1728
|
-
if (await
|
|
1740
|
+
async function mn(e) {
|
|
1741
|
+
if (await ut(e), !pe) throw new Error("Assets not loaded");
|
|
1729
1742
|
return pe;
|
|
1730
1743
|
}
|
|
1731
|
-
function
|
|
1732
|
-
return
|
|
1744
|
+
function Ue(e) {
|
|
1745
|
+
return xr(
|
|
1733
1746
|
e.viseme.atlasMeta,
|
|
1734
1747
|
e.sil.naturalWidth,
|
|
1735
1748
|
e.sil.naturalHeight
|
|
1736
1749
|
);
|
|
1737
1750
|
}
|
|
1738
|
-
function
|
|
1751
|
+
function gs(e, t) {
|
|
1739
1752
|
const n = document.createElement("canvas");
|
|
1740
1753
|
return n.width = t.w, n.height = t.h, n.getContext("2d", { willReadFrequently: !0 }).drawImage(e.atlas, t.x, t.y, t.w, t.h, 0, 0, t.w, t.h), n;
|
|
1741
1754
|
}
|
|
1742
|
-
async function
|
|
1743
|
-
const r = `${t.diffBase}::${n}`, s =
|
|
1755
|
+
async function qt(e, t, n) {
|
|
1756
|
+
const r = `${t.diffBase}::${n}`, s = Ke.get(r);
|
|
1744
1757
|
if (s) return s;
|
|
1745
1758
|
const i = (async () => {
|
|
1746
1759
|
const o = t.cellByPath.get(n);
|
|
1747
1760
|
if (!o) throw new Error(`No atlas cell for path: ${n}`);
|
|
1748
|
-
const a = Mr(t.atlasMeta, o), f =
|
|
1749
|
-
if (
|
|
1750
|
-
const _ =
|
|
1761
|
+
const a = Mr(t.atlasMeta, o), f = Ue(e);
|
|
1762
|
+
if (Pr(o)) {
|
|
1763
|
+
const _ = gs(t, o), m = document.createElement("canvas");
|
|
1751
1764
|
m.width = f.width, m.height = f.height;
|
|
1752
|
-
const
|
|
1753
|
-
return
|
|
1765
|
+
const v = m.getContext("2d");
|
|
1766
|
+
return v.fillStyle = "#000", v.fillRect(0, 0, f.width, f.height), v.drawImage(_, a.x, a.y), m;
|
|
1754
1767
|
}
|
|
1755
|
-
const l = `${t.diffBase}/${n}`, w = await
|
|
1768
|
+
const l = `${t.diffBase}/${n}`, w = await pt(l);
|
|
1756
1769
|
if (w.naturalWidth === f.width && w.naturalHeight === f.height)
|
|
1757
1770
|
return w;
|
|
1758
1771
|
throw new Error(`Diff PNG wrong size for ${n}`);
|
|
1759
1772
|
})();
|
|
1760
|
-
return
|
|
1773
|
+
return Ke.set(r, i), i;
|
|
1761
1774
|
}
|
|
1762
|
-
async function
|
|
1775
|
+
async function Kt(e, t, n, r, s, i) {
|
|
1763
1776
|
if (s) {
|
|
1764
|
-
const { width:
|
|
1777
|
+
const { width: v, height: k } = s;
|
|
1765
1778
|
if (i && !i() || t.readyState < HTMLMediaElement.HAVE_CURRENT_DATA)
|
|
1766
1779
|
return;
|
|
1767
1780
|
const u = document.createElement("canvas");
|
|
1768
|
-
u.width =
|
|
1781
|
+
u.width = v, u.height = k;
|
|
1769
1782
|
const p = u.getContext("2d");
|
|
1770
|
-
if (p.clearRect(0, 0,
|
|
1771
|
-
(e.width !==
|
|
1783
|
+
if (p.clearRect(0, 0, v, k), p.drawImage(t, 0, 0, v, k), i && !i()) return;
|
|
1784
|
+
(e.width !== v || e.height !== k) && (e.width = v, e.height = k);
|
|
1772
1785
|
const d = e.getContext("2d");
|
|
1773
|
-
d.clearRect(0, 0,
|
|
1786
|
+
d.clearRect(0, 0, v, k), d.drawImage(u, 0, 0);
|
|
1774
1787
|
return;
|
|
1775
1788
|
}
|
|
1776
|
-
const o = await
|
|
1789
|
+
const o = await mn(), a = cn(o.viseme.atlasMeta), { width: f, height: l } = Ue(o);
|
|
1777
1790
|
(e.width !== f || e.height !== l) && (e.width = f, e.height = l);
|
|
1778
1791
|
const w = [], _ = e.getContext("2d");
|
|
1779
1792
|
if (_.clearRect(0, 0, f, l), t.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1780
|
-
const
|
|
1781
|
-
_.drawImage(
|
|
1793
|
+
const v = o.sil;
|
|
1794
|
+
_.drawImage(v, 0, 0, f, l);
|
|
1782
1795
|
return;
|
|
1783
1796
|
}
|
|
1784
1797
|
if (w.length === 0) {
|
|
1785
1798
|
_.drawImage(t, 0, 0, f, l);
|
|
1786
1799
|
return;
|
|
1787
1800
|
}
|
|
1788
|
-
const m =
|
|
1801
|
+
const m = hn(t, w, f, l, a);
|
|
1789
1802
|
_.drawImage(m, 0, 0);
|
|
1790
1803
|
}
|
|
1791
|
-
async function
|
|
1792
|
-
const r = await
|
|
1804
|
+
async function lt(e, t, n) {
|
|
1805
|
+
const r = await mn(Fe ?? void 0), s = cn(r.viseme.atlasMeta), { width: i, height: o } = Ue(r);
|
|
1793
1806
|
(e.width !== i || e.height !== o) && (e.width = i, e.height = o);
|
|
1794
1807
|
const a = [];
|
|
1795
1808
|
if (t.mouthPath) {
|
|
1796
|
-
const w = new Set(r.viseme.cellByPath.keys()), _ =
|
|
1797
|
-
_ && a.push(await
|
|
1809
|
+
const w = new Set(r.viseme.cellByPath.keys()), _ = Vr(t.mouthPath, w) ?? (w.has(t.mouthPath) ? t.mouthPath : null);
|
|
1810
|
+
_ && a.push(await qt(r, r.viseme, _));
|
|
1798
1811
|
}
|
|
1799
1812
|
t.expressionPath && r.expression && a.push(
|
|
1800
|
-
await
|
|
1813
|
+
await qt(r, r.expression, t.expressionPath)
|
|
1801
1814
|
);
|
|
1802
1815
|
const f = e.getContext("2d");
|
|
1803
1816
|
if (f.clearRect(0, 0, i, o), a.length === 0) {
|
|
1804
1817
|
f.drawImage(r.sil, 0, 0, i, o);
|
|
1805
1818
|
return;
|
|
1806
1819
|
}
|
|
1807
|
-
const l =
|
|
1820
|
+
const l = hn(
|
|
1808
1821
|
r.sil,
|
|
1809
1822
|
a,
|
|
1810
1823
|
i,
|
|
@@ -1813,75 +1826,81 @@ async function ct(e, t, n) {
|
|
|
1813
1826
|
);
|
|
1814
1827
|
f.drawImage(l, 0, 0);
|
|
1815
1828
|
}
|
|
1816
|
-
async function
|
|
1817
|
-
await
|
|
1829
|
+
async function _s(e) {
|
|
1830
|
+
await lt(e, { mouthPath: null, expressionPath: null });
|
|
1818
1831
|
}
|
|
1819
|
-
function
|
|
1832
|
+
function ps(e) {
|
|
1820
1833
|
const t = /* @__PURE__ */ new Map();
|
|
1821
1834
|
for (const n of e)
|
|
1822
1835
|
t.has(n.vtime) || t.set(n.vtime, n);
|
|
1823
1836
|
return [...t.values()].sort((n, r) => n.vtime - r.vtime);
|
|
1824
1837
|
}
|
|
1825
|
-
function
|
|
1826
|
-
const t =
|
|
1838
|
+
function ys(e) {
|
|
1839
|
+
const t = ps(e), n = [];
|
|
1827
1840
|
for (let r = 0; r < t.length - 1; r++) {
|
|
1828
1841
|
const s = t[r].viseme, i = t[r + 1].viseme, o = t[r].vtime, a = t[r + 1].vtime;
|
|
1829
1842
|
s === i || a <= o || n.push({ from: s, to: i, fromVtime: o, toVtime: a });
|
|
1830
1843
|
}
|
|
1831
1844
|
return n;
|
|
1832
1845
|
}
|
|
1833
|
-
function
|
|
1846
|
+
function Es(e, t) {
|
|
1834
1847
|
let n = null;
|
|
1835
1848
|
for (const r of e)
|
|
1836
1849
|
t >= r.fromVtime && t < r.toVtime && (n = r);
|
|
1837
1850
|
return n;
|
|
1838
1851
|
}
|
|
1839
|
-
function
|
|
1852
|
+
function Ss(e, t) {
|
|
1840
1853
|
return { gapMs: Math.max(0, t - e), holdEnd: e, transStart: e };
|
|
1841
1854
|
}
|
|
1842
|
-
const
|
|
1843
|
-
function
|
|
1844
|
-
return e.lastDrawnKey ? e.lastDrawnKey.split("|")[0] ===
|
|
1855
|
+
const wn = 400, ks = 200, vs = 600, gn = "__sil__";
|
|
1856
|
+
function bs(e) {
|
|
1857
|
+
return e.lastDrawnKey ? e.lastDrawnKey.split("|")[0] === gn : !1;
|
|
1845
1858
|
}
|
|
1846
|
-
function
|
|
1859
|
+
function Ts() {
|
|
1847
1860
|
return { lastDrawnKey: "" };
|
|
1848
1861
|
}
|
|
1849
|
-
function
|
|
1862
|
+
function de(e) {
|
|
1850
1863
|
e.lastDrawnKey = "", e.transitionCache = void 0;
|
|
1851
1864
|
}
|
|
1852
|
-
function
|
|
1865
|
+
function As(e, t) {
|
|
1853
1866
|
if (t?.transitionCache && t.transitionCache.queueLength === e.length)
|
|
1854
1867
|
return t.transitionCache.transitions;
|
|
1855
|
-
const n =
|
|
1868
|
+
const n = ys(e);
|
|
1856
1869
|
return t && (t.transitionCache = { queueLength: e.length, transitions: n }), n;
|
|
1857
1870
|
}
|
|
1858
|
-
function
|
|
1859
|
-
let
|
|
1860
|
-
for (const
|
|
1861
|
-
|
|
1862
|
-
return
|
|
1871
|
+
function Is(e, t) {
|
|
1872
|
+
let n = "sil";
|
|
1873
|
+
for (const r of e)
|
|
1874
|
+
r.viseme !== "sil" && (t != null && r.vtime > t || (n = r.viseme));
|
|
1875
|
+
return n;
|
|
1863
1876
|
}
|
|
1864
|
-
function
|
|
1865
|
-
|
|
1877
|
+
function Rs(e, t, n, r = 120) {
|
|
1878
|
+
if (n !== "sil")
|
|
1879
|
+
return n;
|
|
1880
|
+
const s = kr(e, t, r);
|
|
1881
|
+
return s !== "sil" ? s : Is(e, t);
|
|
1882
|
+
}
|
|
1883
|
+
function Ds(e, t) {
|
|
1884
|
+
return e === "sil" ? !1 : t ? $r(e, "sil", t) : wt(e, "sil").length > 0;
|
|
1866
1885
|
}
|
|
1867
|
-
function
|
|
1868
|
-
return
|
|
1886
|
+
function Cs() {
|
|
1887
|
+
return wn + vs;
|
|
1869
1888
|
}
|
|
1870
|
-
function
|
|
1871
|
-
return e ??
|
|
1889
|
+
function jt(e) {
|
|
1890
|
+
return e ?? gn;
|
|
1872
1891
|
}
|
|
1873
|
-
function
|
|
1892
|
+
function xs(e, t, n, r) {
|
|
1874
1893
|
if (e.length === 0)
|
|
1875
1894
|
return { diffPath: null, label: "sil" };
|
|
1876
|
-
const s =
|
|
1895
|
+
const s = As(e, r), i = Es(s, t);
|
|
1877
1896
|
if (i) {
|
|
1878
|
-
const a = i.toVtime - i.fromVtime, f =
|
|
1897
|
+
const a = i.toVtime - i.fromVtime, f = Ss(i.fromVtime, i.toVtime);
|
|
1879
1898
|
if (t >= f.transStart && t < i.toVtime) {
|
|
1880
|
-
let l =
|
|
1881
|
-
n && (l =
|
|
1882
|
-
const w =
|
|
1899
|
+
let l = wt(i.from, i.to);
|
|
1900
|
+
n && (l = un(l, n));
|
|
1901
|
+
const w = Hr(l, a);
|
|
1883
1902
|
if (w.length > 0) {
|
|
1884
|
-
const _ =
|
|
1903
|
+
const _ = qr(
|
|
1885
1904
|
t,
|
|
1886
1905
|
f.transStart,
|
|
1887
1906
|
i.toVtime,
|
|
@@ -1889,34 +1908,34 @@ function Rs(e, t, n, r) {
|
|
|
1889
1908
|
);
|
|
1890
1909
|
return { diffPath: w[_] ?? w[w.length - 1], label: `${i.from}→${i.to}` };
|
|
1891
1910
|
}
|
|
1892
|
-
return { diffPath:
|
|
1911
|
+
return { diffPath: qe(i.to), label: i.to };
|
|
1893
1912
|
}
|
|
1894
1913
|
}
|
|
1895
|
-
const o =
|
|
1896
|
-
return o === "sil" ? { diffPath: null, label: "sil" } : { diffPath:
|
|
1914
|
+
const o = ze(e, t);
|
|
1915
|
+
return o === "sil" ? { diffPath: null, label: "sil" } : { diffPath: qe(o), label: o };
|
|
1897
1916
|
}
|
|
1898
|
-
function
|
|
1899
|
-
const n = t ??
|
|
1900
|
-
return `${
|
|
1917
|
+
function _n(e, t) {
|
|
1918
|
+
const n = t ?? jt(e.expressionPath);
|
|
1919
|
+
return `${jt(e.mouthPath)}|${n}`;
|
|
1901
1920
|
}
|
|
1902
|
-
function
|
|
1903
|
-
const w =
|
|
1921
|
+
function Ms(e, t, n, r, s, i, o, a, f, l) {
|
|
1922
|
+
const w = xs(t, n, f, i), _ = {
|
|
1904
1923
|
mouthPath: w.diffPath,
|
|
1905
1924
|
expressionPath: r
|
|
1906
|
-
}, m =
|
|
1907
|
-
m !== i.lastDrawnKey && (a(w.label), o(e, _, m, (
|
|
1908
|
-
|
|
1925
|
+
}, m = _n(_, s);
|
|
1926
|
+
m !== i.lastDrawnKey && (a(w.label), o(e, _, m, (v) => {
|
|
1927
|
+
v === m && (i.lastDrawnKey = m);
|
|
1909
1928
|
}));
|
|
1910
1929
|
}
|
|
1911
|
-
function
|
|
1912
|
-
const a = { mouthPath: null, expressionPath: t }, f = o != null ? `|idle@${Math.round(o * 1e3)}` : "", l =
|
|
1930
|
+
function Gt(e, t, n, r, s, i, o = null) {
|
|
1931
|
+
const a = { mouthPath: null, expressionPath: t }, f = o != null ? `|idle@${Math.round(o * 1e3)}` : "", l = _n(a, n) + f;
|
|
1913
1932
|
!(o != null) && l === r.lastDrawnKey || (i(
|
|
1914
1933
|
o != null ? "idle" : "sil"
|
|
1915
1934
|
), s(e, a, l, (_) => {
|
|
1916
1935
|
_ === l && (r.lastDrawnKey = l);
|
|
1917
1936
|
}));
|
|
1918
1937
|
}
|
|
1919
|
-
function
|
|
1938
|
+
function pn(e) {
|
|
1920
1939
|
let t = 0, n = null, r = !1, s = !1;
|
|
1921
1940
|
const i = async () => {
|
|
1922
1941
|
if (!r) {
|
|
@@ -1952,9 +1971,9 @@ function _n(e) {
|
|
|
1952
1971
|
}
|
|
1953
1972
|
};
|
|
1954
1973
|
}
|
|
1955
|
-
const
|
|
1956
|
-
async function
|
|
1957
|
-
let t =
|
|
1974
|
+
const zt = -1, Yt = /* @__PURE__ */ new Map();
|
|
1975
|
+
async function Ps(e) {
|
|
1976
|
+
let t = Yt.get(e);
|
|
1958
1977
|
if (!t) {
|
|
1959
1978
|
const n = await fetch(e);
|
|
1960
1979
|
if (!n.ok)
|
|
@@ -1962,32 +1981,32 @@ async function Ms(e) {
|
|
|
1962
1981
|
`Failed to fetch worker script (${n.status}): ${e}`
|
|
1963
1982
|
);
|
|
1964
1983
|
const r = await n.blob();
|
|
1965
|
-
t = URL.createObjectURL(r),
|
|
1984
|
+
t = URL.createObjectURL(r), Yt.set(e, t);
|
|
1966
1985
|
}
|
|
1967
1986
|
return new Worker(t, { name: "visemeDiffPreview" });
|
|
1968
1987
|
}
|
|
1969
|
-
function
|
|
1988
|
+
function Bs() {
|
|
1970
1989
|
return typeof Worker < "u" && typeof OffscreenCanvas < "u";
|
|
1971
1990
|
}
|
|
1972
|
-
function
|
|
1991
|
+
function Ls(e, t) {
|
|
1973
1992
|
(e.width !== t.width || e.height !== t.height) && (e.width = t.width, e.height = t.height);
|
|
1974
1993
|
const n = e.getContext("2d");
|
|
1975
1994
|
n && n.drawImage(t, 0, 0);
|
|
1976
1995
|
}
|
|
1977
|
-
function
|
|
1996
|
+
function Jt(e, t) {
|
|
1978
1997
|
let n = 0, r = null;
|
|
1979
|
-
const s =
|
|
1998
|
+
const s = pn(async (i, o) => (await ut(), await lt(e, i), s.isLatestSeq(o)));
|
|
1980
1999
|
return {
|
|
1981
2000
|
usesWorker: !1,
|
|
1982
2001
|
async loadAssets(i) {
|
|
1983
|
-
const o = await
|
|
2002
|
+
const o = await ut(i);
|
|
1984
2003
|
return r = o.visemePaths ? new Set(o.visemePaths) : null, o;
|
|
1985
2004
|
},
|
|
1986
2005
|
getVisemeAtlasPaths() {
|
|
1987
2006
|
return r;
|
|
1988
2007
|
},
|
|
1989
2008
|
async renderSilOnly() {
|
|
1990
|
-
n += 1, s.reset(), await
|
|
2009
|
+
n += 1, s.reset(), await _s(e);
|
|
1991
2010
|
},
|
|
1992
2011
|
drawLiveFrame(i, o, a, f) {
|
|
1993
2012
|
s.enqueue(o, a, f);
|
|
@@ -1995,8 +2014,8 @@ function Yt(e, t) {
|
|
|
1995
2014
|
async renderViseme(i, o) {
|
|
1996
2015
|
n += 1;
|
|
1997
2016
|
const a = n;
|
|
1998
|
-
t.onStatus?.(o), await
|
|
1999
|
-
mouthPath:
|
|
2017
|
+
t.onStatus?.(o), await lt(i, {
|
|
2018
|
+
mouthPath: qe(o),
|
|
2000
2019
|
expressionPath: null
|
|
2001
2020
|
});
|
|
2002
2021
|
},
|
|
@@ -2005,12 +2024,12 @@ function Yt(e, t) {
|
|
|
2005
2024
|
}
|
|
2006
2025
|
};
|
|
2007
2026
|
}
|
|
2008
|
-
function
|
|
2027
|
+
function Os(e, t, n) {
|
|
2009
2028
|
let r = null, s = 1, i = 0, o = !1, a = !1, f = null;
|
|
2010
|
-
const l = /* @__PURE__ */ new Map(), w =
|
|
2029
|
+
const l = /* @__PURE__ */ new Map(), w = pn(async (p, d, I) => (l.set(d, {
|
|
2011
2030
|
drawKey: I.drawKey,
|
|
2012
2031
|
onDisplayed: I.onDisplayed
|
|
2013
|
-
}), await
|
|
2032
|
+
}), await k(
|
|
2014
2033
|
{
|
|
2015
2034
|
type: "drawFrame",
|
|
2016
2035
|
diffPath: p.mouthPath,
|
|
@@ -2020,30 +2039,30 @@ function Ps(e, t, n) {
|
|
|
2020
2039
|
void 0,
|
|
2021
2040
|
!0
|
|
2022
2041
|
), !1)), _ = (p) => {
|
|
2023
|
-
if (p ===
|
|
2024
|
-
let
|
|
2025
|
-
for (const [
|
|
2026
|
-
|
|
2027
|
-
|
|
2042
|
+
if (p === zt) {
|
|
2043
|
+
let S = -1, R;
|
|
2044
|
+
for (const [q, N] of l)
|
|
2045
|
+
q >= S && (S = q, R = N);
|
|
2046
|
+
S >= 0 && l.delete(S), R?.onDisplayed?.(R.drawKey);
|
|
2028
2047
|
return;
|
|
2029
2048
|
}
|
|
2030
2049
|
const d = -p, I = l.get(d);
|
|
2031
2050
|
l.delete(d), I?.onDisplayed?.(I.drawKey);
|
|
2032
|
-
}, m = /* @__PURE__ */ new Map(),
|
|
2051
|
+
}, m = /* @__PURE__ */ new Map(), v = (p, d) => {
|
|
2033
2052
|
a || !r || r.postMessage(p, []);
|
|
2034
|
-
},
|
|
2053
|
+
}, k = (p, d, I = !1) => {
|
|
2035
2054
|
if (a) return Promise.resolve();
|
|
2036
|
-
const
|
|
2037
|
-
return new Promise((R,
|
|
2038
|
-
m.set(
|
|
2039
|
-
resolve: (
|
|
2040
|
-
reject:
|
|
2055
|
+
const S = s++;
|
|
2056
|
+
return new Promise((R, q) => {
|
|
2057
|
+
m.set(S, {
|
|
2058
|
+
resolve: (N) => R(N),
|
|
2059
|
+
reject: q,
|
|
2041
2060
|
generation: typeof p.generation == "number" ? p.generation : void 0,
|
|
2042
2061
|
expectRenderDone: I
|
|
2043
|
-
}),
|
|
2062
|
+
}), v({ ...p, requestId: S });
|
|
2044
2063
|
});
|
|
2045
2064
|
}, u = (async () => {
|
|
2046
|
-
r = await
|
|
2065
|
+
r = await Ps(n), r.onmessage = (p) => {
|
|
2047
2066
|
if (a) return;
|
|
2048
2067
|
const d = p.data;
|
|
2049
2068
|
if (d.type === "status") {
|
|
@@ -2051,23 +2070,23 @@ function Ps(e, t, n) {
|
|
|
2051
2070
|
return;
|
|
2052
2071
|
}
|
|
2053
2072
|
if (d.type === "frame") {
|
|
2054
|
-
const
|
|
2055
|
-
if (!
|
|
2073
|
+
const S = d.generation < 0;
|
|
2074
|
+
if (!S && d.generation !== i) {
|
|
2056
2075
|
d.bitmap.close();
|
|
2057
2076
|
return;
|
|
2058
2077
|
}
|
|
2059
|
-
if (
|
|
2060
|
-
const
|
|
2061
|
-
if (!w.isLatestSeq(
|
|
2078
|
+
if (S && !(d.generation === zt)) {
|
|
2079
|
+
const q = -d.generation;
|
|
2080
|
+
if (!w.isLatestSeq(q)) {
|
|
2062
2081
|
d.bitmap.close();
|
|
2063
2082
|
return;
|
|
2064
2083
|
}
|
|
2065
2084
|
}
|
|
2066
|
-
if (
|
|
2085
|
+
if (S && t.shouldAcceptLiveFrame && !t.shouldAcceptLiveFrame()) {
|
|
2067
2086
|
d.bitmap.close();
|
|
2068
2087
|
return;
|
|
2069
2088
|
}
|
|
2070
|
-
|
|
2089
|
+
Ls(e, d.bitmap), d.bitmap.close(), S && _(d.generation);
|
|
2071
2090
|
return;
|
|
2072
2091
|
}
|
|
2073
2092
|
const I = m.get(d.requestId);
|
|
@@ -2098,7 +2117,7 @@ function Ps(e, t, n) {
|
|
|
2098
2117
|
for (const [, I] of m)
|
|
2099
2118
|
I.reject(new Error(d));
|
|
2100
2119
|
m.clear();
|
|
2101
|
-
}, await
|
|
2120
|
+
}, await k({ type: "init" }), o = !0;
|
|
2102
2121
|
})();
|
|
2103
2122
|
return {
|
|
2104
2123
|
usesWorker: !0,
|
|
@@ -2106,10 +2125,10 @@ function Ps(e, t, n) {
|
|
|
2106
2125
|
if (a) return { width: 842, height: 1264 };
|
|
2107
2126
|
if (await u, a) return { width: 842, height: 1264 };
|
|
2108
2127
|
if (!o) throw new Error("Worker init failed");
|
|
2109
|
-
return await
|
|
2128
|
+
return await k({
|
|
2110
2129
|
type: "loadAssets",
|
|
2111
2130
|
keyHex: p,
|
|
2112
|
-
urls:
|
|
2131
|
+
urls: Xn(Ee())
|
|
2113
2132
|
}) ?? { width: 842, height: 1264 };
|
|
2114
2133
|
},
|
|
2115
2134
|
getVisemeAtlasPaths() {
|
|
@@ -2119,26 +2138,26 @@ function Ps(e, t, n) {
|
|
|
2119
2138
|
if (a || (await u, a)) return;
|
|
2120
2139
|
i += 1, w.reset(), l.clear();
|
|
2121
2140
|
const p = i;
|
|
2122
|
-
await
|
|
2141
|
+
await k({ type: "cancelLiveDraws" }), await k(
|
|
2123
2142
|
{ type: "renderSil", generation: p },
|
|
2124
2143
|
void 0,
|
|
2125
2144
|
!0
|
|
2126
2145
|
);
|
|
2127
2146
|
},
|
|
2128
|
-
drawLiveFrame(p, d, I,
|
|
2147
|
+
drawLiveFrame(p, d, I, S) {
|
|
2129
2148
|
a || u.then(() => {
|
|
2130
|
-
a || w.enqueue(d, I,
|
|
2149
|
+
a || w.enqueue(d, I, S);
|
|
2131
2150
|
});
|
|
2132
2151
|
},
|
|
2133
2152
|
async renderViseme(p, d, I = {}) {
|
|
2134
2153
|
if (a || (await u, a)) return;
|
|
2135
2154
|
i += 1, w.reset(), l.clear();
|
|
2136
|
-
const
|
|
2155
|
+
const S = i;
|
|
2137
2156
|
try {
|
|
2138
|
-
await
|
|
2157
|
+
await k({ type: "cancelLiveDraws" }), await k(
|
|
2139
2158
|
{
|
|
2140
2159
|
type: "renderViseme",
|
|
2141
|
-
generation:
|
|
2160
|
+
generation: S,
|
|
2142
2161
|
to: d,
|
|
2143
2162
|
from: I.from,
|
|
2144
2163
|
transitionDurationMs: I.transitionDurationMs,
|
|
@@ -2163,25 +2182,25 @@ function Ps(e, t, n) {
|
|
|
2163
2182
|
}
|
|
2164
2183
|
};
|
|
2165
2184
|
}
|
|
2166
|
-
function
|
|
2167
|
-
if (!
|
|
2168
|
-
return
|
|
2169
|
-
const n =
|
|
2185
|
+
function Fs(e, t = {}) {
|
|
2186
|
+
if (!Bs())
|
|
2187
|
+
return Jt(e, t);
|
|
2188
|
+
const n = Bn(t.workerScriptUrl);
|
|
2170
2189
|
try {
|
|
2171
|
-
return
|
|
2190
|
+
return Os(e, t, n);
|
|
2172
2191
|
} catch {
|
|
2173
|
-
return
|
|
2192
|
+
return Jt(e, t);
|
|
2174
2193
|
}
|
|
2175
2194
|
}
|
|
2176
|
-
class
|
|
2195
|
+
class Us extends Error {
|
|
2177
2196
|
constructor(t, n) {
|
|
2178
2197
|
super(`${t} timed out after ${Math.round(n / 1e3)}s`), this.name = "LoadTimeoutError";
|
|
2179
2198
|
}
|
|
2180
2199
|
}
|
|
2181
|
-
function
|
|
2200
|
+
function rt(e, t, n) {
|
|
2182
2201
|
return new Promise((r, s) => {
|
|
2183
2202
|
const i = globalThis.setTimeout(() => {
|
|
2184
|
-
s(new
|
|
2203
|
+
s(new Us(n, t));
|
|
2185
2204
|
}, t);
|
|
2186
2205
|
e.then(
|
|
2187
2206
|
(o) => {
|
|
@@ -2193,15 +2212,15 @@ function tt(e, t, n) {
|
|
|
2193
2212
|
);
|
|
2194
2213
|
});
|
|
2195
2214
|
}
|
|
2196
|
-
const
|
|
2215
|
+
const Ns = {
|
|
2197
2216
|
position: "relative",
|
|
2198
2217
|
display: "inline-block",
|
|
2199
2218
|
lineHeight: 0
|
|
2200
|
-
},
|
|
2219
|
+
}, Vs = {
|
|
2201
2220
|
display: "block",
|
|
2202
2221
|
maxWidth: "100%",
|
|
2203
2222
|
height: "auto"
|
|
2204
|
-
},
|
|
2223
|
+
}, $s = {
|
|
2205
2224
|
position: "absolute",
|
|
2206
2225
|
inset: 0,
|
|
2207
2226
|
display: "flex",
|
|
@@ -2213,78 +2232,78 @@ const Os = {
|
|
|
2213
2232
|
fontSize: "0.875rem",
|
|
2214
2233
|
textAlign: "center"
|
|
2215
2234
|
};
|
|
2216
|
-
function
|
|
2217
|
-
return
|
|
2235
|
+
function Le(e) {
|
|
2236
|
+
return Un(e) ? vr : rn;
|
|
2218
2237
|
}
|
|
2219
|
-
function
|
|
2238
|
+
function ge(e, t) {
|
|
2220
2239
|
return t?.isSpeaking() ? t : e.isSpeaking() ? e : t?.isConnected() ? t : e;
|
|
2221
2240
|
}
|
|
2222
|
-
const
|
|
2241
|
+
const Qs = bn(function({
|
|
2223
2242
|
id: t,
|
|
2224
2243
|
avatarId: n,
|
|
2225
2244
|
faceId: r,
|
|
2226
2245
|
assets: s,
|
|
2227
2246
|
authToken: i,
|
|
2228
|
-
ttsEngineId: o =
|
|
2247
|
+
ttsEngineId: o = Ae,
|
|
2229
2248
|
voiceId: a,
|
|
2230
|
-
speakingRate: f =
|
|
2249
|
+
speakingRate: f = ht,
|
|
2231
2250
|
className: l,
|
|
2232
2251
|
style: w,
|
|
2233
2252
|
canvasStyle: _,
|
|
2234
2253
|
onStatusChange: m,
|
|
2235
|
-
onDisplayStatus:
|
|
2236
|
-
onError:
|
|
2254
|
+
onDisplayStatus: v,
|
|
2255
|
+
onError: k,
|
|
2237
2256
|
onReady: u,
|
|
2238
2257
|
showErrorOverlay: p = !0,
|
|
2239
2258
|
onUserTranscript: d,
|
|
2240
2259
|
onBotOutput: I,
|
|
2241
|
-
onRealtimeLipsyncDebug:
|
|
2260
|
+
onRealtimeLipsyncDebug: S
|
|
2242
2261
|
}, R) {
|
|
2243
|
-
const
|
|
2262
|
+
const q = O(null), N = O(null), V = O(Ts()), z = O(as()), y = O(0), T = O(0), g = O(0), x = O(null), b = O(null), D = O(!1), A = O(!1), P = O(!1), F = O("sil"), W = O(0), G = O(!1), H = O(
|
|
2244
2263
|
null
|
|
2245
|
-
),
|
|
2246
|
-
|
|
2247
|
-
const
|
|
2264
|
+
), Y = O(!1), [J, he] = Be("idle"), [te, c] = Be(null), [E, L] = Be(!1), [X, ne] = Be(!1), [Se, se] = Be({ width: 842, height: 1264 }), ue = O(i ?? null), le = O(null), re = O(null), De = O(!1), Je = O({ width: 842, height: 1264 }), Qe = O(null), yt = O(u), Z = O(v), Et = O(k), St = O(d), kt = O(I), vt = O(S);
|
|
2265
|
+
yt.current = u, Z.current = v, Et.current = k, St.current = d, kt.current = I, vt.current = S;
|
|
2266
|
+
const bt = ae(
|
|
2248
2267
|
(h) => {
|
|
2249
|
-
const
|
|
2250
|
-
return { ttsEngineId:
|
|
2268
|
+
const C = h?.ttsEngineId ?? o ?? re.current?.ttsEngineId ?? Ae, M = h?.voiceId ?? a ?? re.current?.voiceId ?? Le(C);
|
|
2269
|
+
return { ttsEngineId: C, voiceId: M };
|
|
2251
2270
|
},
|
|
2252
2271
|
[o, a]
|
|
2253
|
-
),
|
|
2254
|
-
|
|
2255
|
-
}, []),
|
|
2272
|
+
), me = ae((h) => {
|
|
2273
|
+
c(h), Et.current?.(h);
|
|
2274
|
+
}, []), Ce = ae(
|
|
2256
2275
|
(h) => {
|
|
2257
|
-
|
|
2276
|
+
he(h), m?.(h);
|
|
2258
2277
|
},
|
|
2259
2278
|
[m]
|
|
2260
|
-
),
|
|
2261
|
-
|
|
2262
|
-
),
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
), i &&
|
|
2267
|
-
|
|
2268
|
-
const h =
|
|
2269
|
-
h && (h.disconnect(),
|
|
2270
|
-
}), [
|
|
2271
|
-
const
|
|
2272
|
-
|
|
2279
|
+
), K = O(
|
|
2280
|
+
Lt(Ce, Te)
|
|
2281
|
+
), j = O(null);
|
|
2282
|
+
ve(() => (K.current = Lt(
|
|
2283
|
+
Ce,
|
|
2284
|
+
Te
|
|
2285
|
+
), i && K.current.setDeveloperToken(i), K.current.setTtsEngineId(o), () => {
|
|
2286
|
+
K.current.stop();
|
|
2287
|
+
const h = j.current;
|
|
2288
|
+
h && (h.disconnect(), j.current = null);
|
|
2289
|
+
}), [Ce, i, o]);
|
|
2290
|
+
const Tt = ae(() => (j.current || (j.current = Cr(
|
|
2291
|
+
Ce,
|
|
2273
2292
|
{
|
|
2274
2293
|
speakingRate: f,
|
|
2275
|
-
onUserTranscript: (h,
|
|
2276
|
-
onBotOutput: (h) =>
|
|
2277
|
-
onLipsyncDebug: (h) =>
|
|
2294
|
+
onUserTranscript: (h, C) => St.current?.(h, C),
|
|
2295
|
+
onBotOutput: (h) => kt.current?.(h),
|
|
2296
|
+
onLipsyncDebug: (h) => vt.current?.(h)
|
|
2278
2297
|
}
|
|
2279
|
-
),
|
|
2280
|
-
|
|
2281
|
-
}, []),
|
|
2298
|
+
), j.current.setTtsEngineId(o)), j.current), [Ce, f, o]), ie = ae(() => {
|
|
2299
|
+
x.current != null && (clearTimeout(x.current), x.current = null);
|
|
2300
|
+
}, []), fe = ae(() => {
|
|
2282
2301
|
b.current != null && (clearTimeout(b.current), b.current = null), P.current = !1;
|
|
2283
|
-
}, []),
|
|
2284
|
-
!
|
|
2285
|
-
if (b.current = null,
|
|
2286
|
-
|
|
2287
|
-
|
|
2302
|
+
}, []), At = ae(() => {
|
|
2303
|
+
!Y.current || !H.current || (fe(), P.current = !0, b.current = setTimeout(() => {
|
|
2304
|
+
if (b.current = null, ge(
|
|
2305
|
+
K.current,
|
|
2306
|
+
j.current
|
|
2288
2307
|
).isSpeaking()) {
|
|
2289
2308
|
P.current = !1;
|
|
2290
2309
|
return;
|
|
@@ -2293,435 +2312,440 @@ const zs = vn(function({
|
|
|
2293
2312
|
P.current = !1;
|
|
2294
2313
|
return;
|
|
2295
2314
|
}
|
|
2296
|
-
const h =
|
|
2315
|
+
const h = H.current;
|
|
2297
2316
|
if (!h) {
|
|
2298
2317
|
P.current = !1;
|
|
2299
2318
|
return;
|
|
2300
2319
|
}
|
|
2301
2320
|
h.restart(), h.setActive(!0);
|
|
2302
|
-
const
|
|
2303
|
-
let
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
},
|
|
2307
|
-
|
|
2321
|
+
const C = h.getVideo();
|
|
2322
|
+
let M = !1;
|
|
2323
|
+
const U = () => {
|
|
2324
|
+
M || (M = !0, C.removeEventListener("playing", B), P.current = !1);
|
|
2325
|
+
}, B = () => {
|
|
2326
|
+
U();
|
|
2308
2327
|
};
|
|
2309
|
-
if (
|
|
2310
|
-
|
|
2328
|
+
if (C.addEventListener("playing", B, { once: !0 }), C.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA && !C.paused) {
|
|
2329
|
+
U();
|
|
2311
2330
|
return;
|
|
2312
2331
|
}
|
|
2313
|
-
setTimeout(
|
|
2314
|
-
},
|
|
2315
|
-
}, [
|
|
2316
|
-
if (ie(),
|
|
2332
|
+
setTimeout(U, 300);
|
|
2333
|
+
}, ks));
|
|
2334
|
+
}, [fe]), xe = ae(() => {
|
|
2335
|
+
if (ie(), Z.current?.("sil"), D.current = !1, !Y.current || !H.current) {
|
|
2317
2336
|
P.current = !1;
|
|
2318
2337
|
return;
|
|
2319
2338
|
}
|
|
2320
|
-
|
|
2321
|
-
}, [ie,
|
|
2339
|
+
At();
|
|
2340
|
+
}, [ie, At]), Xe = ae(
|
|
2322
2341
|
async (h) => {
|
|
2323
|
-
const
|
|
2342
|
+
const C = T.current, M = N.current, U = q.current, B = () => {
|
|
2324
2343
|
h?.fallbackOnly || (D.current = !1);
|
|
2325
2344
|
};
|
|
2326
|
-
if (!
|
|
2327
|
-
|
|
2345
|
+
if (!M || !U || !E) {
|
|
2346
|
+
B();
|
|
2328
2347
|
return;
|
|
2329
2348
|
}
|
|
2330
|
-
if (
|
|
2331
|
-
|
|
2332
|
-
|
|
2349
|
+
if (ge(
|
|
2350
|
+
K.current,
|
|
2351
|
+
j.current
|
|
2333
2352
|
).isSpeaking()) {
|
|
2334
|
-
|
|
2353
|
+
B();
|
|
2335
2354
|
return;
|
|
2336
2355
|
}
|
|
2337
2356
|
if (h?.fallbackOnly) {
|
|
2338
|
-
if (!D.current || (
|
|
2339
|
-
|
|
2340
|
-
|
|
2357
|
+
if (!D.current || (de(V.current), await M.renderSilOnly(), C !== T.current) || ge(
|
|
2358
|
+
K.current,
|
|
2359
|
+
j.current
|
|
2341
2360
|
).isSpeaking())
|
|
2342
2361
|
return;
|
|
2343
|
-
|
|
2362
|
+
xe();
|
|
2344
2363
|
return;
|
|
2345
2364
|
}
|
|
2346
|
-
if (
|
|
2347
|
-
|
|
2365
|
+
if (bs(V.current)) {
|
|
2366
|
+
de(V.current), xe();
|
|
2348
2367
|
return;
|
|
2349
2368
|
}
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
).getVisemeQueue()
|
|
2355
|
-
|
|
2356
|
-
|
|
2369
|
+
const ee = Rs(
|
|
2370
|
+
ge(
|
|
2371
|
+
K.current,
|
|
2372
|
+
j.current
|
|
2373
|
+
).getVisemeQueue(),
|
|
2374
|
+
W.current,
|
|
2375
|
+
F.current
|
|
2376
|
+
), ce = Ds(
|
|
2377
|
+
ee,
|
|
2357
2378
|
Qe.current
|
|
2358
2379
|
);
|
|
2359
|
-
if (
|
|
2360
|
-
if (await
|
|
2361
|
-
|
|
2362
|
-
|
|
2380
|
+
if (de(V.current), !ce) {
|
|
2381
|
+
if (await M.renderSilOnly(), C !== T.current || ge(
|
|
2382
|
+
K.current,
|
|
2383
|
+
j.current
|
|
2363
2384
|
).isSpeaking())
|
|
2364
2385
|
return;
|
|
2365
|
-
|
|
2386
|
+
xe();
|
|
2366
2387
|
return;
|
|
2367
2388
|
}
|
|
2368
2389
|
try {
|
|
2369
|
-
await
|
|
2370
|
-
from:
|
|
2371
|
-
transitionDurationMs:
|
|
2390
|
+
await M.renderViseme(U, "sil", {
|
|
2391
|
+
from: ee,
|
|
2392
|
+
transitionDurationMs: wn
|
|
2372
2393
|
});
|
|
2373
|
-
} catch (
|
|
2374
|
-
if (
|
|
2375
|
-
throw
|
|
2394
|
+
} catch (we) {
|
|
2395
|
+
if (we?.name !== "AbortError")
|
|
2396
|
+
throw we;
|
|
2376
2397
|
}
|
|
2377
|
-
if (
|
|
2378
|
-
|
|
2398
|
+
if (C !== T.current) {
|
|
2399
|
+
B();
|
|
2379
2400
|
return;
|
|
2380
2401
|
}
|
|
2381
|
-
if (
|
|
2382
|
-
|
|
2383
|
-
|
|
2402
|
+
if (ge(
|
|
2403
|
+
K.current,
|
|
2404
|
+
j.current
|
|
2384
2405
|
).isSpeaking()) {
|
|
2385
|
-
|
|
2406
|
+
B();
|
|
2386
2407
|
return;
|
|
2387
2408
|
}
|
|
2388
|
-
|
|
2409
|
+
xe();
|
|
2389
2410
|
},
|
|
2390
|
-
[
|
|
2391
|
-
),
|
|
2411
|
+
[E, xe]
|
|
2412
|
+
), Me = ae(() => {
|
|
2392
2413
|
if (A.current || D.current) return;
|
|
2393
2414
|
A.current = !0, D.current = !0, ie();
|
|
2394
2415
|
const h = T.current;
|
|
2395
2416
|
Xe().finally(() => {
|
|
2396
2417
|
A.current = !1;
|
|
2397
|
-
}),
|
|
2398
|
-
|
|
2399
|
-
},
|
|
2400
|
-
}, [ie, Xe]),
|
|
2418
|
+
}), x.current = setTimeout(() => {
|
|
2419
|
+
x.current = null, h === T.current && Xe({ fallbackOnly: !0 });
|
|
2420
|
+
}, Cs());
|
|
2421
|
+
}, [ie, Xe]), It = ae(async () => {
|
|
2401
2422
|
const h = Math.floor(Date.now() / 1e3);
|
|
2402
|
-
if (
|
|
2403
|
-
return
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2406
|
-
const
|
|
2407
|
-
return
|
|
2408
|
-
key:
|
|
2409
|
-
expiresAt:
|
|
2410
|
-
},
|
|
2423
|
+
if (le.current && h < le.current.expiresAt - 60)
|
|
2424
|
+
return le.current.key;
|
|
2425
|
+
const C = ue.current ?? await nt();
|
|
2426
|
+
ue.current = C, K.current.setDeveloperToken(C);
|
|
2427
|
+
const M = await jn(C, Te);
|
|
2428
|
+
return le.current = {
|
|
2429
|
+
key: M.value,
|
|
2430
|
+
expiresAt: M.expiresAt
|
|
2431
|
+
}, M.value;
|
|
2411
2432
|
}, []);
|
|
2412
|
-
|
|
2413
|
-
i && (
|
|
2414
|
-
}, [i]),
|
|
2415
|
-
|
|
2416
|
-
}, [o]),
|
|
2417
|
-
const h = a ??
|
|
2418
|
-
|
|
2433
|
+
ve(() => {
|
|
2434
|
+
i && (ue.current = i, K.current.setDeveloperToken(i));
|
|
2435
|
+
}, [i]), ve(() => {
|
|
2436
|
+
K.current.setTtsEngineId(o), j.current?.setTtsEngineId(o), re.current && (re.current.ttsEngineId = o);
|
|
2437
|
+
}, [o]), ve(() => {
|
|
2438
|
+
const h = a ?? Le(o);
|
|
2439
|
+
re.current && (re.current.voiceId = h);
|
|
2419
2440
|
}, [a, o]);
|
|
2420
|
-
const
|
|
2421
|
-
() =>
|
|
2441
|
+
const _e = Dt(
|
|
2442
|
+
() => Jn(n, r),
|
|
2422
2443
|
[n, r]
|
|
2423
|
-
),
|
|
2424
|
-
return
|
|
2425
|
-
if (!t && !s && !
|
|
2426
|
-
|
|
2444
|
+
), yn = Dt(() => s ? JSON.stringify(s) : _e ? `face:${_e}` : `id:${t ?? ""}`, [s, _e, t]);
|
|
2445
|
+
return ve(() => {
|
|
2446
|
+
if (!t && !s && !_e) {
|
|
2447
|
+
me("AiTwin requires `assets`, `avatarId`/`faceId`, or `id`");
|
|
2427
2448
|
return;
|
|
2428
2449
|
}
|
|
2429
2450
|
let h = !1;
|
|
2430
|
-
De.current = !1,
|
|
2431
|
-
const
|
|
2432
|
-
if (!
|
|
2433
|
-
let
|
|
2451
|
+
De.current = !1, L(!1), ne(!1), c(null), re.current = null, H.current = null, Y.current = !1;
|
|
2452
|
+
const C = q.current;
|
|
2453
|
+
if (!C) return;
|
|
2454
|
+
let M = null;
|
|
2434
2455
|
return (async () => {
|
|
2435
2456
|
try {
|
|
2436
|
-
let
|
|
2457
|
+
let U, B, ee, ce;
|
|
2437
2458
|
if (s)
|
|
2438
|
-
|
|
2439
|
-
else if (
|
|
2440
|
-
|
|
2459
|
+
U = s, B = o, ee = a ?? Le(B);
|
|
2460
|
+
else if (_e)
|
|
2461
|
+
Z.current?.("loadFace"), U = xt(_e), B = o, ee = a ?? Le(B);
|
|
2441
2462
|
else {
|
|
2442
|
-
|
|
2443
|
-
const
|
|
2444
|
-
|
|
2463
|
+
Z.current?.("getAiTwin");
|
|
2464
|
+
const $ = await rt(
|
|
2465
|
+
Vn(t),
|
|
2445
2466
|
3e4,
|
|
2446
2467
|
"getAiTwin"
|
|
2447
2468
|
);
|
|
2448
2469
|
if (h) return;
|
|
2449
|
-
if (
|
|
2470
|
+
if (!$.faceId?.trim())
|
|
2450
2471
|
throw new Error("getAiTwin returned no faceId");
|
|
2451
|
-
|
|
2472
|
+
B = $.ttsEngineId, ee = a ?? $.voiceId ?? Le(B), ce = $.knowledgeContextId?.trim() || void 0, U = xt($.faceId);
|
|
2452
2473
|
}
|
|
2453
|
-
|
|
2454
|
-
onStatus: (
|
|
2455
|
-
h ||
|
|
2474
|
+
re.current = { ttsEngineId: B, voiceId: ee, personaId: ce }, Qn(U), H.current = cs(), M = Fs(C, {
|
|
2475
|
+
onStatus: ($) => {
|
|
2476
|
+
h || Z.current?.($);
|
|
2456
2477
|
},
|
|
2457
|
-
onError: (
|
|
2458
|
-
h ||
|
|
2478
|
+
onError: ($) => {
|
|
2479
|
+
h || me($);
|
|
2459
2480
|
},
|
|
2460
|
-
shouldAcceptLiveFrame: () =>
|
|
2461
|
-
|
|
2462
|
-
|
|
2481
|
+
shouldAcceptLiveFrame: () => ge(
|
|
2482
|
+
K.current,
|
|
2483
|
+
j.current
|
|
2463
2484
|
).isSpeaking() && !D.current
|
|
2464
|
-
}),
|
|
2465
|
-
const
|
|
2485
|
+
}), N.current = M, Z.current?.("auth");
|
|
2486
|
+
const we = ue.current ?? i ?? await rt(nt(), 3e4, "getAuthToken");
|
|
2466
2487
|
if (h) return;
|
|
2467
|
-
|
|
2468
|
-
const
|
|
2488
|
+
ue.current = we, K.current.setDeveloperToken(we), K.current.setTtsEngineId(B);
|
|
2489
|
+
const Pe = je() ? await It() : void 0;
|
|
2469
2490
|
if (h) return;
|
|
2470
|
-
|
|
2471
|
-
const
|
|
2472
|
-
|
|
2491
|
+
Z.current?.("loadAssets");
|
|
2492
|
+
const Q = await rt(
|
|
2493
|
+
M.loadAssets(Pe),
|
|
2473
2494
|
18e4,
|
|
2474
2495
|
"load face assets"
|
|
2475
2496
|
);
|
|
2476
|
-
if (!h &&
|
|
2477
|
-
Qe.current =
|
|
2478
|
-
h ||
|
|
2497
|
+
if (!h && Q.width > 0 && Q.height > 0 && (Je.current = Q, se(Q)), h) return;
|
|
2498
|
+
Qe.current = M.getVisemeAtlasPaths(), De.current = !0, L(!0), yt.current?.(), M.renderSilOnly().then(() => {
|
|
2499
|
+
h || Z.current?.("sil");
|
|
2479
2500
|
}), (async () => {
|
|
2480
2501
|
try {
|
|
2481
|
-
const
|
|
2482
|
-
if (await
|
|
2483
|
-
|
|
2484
|
-
const
|
|
2485
|
-
await
|
|
2486
|
-
|
|
2487
|
-
|
|
2502
|
+
const $ = await Ur(Pe);
|
|
2503
|
+
if (await H.current.load($), h) return;
|
|
2504
|
+
Y.current = !0, ne(!0), de(V.current), H.current.setActive(!0);
|
|
2505
|
+
const oe = H.current.getVideo();
|
|
2506
|
+
await Kt(
|
|
2507
|
+
C,
|
|
2508
|
+
oe,
|
|
2488
2509
|
null,
|
|
2489
2510
|
void 0,
|
|
2490
2511
|
Je.current
|
|
2491
|
-
), h ||
|
|
2492
|
-
} catch (
|
|
2512
|
+
), h || Z.current?.("idle");
|
|
2513
|
+
} catch ($) {
|
|
2493
2514
|
if (h) return;
|
|
2494
|
-
|
|
2515
|
+
Y.current = !1, ne(!1), console.warn("[AiTwin] Idle video unavailable:", $);
|
|
2495
2516
|
}
|
|
2496
2517
|
})();
|
|
2497
|
-
} catch (
|
|
2518
|
+
} catch (U) {
|
|
2498
2519
|
if (h) return;
|
|
2499
|
-
if (
|
|
2500
|
-
|
|
2520
|
+
if (U instanceof st) {
|
|
2521
|
+
me(U.message);
|
|
2501
2522
|
return;
|
|
2502
2523
|
}
|
|
2503
|
-
|
|
2524
|
+
me(U instanceof Error ? U.message : "Failed to load AI twin");
|
|
2504
2525
|
}
|
|
2505
2526
|
})(), () => {
|
|
2506
|
-
h = !0,
|
|
2527
|
+
h = !0, H.current?.dispose(), M?.dispose(), N.current = null;
|
|
2507
2528
|
};
|
|
2508
|
-
}, [
|
|
2509
|
-
const h = { current: !1 },
|
|
2510
|
-
const
|
|
2511
|
-
|
|
2512
|
-
|
|
2529
|
+
}, [yn, s, _e, t, o, a, i, It, me]), ve(() => {
|
|
2530
|
+
const h = { current: !1 }, C = () => {
|
|
2531
|
+
const M = q.current, U = N.current, B = ge(
|
|
2532
|
+
K.current,
|
|
2533
|
+
j.current
|
|
2513
2534
|
);
|
|
2514
|
-
if (!
|
|
2515
|
-
y.current = requestAnimationFrame(
|
|
2535
|
+
if (!M || !U || !E) {
|
|
2536
|
+
y.current = requestAnimationFrame(C);
|
|
2516
2537
|
return;
|
|
2517
2538
|
}
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
const
|
|
2521
|
-
if (
|
|
2522
|
-
|
|
2523
|
-
const
|
|
2524
|
-
|
|
2525
|
-
const
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2539
|
+
const ee = B.isSpeaking(), ce = ee && !G.current, we = G.current && !ee;
|
|
2540
|
+
ce && (ie(), fe(), D.current = !1, A.current = !1, de(V.current), g.current = 0, F.current = "sil", W.current = 0, H.current?.setActive(!1)), we && (z.current.reset(), H.current?.setActive(!1), Me());
|
|
2541
|
+
const Pe = we || D.current || P.current;
|
|
2542
|
+
if (ee) {
|
|
2543
|
+
Y.current && H.current?.setActive(!1);
|
|
2544
|
+
const Q = B.getVisemeQueue(), $ = B.getPlaybackElapsedMs();
|
|
2545
|
+
W.current = $;
|
|
2546
|
+
const oe = Q.length > 0 ? ze(Q, $) : "sil";
|
|
2547
|
+
oe !== "sil" && (F.current = oe);
|
|
2548
|
+
const ke = ds(
|
|
2549
|
+
$,
|
|
2550
|
+
B.getSentenceEmotions(),
|
|
2551
|
+
B.getWordQueue(),
|
|
2552
|
+
B.getStreamMood()
|
|
2530
2553
|
);
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2554
|
+
z.current.setTargetEmotion(ke), z.current.setTargetEyebrow(
|
|
2555
|
+
os(
|
|
2556
|
+
$,
|
|
2557
|
+
B.getWordQueue(),
|
|
2558
|
+
_t(ke)
|
|
2536
2559
|
)
|
|
2537
|
-
),
|
|
2538
|
-
const
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
Pe,
|
|
2560
|
+
), z.current.advance(performance.now());
|
|
2561
|
+
const Ze = z.current.getExpressionPath(), et = z.current.getDrawKey();
|
|
2562
|
+
Ms(
|
|
2563
|
+
M,
|
|
2564
|
+
Q,
|
|
2565
|
+
$,
|
|
2544
2566
|
Ze,
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
(
|
|
2567
|
+
et,
|
|
2568
|
+
V.current,
|
|
2569
|
+
(tt, En, Sn, kn) => U.drawLiveFrame(tt, En, Sn, kn),
|
|
2570
|
+
(tt) => Z.current?.(tt),
|
|
2548
2571
|
Qe.current
|
|
2549
2572
|
);
|
|
2550
|
-
} else if (!
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2573
|
+
} else if (!Pe && Y.current && H.current) {
|
|
2574
|
+
const Q = H.current, $ = Q.getVideo();
|
|
2575
|
+
$.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA ? (Q.setActive(!0), h.current || (h.current = !0, Kt(
|
|
2576
|
+
M,
|
|
2577
|
+
$,
|
|
2555
2578
|
null,
|
|
2556
2579
|
void 0,
|
|
2557
2580
|
Je.current,
|
|
2558
|
-
() => !
|
|
2559
|
-
).then(() =>
|
|
2581
|
+
() => !B.isSpeaking() && !D.current && !P.current
|
|
2582
|
+
).then(() => Z.current?.("idle")).finally(() => {
|
|
2560
2583
|
h.current = !1;
|
|
2561
|
-
}))) :
|
|
2562
|
-
|
|
2584
|
+
}))) : Gt(
|
|
2585
|
+
M,
|
|
2563
2586
|
null,
|
|
2564
2587
|
"__sil__",
|
|
2565
|
-
|
|
2566
|
-
(
|
|
2567
|
-
(
|
|
2588
|
+
V.current,
|
|
2589
|
+
(oe, ke, Ze, et) => U.drawLiveFrame(oe, ke, Ze, et),
|
|
2590
|
+
(oe) => Z.current?.(oe)
|
|
2568
2591
|
);
|
|
2569
|
-
} else
|
|
2570
|
-
|
|
2592
|
+
} else Pe || Gt(
|
|
2593
|
+
M,
|
|
2571
2594
|
null,
|
|
2572
2595
|
"__sil__",
|
|
2573
|
-
|
|
2574
|
-
(
|
|
2575
|
-
(
|
|
2596
|
+
V.current,
|
|
2597
|
+
(Q, $, oe, ke) => U.drawLiveFrame(Q, $, oe, ke),
|
|
2598
|
+
(Q) => Z.current?.(Q)
|
|
2576
2599
|
);
|
|
2577
|
-
|
|
2600
|
+
G.current = ee, y.current = requestAnimationFrame(C);
|
|
2578
2601
|
};
|
|
2579
|
-
return y.current = requestAnimationFrame(
|
|
2580
|
-
cancelAnimationFrame(y.current), ie(),
|
|
2602
|
+
return y.current = requestAnimationFrame(C), () => {
|
|
2603
|
+
cancelAnimationFrame(y.current), ie(), fe(), K.current.stop(), j.current?.stop();
|
|
2581
2604
|
};
|
|
2582
2605
|
}, [
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2606
|
+
E,
|
|
2607
|
+
X,
|
|
2608
|
+
Me,
|
|
2586
2609
|
ie,
|
|
2587
|
-
|
|
2588
|
-
]),
|
|
2610
|
+
fe
|
|
2611
|
+
]), Tn(
|
|
2589
2612
|
R,
|
|
2590
2613
|
() => ({
|
|
2591
|
-
speakText: async (h,
|
|
2592
|
-
const
|
|
2593
|
-
if (!
|
|
2594
|
-
const
|
|
2595
|
-
if (!
|
|
2614
|
+
speakText: async (h, C) => {
|
|
2615
|
+
const M = h.trim();
|
|
2616
|
+
if (!M) return;
|
|
2617
|
+
const U = N.current;
|
|
2618
|
+
if (!U || !De.current && !E)
|
|
2596
2619
|
throw new Error("AI twin is not ready");
|
|
2597
|
-
const { ttsEngineId:
|
|
2598
|
-
|
|
2620
|
+
const { ttsEngineId: B, voiceId: ee } = bt(C);
|
|
2621
|
+
c(null), T.current += 1, ie(), fe(), D.current = !1, A.current = !1, F.current = "sil", W.current = 0, de(V.current), z.current.reset(), G.current = !1;
|
|
2599
2622
|
try {
|
|
2600
|
-
|
|
2601
|
-
voiceId:
|
|
2602
|
-
speakingRate:
|
|
2603
|
-
ttsEngineId:
|
|
2623
|
+
Y.current ? (H.current?.setActive(!1), H.current?.restart(), de(V.current)) : await U.renderSilOnly(), await K.current.speak(M, {
|
|
2624
|
+
voiceId: ee,
|
|
2625
|
+
speakingRate: C?.speakingRate ?? f,
|
|
2626
|
+
ttsEngineId: B
|
|
2604
2627
|
});
|
|
2605
|
-
} catch (
|
|
2606
|
-
throw
|
|
2628
|
+
} catch (ce) {
|
|
2629
|
+
throw me(ce instanceof Error ? ce.message : "TTS failed"), ce;
|
|
2607
2630
|
}
|
|
2608
2631
|
},
|
|
2609
2632
|
stop: () => {
|
|
2610
|
-
T.current += 1, ie(),
|
|
2633
|
+
T.current += 1, ie(), fe(), D.current = !1, A.current = !1, K.current.stop(), j.current?.stop(), de(V.current), G.current = !1, Me();
|
|
2611
2634
|
},
|
|
2612
2635
|
setTtsEngineId: (h) => {
|
|
2613
|
-
|
|
2636
|
+
K.current.setTtsEngineId(h), j.current?.setTtsEngineId(h), re.current && (re.current.ttsEngineId = h);
|
|
2614
2637
|
},
|
|
2615
|
-
renderViseme: async (h,
|
|
2616
|
-
const
|
|
2617
|
-
if (!
|
|
2638
|
+
renderViseme: async (h, C) => {
|
|
2639
|
+
const M = N.current, U = q.current;
|
|
2640
|
+
if (!M || !U || !De.current)
|
|
2618
2641
|
throw new Error("AI twin is not ready");
|
|
2619
|
-
await
|
|
2620
|
-
from:
|
|
2621
|
-
transitionDurationMs:
|
|
2622
|
-
gapMs:
|
|
2623
|
-
onStatus: (
|
|
2642
|
+
await M.renderViseme(U, h, {
|
|
2643
|
+
from: C?.from,
|
|
2644
|
+
transitionDurationMs: C?.transitionDurationMs,
|
|
2645
|
+
gapMs: C?.gapMs,
|
|
2646
|
+
onStatus: (B) => Z.current?.(B)
|
|
2624
2647
|
});
|
|
2625
2648
|
},
|
|
2626
2649
|
isReady: () => De.current,
|
|
2627
|
-
getStatus: () =>
|
|
2650
|
+
getStatus: () => J,
|
|
2628
2651
|
connect: async (h = {}) => {
|
|
2629
|
-
|
|
2652
|
+
c(null);
|
|
2630
2653
|
try {
|
|
2631
|
-
let
|
|
2632
|
-
|
|
2633
|
-
const
|
|
2634
|
-
await
|
|
2654
|
+
let C = h.authToken?.trim();
|
|
2655
|
+
C || (C = ue.current ?? i ?? await nt(), ue.current = C);
|
|
2656
|
+
const M = h.voiceId?.trim() ?? a ?? re.current?.voiceId, U = h.personaId?.trim() ?? re.current?.personaId, B = Tt();
|
|
2657
|
+
await B.unlockAudio(), await B.connect({
|
|
2635
2658
|
...h,
|
|
2636
|
-
authToken:
|
|
2637
|
-
voiceId:
|
|
2659
|
+
authToken: C,
|
|
2660
|
+
voiceId: M,
|
|
2661
|
+
personaId: U,
|
|
2638
2662
|
speakingRate: h.speakingRate ?? f
|
|
2639
2663
|
});
|
|
2640
|
-
} catch (
|
|
2641
|
-
throw
|
|
2642
|
-
|
|
2643
|
-
),
|
|
2664
|
+
} catch (C) {
|
|
2665
|
+
throw me(
|
|
2666
|
+
C instanceof Error ? C.message : "Voice connect failed"
|
|
2667
|
+
), C;
|
|
2644
2668
|
}
|
|
2645
2669
|
},
|
|
2646
2670
|
disconnect: async () => {
|
|
2647
|
-
const h =
|
|
2648
|
-
h && (T.current += 1, ie(),
|
|
2671
|
+
const h = j.current;
|
|
2672
|
+
h && (T.current += 1, ie(), fe(), D.current = !1, A.current = !1, de(V.current), G.current = !1, await h.disconnect(), Me());
|
|
2649
2673
|
},
|
|
2650
|
-
isConnected: () =>
|
|
2674
|
+
isConnected: () => j.current?.isConnected() ?? !1
|
|
2651
2675
|
}),
|
|
2652
2676
|
[
|
|
2653
|
-
|
|
2677
|
+
E,
|
|
2654
2678
|
f,
|
|
2655
2679
|
i,
|
|
2656
2680
|
a,
|
|
2657
2681
|
ie,
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
vt,
|
|
2682
|
+
fe,
|
|
2683
|
+
Me,
|
|
2684
|
+
me,
|
|
2662
2685
|
bt,
|
|
2663
|
-
|
|
2686
|
+
Tt,
|
|
2687
|
+
J
|
|
2664
2688
|
]
|
|
2665
|
-
), /* @__PURE__ */
|
|
2666
|
-
/* @__PURE__ */
|
|
2689
|
+
), /* @__PURE__ */ vn("div", { className: l, style: { ...Ns, ...w }, children: [
|
|
2690
|
+
/* @__PURE__ */ Rt(
|
|
2667
2691
|
"canvas",
|
|
2668
2692
|
{
|
|
2669
|
-
ref:
|
|
2670
|
-
width:
|
|
2671
|
-
height:
|
|
2672
|
-
style: { ...
|
|
2693
|
+
ref: q,
|
|
2694
|
+
width: Se.width,
|
|
2695
|
+
height: Se.height,
|
|
2696
|
+
style: { ...Vs, ..._ },
|
|
2673
2697
|
"aria-label": t ? `AI twin ${t}` : "AI twin face"
|
|
2674
2698
|
}
|
|
2675
2699
|
),
|
|
2676
|
-
p &&
|
|
2700
|
+
p && te ? /* @__PURE__ */ Rt("div", { style: $s, children: te }) : null
|
|
2677
2701
|
] });
|
|
2678
|
-
}),
|
|
2679
|
-
function
|
|
2702
|
+
}), Ws = "thumbnail.webp";
|
|
2703
|
+
function Xs(e, t = ft) {
|
|
2680
2704
|
const n = e.trim();
|
|
2681
2705
|
if (!n)
|
|
2682
2706
|
throw new Error("faceId is required");
|
|
2683
|
-
return `${t.replace(/\/$/, "")}/${n}/${
|
|
2707
|
+
return `${t.replace(/\/$/, "")}/${n}/${Ws}`;
|
|
2684
2708
|
}
|
|
2685
|
-
const
|
|
2686
|
-
function
|
|
2709
|
+
const Hs = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".webp"]);
|
|
2710
|
+
function qs(e = ".png") {
|
|
2687
2711
|
const t = e.toLowerCase();
|
|
2688
|
-
return
|
|
2712
|
+
return Hs.has(t) ? `source${t}` : "source.png";
|
|
2689
2713
|
}
|
|
2690
|
-
function
|
|
2714
|
+
function Zs(e, t = ft, n = ".png") {
|
|
2691
2715
|
const r = e.trim();
|
|
2692
2716
|
if (!r)
|
|
2693
2717
|
throw new Error("faceId is required");
|
|
2694
|
-
return `${t.replace(/\/$/, "")}/${r}/${
|
|
2718
|
+
return `${t.replace(/\/$/, "")}/${r}/${qs(n)}`;
|
|
2695
2719
|
}
|
|
2696
2720
|
export {
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2721
|
+
Ws as AI_TWIN_THUMBNAIL_FILENAME,
|
|
2722
|
+
Qs as AiTwin,
|
|
2723
|
+
st as AiTwinNotFoundError,
|
|
2724
|
+
Ae as DEFAULT_TTS_ENGINE_ID,
|
|
2725
|
+
sn as MIC_SAMPLE_RATE,
|
|
2726
|
+
ir as OCULUS_VISEME_IDS,
|
|
2727
|
+
on as PLAYBACK_SAMPLE_RATE,
|
|
2728
|
+
nn as SPEAKING_RATE_MAX,
|
|
2729
|
+
tn as SPEAKING_RATE_MIN,
|
|
2730
|
+
Ie as TTS_ENGINE_CARTESIA,
|
|
2731
|
+
Xt as TTS_ENGINE_GOOGLE,
|
|
2732
|
+
dt as TTS_ENGINE_INWORLD,
|
|
2733
|
+
Js as VISEME_IDS,
|
|
2734
|
+
vr as VISEME_TEST_CARTESIA_VOICE_ID,
|
|
2735
|
+
ht as VISEME_TEST_SPEAKING_RATE,
|
|
2736
|
+
rn as VISEME_TEST_VOICE_ID,
|
|
2737
|
+
qs as aiTwinSourceFilename,
|
|
2738
|
+
Rr as buildVoiceWebSocketUrl,
|
|
2739
|
+
Lt as createAvatarTtsLipsyncController,
|
|
2740
|
+
Cr as createRealtimeVoiceLipsyncController,
|
|
2741
|
+
xt as faceAssetUrls,
|
|
2742
|
+
Vn as fetchAiTwin,
|
|
2743
|
+
nt as fetchDevAuthToken,
|
|
2744
|
+
Zs as getAiTwinSourceUrl,
|
|
2745
|
+
Xs as getAiTwinThumbnailUrl,
|
|
2746
|
+
ar as normalizeOculusViseme,
|
|
2747
|
+
Jn as resolveDirectFaceId,
|
|
2748
|
+
ze as resolveVisemeAtTime,
|
|
2749
|
+
Ys as resolveWordAtTime,
|
|
2750
|
+
Qn as setActiveTwinAssets
|
|
2727
2751
|
};
|