orb-ui 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -28
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/livekit/browser.d.ts +44 -0
- package/dist/adapters/livekit/index.d.ts +1 -1
- package/dist/adapters/types.d.ts +2 -2
- package/dist/adapters.cjs +1 -1
- package/dist/adapters.js +156 -394
- package/dist/components/Orb/Orb.d.ts +1 -1
- package/dist/components/Orb/Orb.types.d.ts +7 -13
- package/dist/components/Orb/index.d.ts +1 -1
- package/dist/components/Orb/signals.d.ts +1 -3
- package/dist/index.d.ts +1 -1
- package/dist/livekit-Dasur3lv.js +240 -0
- package/dist/livekit-Ro6A52eb.cjs +1 -0
- package/dist/livekit-adapter.cjs +1 -0
- package/dist/livekit-adapter.js +28 -0
- package/dist/orb-ui.cjs +102 -2
- package/dist/orb-ui.js +332 -114
- package/dist/themes/cloud/CloudTheme.d.ts +14 -0
- package/dist/themes/cloud/index.d.ts +1 -0
- package/dist/themes/index.d.ts +1 -0
- package/package.json +15 -1
package/dist/adapters.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t as e } from "./livekit-Dasur3lv.js";
|
|
1
2
|
//#region src/adapters/vapi/index.ts
|
|
2
|
-
var
|
|
3
|
-
function
|
|
3
|
+
var t = .12;
|
|
4
|
+
function n(e) {
|
|
4
5
|
let t = "idle", n = null;
|
|
5
6
|
function r(r) {
|
|
6
7
|
if (n &&= (clearTimeout(n), null), t === "speaking" && r === "listening") {
|
|
@@ -19,20 +20,20 @@ function t(e) {
|
|
|
19
20
|
clearTimer: i
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function r(e, r) {
|
|
23
24
|
let i = /* @__PURE__ */ new Set(), a = null;
|
|
24
25
|
function o() {
|
|
25
|
-
a || (a =
|
|
26
|
+
a || (a = e.start.bind(e), e.start = async (...e) => (i.forEach((e) => e()), a(...e)));
|
|
26
27
|
}
|
|
27
28
|
function s() {
|
|
28
|
-
i.size > 0 || !a || (
|
|
29
|
+
i.size > 0 || !a || (e.start = a, a = null);
|
|
29
30
|
}
|
|
30
31
|
return {
|
|
31
32
|
async start() {
|
|
32
|
-
await
|
|
33
|
+
await e.start(r?.assistantId);
|
|
33
34
|
},
|
|
34
35
|
stop() {
|
|
35
|
-
|
|
36
|
+
e.stop();
|
|
36
37
|
},
|
|
37
38
|
subscribe(r) {
|
|
38
39
|
let a = {
|
|
@@ -40,8 +41,8 @@ function n(n, r) {
|
|
|
40
41
|
volume: 0,
|
|
41
42
|
outputVolume: 0
|
|
42
43
|
}, c = 0;
|
|
43
|
-
function l(
|
|
44
|
-
let n =
|
|
44
|
+
function l(e) {
|
|
45
|
+
let n = e < t ? 0 : (e - t) / (1 - t), r = n > c ? .8 : .5;
|
|
45
46
|
return c += (n - c) * r, c;
|
|
46
47
|
}
|
|
47
48
|
function u(e) {
|
|
@@ -54,7 +55,7 @@ function n(n, r) {
|
|
|
54
55
|
state: e.state ?? a.state
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
let { emitState: f, clearTimer: p } =
|
|
58
|
+
let { emitState: f, clearTimer: p } = n((e) => d({ state: e })), m = () => f("connecting"), h = "idle", g = !1, _ = () => {
|
|
58
59
|
g = !0, h = "listening", f("listening"), d({
|
|
59
60
|
volume: 0,
|
|
60
61
|
outputVolume: 0
|
|
@@ -96,15 +97,15 @@ function n(n, r) {
|
|
|
96
97
|
error: e
|
|
97
98
|
}), c = 0;
|
|
98
99
|
};
|
|
99
|
-
return
|
|
100
|
-
p(), E(), c = 0,
|
|
100
|
+
return e.on("call-start", _), e.on("call-end", v), e.on("speech-start", y), e.on("speech-end", b), e.on("volume-level", D), e.on("message", O), e.on("error", k), i.add(m), o(), () => {
|
|
101
|
+
p(), E(), c = 0, e.removeListener("call-start", _), e.removeListener("call-end", v), e.removeListener("speech-start", y), e.removeListener("speech-end", b), e.removeListener("volume-level", D), e.removeListener("message", O), e.removeListener("error", k), i.delete(m), s();
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
//#endregion
|
|
106
107
|
//#region src/adapters/elevenlabs/index.ts
|
|
107
|
-
function
|
|
108
|
+
function i(e, t) {
|
|
108
109
|
let n = null, r = 0, i = null, a = null, o = {
|
|
109
110
|
state: "idle",
|
|
110
111
|
volume: 0,
|
|
@@ -243,247 +244,8 @@ function r(e, t) {
|
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
246
|
//#endregion
|
|
246
|
-
//#region src/adapters/types.ts
|
|
247
|
-
function i(e) {
|
|
248
|
-
let t = Math.min(e / .5, 1);
|
|
249
|
-
return t **= 1.3, t;
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region src/adapters/livekit/index.ts
|
|
253
|
-
var a = 4, o = .03, s = 1.5, c = .6, l = .2, u = .35;
|
|
254
|
-
function d(e) {
|
|
255
|
-
switch (e) {
|
|
256
|
-
case "speaking": return "speaking";
|
|
257
|
-
case "thinking": return "thinking";
|
|
258
|
-
case "listening":
|
|
259
|
-
case "idle": return "listening";
|
|
260
|
-
case "connecting":
|
|
261
|
-
case "pre-connect-buffering":
|
|
262
|
-
case "initializing": return "connecting";
|
|
263
|
-
case "disconnected": return "idle";
|
|
264
|
-
case "failed": return "error";
|
|
265
|
-
default: return "idle";
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
function f(e) {
|
|
269
|
-
return "RoomClass" in e;
|
|
270
|
-
}
|
|
271
|
-
function p(e) {
|
|
272
|
-
return typeof e == "function" ? e() : e;
|
|
273
|
-
}
|
|
274
|
-
function m(e) {
|
|
275
|
-
if (!e) return {};
|
|
276
|
-
let t = {}, n = (e, n) => {
|
|
277
|
-
n !== void 0 && (t[e] = n);
|
|
278
|
-
};
|
|
279
|
-
return n("roomName", p(e.roomName)), n("participantName", p(e.participantName)), n("participantIdentity", p(e.participantIdentity)), n("participantMetadata", p(e.participantMetadata)), n("participantAttributes", typeof e.participantAttributes == "function" ? e.participantAttributes() : e.participantAttributes), n("agentName", p(e.agentName)), n("agentMetadata", p(e.agentMetadata)), n("deployment", p(e.deployment)), t;
|
|
280
|
-
}
|
|
281
|
-
function h(e) {
|
|
282
|
-
if (!e.serverUrl || !e.participantToken) throw Error("[orb-ui/livekit] connection details must include serverUrl and participantToken.");
|
|
283
|
-
return e;
|
|
284
|
-
}
|
|
285
|
-
async function g(e) {
|
|
286
|
-
let t = m(e.tokenOptions);
|
|
287
|
-
return typeof e.getConnectionDetails == "function" ? h(await e.getConnectionDetails(t)) : e.tokenSource ? h(await e.tokenSource.fetch(t)) : h({
|
|
288
|
-
serverUrl: e.serverUrl,
|
|
289
|
-
participantToken: e.participantToken
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
function _(e) {
|
|
293
|
-
for (let [, t] of e.remoteParticipants) if (!t.isLocal && (t.kind === a || t.attributes?.["lk.agent.state"] !== void 0)) return t;
|
|
294
|
-
return null;
|
|
295
|
-
}
|
|
296
|
-
function v(e, t, n) {
|
|
297
|
-
let r = e.off;
|
|
298
|
-
if (r) {
|
|
299
|
-
r.call(e, t, n);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
e.removeListener?.call(e, t, n);
|
|
303
|
-
}
|
|
304
|
-
function y(e, t, n) {
|
|
305
|
-
e.on.call(e, t, n);
|
|
306
|
-
}
|
|
307
|
-
function b(e) {
|
|
308
|
-
let t = f(e), n = e.createAudioAnalyser, r = { current: t ? null : e.room }, p = /* @__PURE__ */ new Set(), m = {
|
|
309
|
-
state: "idle",
|
|
310
|
-
volume: 0,
|
|
311
|
-
inputVolume: 0,
|
|
312
|
-
outputVolume: 0
|
|
313
|
-
}, h = "idle", b = null, x = null, S = null, C = null, w = null, T = null, E = null, D = 0, O = null;
|
|
314
|
-
function k(e) {
|
|
315
|
-
m = e, p.forEach((t) => t(e));
|
|
316
|
-
}
|
|
317
|
-
function A(e) {
|
|
318
|
-
k({
|
|
319
|
-
...m,
|
|
320
|
-
...e,
|
|
321
|
-
state: e.state ?? m.state
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
function j(e) {
|
|
325
|
-
let t = e < o ? 0 : e, n = t > D ? c : l;
|
|
326
|
-
D += (t - D) * n;
|
|
327
|
-
let r = Math.min(D * s, 1);
|
|
328
|
-
return r / (r + u);
|
|
329
|
-
}
|
|
330
|
-
function M() {
|
|
331
|
-
D = 0, A({
|
|
332
|
-
volume: 0,
|
|
333
|
-
outputVolume: 0
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
function N({ emitZero: e = !0 } = {}) {
|
|
337
|
-
w &&= (clearInterval(w), null), C &&= (C.cleanup().catch(() => {}), null), e && A({
|
|
338
|
-
volume: 0,
|
|
339
|
-
inputVolume: 0
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
function P(e) {
|
|
343
|
-
if (!(b === e && C)) {
|
|
344
|
-
N({ emitZero: !1 }), b = e;
|
|
345
|
-
try {
|
|
346
|
-
C = n(e);
|
|
347
|
-
} catch (e) {
|
|
348
|
-
console.warn("[orb-ui/livekit] local createAudioAnalyser failed:", e);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
w = setInterval(() => {
|
|
352
|
-
if (!C || h !== "listening") return;
|
|
353
|
-
let e = i(C.calculateVolume());
|
|
354
|
-
A({
|
|
355
|
-
volume: e,
|
|
356
|
-
inputVolume: e,
|
|
357
|
-
outputVolume: 0
|
|
358
|
-
});
|
|
359
|
-
}, 33);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function F({ emitZero: e = !0 } = {}) {
|
|
363
|
-
E &&= (clearInterval(E), null), T &&= (T.cleanup().catch(() => {}), null), D = 0, e && A({
|
|
364
|
-
volume: 0,
|
|
365
|
-
outputVolume: 0
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
function I(e) {
|
|
369
|
-
F();
|
|
370
|
-
try {
|
|
371
|
-
T = n(e);
|
|
372
|
-
} catch (e) {
|
|
373
|
-
console.warn("[orb-ui/livekit] remote createAudioAnalyser failed:", e);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
E = setInterval(() => {
|
|
377
|
-
if (!T || h !== "speaking") return;
|
|
378
|
-
let e = j(T.calculateVolume());
|
|
379
|
-
A({
|
|
380
|
-
volume: e,
|
|
381
|
-
inputVolume: 0,
|
|
382
|
-
outputVolume: e
|
|
383
|
-
});
|
|
384
|
-
}, 33);
|
|
385
|
-
}
|
|
386
|
-
function L(e) {
|
|
387
|
-
h = e, A({
|
|
388
|
-
state: e,
|
|
389
|
-
volume: 0,
|
|
390
|
-
inputVolume: 0,
|
|
391
|
-
outputVolume: 0
|
|
392
|
-
}), e === "speaking" && x ? I(x) : e !== "speaking" && F({ emitZero: !1 });
|
|
393
|
-
}
|
|
394
|
-
function R(e) {
|
|
395
|
-
S || typeof document > "u" || (S = e.attach(), S.id = "orb-ui-livekit-agent-audio", document.body.appendChild(S));
|
|
396
|
-
}
|
|
397
|
-
function z() {
|
|
398
|
-
S &&= (S.remove(), null);
|
|
399
|
-
}
|
|
400
|
-
function B(e) {
|
|
401
|
-
x = e, R(e), h === "speaking" && I(e);
|
|
402
|
-
}
|
|
403
|
-
function V(e) {
|
|
404
|
-
P(e);
|
|
405
|
-
}
|
|
406
|
-
function H(e) {
|
|
407
|
-
let t = e.getTrackPublication?.("microphone");
|
|
408
|
-
t?.track && V(t.track);
|
|
409
|
-
}
|
|
410
|
-
function U(e) {
|
|
411
|
-
let t = d(e);
|
|
412
|
-
t !== h && L(t);
|
|
413
|
-
}
|
|
414
|
-
function W(e) {
|
|
415
|
-
let t = e.attributes?.["lk.agent.state"];
|
|
416
|
-
t && U(t);
|
|
417
|
-
let n = e.getTrackPublication("microphone");
|
|
418
|
-
n?.track && B(n.track);
|
|
419
|
-
}
|
|
420
|
-
function G(e) {
|
|
421
|
-
if (O) return;
|
|
422
|
-
let t = (e, t) => {
|
|
423
|
-
if (t.isLocal) return;
|
|
424
|
-
let n = e["lk.agent.state"];
|
|
425
|
-
n && U(n);
|
|
426
|
-
}, n = (e, t, n) => {
|
|
427
|
-
n.isLocal || !(n.kind === a || n.attributes?.["lk.agent.state"] !== void 0) || e.mediaStreamTrack.kind !== "audio" || B(e);
|
|
428
|
-
}, r = (e) => {
|
|
429
|
-
x === e && (x = null, z(), F());
|
|
430
|
-
}, i = (e) => {
|
|
431
|
-
e.source !== "microphone" || !e.track || V(e.track);
|
|
432
|
-
}, o = (e) => {
|
|
433
|
-
e.source === "microphone" && (b = null, N());
|
|
434
|
-
}, s = () => {
|
|
435
|
-
b = null, x = null, z(), N({ emitZero: !1 }), F({ emitZero: !1 }), L("idle");
|
|
436
|
-
};
|
|
437
|
-
if (y(e, "participantAttributesChanged", t), y(e, "trackSubscribed", n), y(e, "trackUnsubscribed", r), y(e, "localTrackPublished", i), y(e, "localTrackUnpublished", o), y(e, "disconnected", s), O = () => {
|
|
438
|
-
v(e, "participantAttributesChanged", t), v(e, "trackSubscribed", n), v(e, "trackUnsubscribed", r), v(e, "localTrackPublished", i), v(e, "localTrackUnpublished", o), v(e, "disconnected", s);
|
|
439
|
-
}, H(e.localParticipant), e.state === "connected") {
|
|
440
|
-
let t = _(e);
|
|
441
|
-
t ? W(t) : L("connecting");
|
|
442
|
-
} else L("idle");
|
|
443
|
-
}
|
|
444
|
-
function K() {
|
|
445
|
-
O?.(), O = null, b = null, x = null, z(), N({ emitZero: !1 }), F({ emitZero: !1 }), A({
|
|
446
|
-
volume: 0,
|
|
447
|
-
inputVolume: 0,
|
|
448
|
-
outputVolume: 0
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
let q = (e) => {
|
|
452
|
-
p.add(e), e(m);
|
|
453
|
-
let t = r.current;
|
|
454
|
-
return t && G(t), () => {
|
|
455
|
-
p.delete(e), p.size === 0 && K();
|
|
456
|
-
};
|
|
457
|
-
};
|
|
458
|
-
return t ? {
|
|
459
|
-
subscribe: q,
|
|
460
|
-
async start() {
|
|
461
|
-
if (r.current) return;
|
|
462
|
-
let t = e, n = new t.RoomClass();
|
|
463
|
-
L("connecting");
|
|
464
|
-
try {
|
|
465
|
-
let e = await g(t);
|
|
466
|
-
if (await n.connect(e.serverUrl, e.participantToken, t.connectOptions), r.current = n, G(n), t.enableMicrophone !== !1) {
|
|
467
|
-
let e = (await n.localParticipant.setMicrophoneEnabled(!0))?.track ?? n.localParticipant.getTrackPublication?.("microphone")?.track;
|
|
468
|
-
e && V(e);
|
|
469
|
-
}
|
|
470
|
-
} catch (e) {
|
|
471
|
-
throw console.error("[orb-ui/livekit] connect failed:", e), r.current === n && K(), n.disconnect(), r.current = null, L("error"), M(), A({ error: e }), e;
|
|
472
|
-
}
|
|
473
|
-
},
|
|
474
|
-
async stop() {
|
|
475
|
-
let e = r.current;
|
|
476
|
-
if (!e) {
|
|
477
|
-
L("idle");
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
K(), e.disconnect(), r.current = null, L("idle");
|
|
481
|
-
}
|
|
482
|
-
} : { subscribe: q };
|
|
483
|
-
}
|
|
484
|
-
//#endregion
|
|
485
247
|
//#region src/adapters/pipecat/index.ts
|
|
486
|
-
var
|
|
248
|
+
var a = {
|
|
487
249
|
connected: "connected",
|
|
488
250
|
disconnected: "disconnected",
|
|
489
251
|
transportStateChanged: "transportStateChanged",
|
|
@@ -500,8 +262,8 @@ var x = {
|
|
|
500
262
|
userStoppedSpeaking: "userStoppedSpeaking",
|
|
501
263
|
botLlmStarted: "botLlmStarted",
|
|
502
264
|
botTtsStarted: "botTtsStarted"
|
|
503
|
-
},
|
|
504
|
-
function
|
|
265
|
+
}, o = .002, s = 4, c = .8, l = .6, u = .2;
|
|
266
|
+
function d(e) {
|
|
505
267
|
switch (e) {
|
|
506
268
|
case "initializing":
|
|
507
269
|
case "initialized":
|
|
@@ -516,30 +278,30 @@ function D(e) {
|
|
|
516
278
|
default: return;
|
|
517
279
|
}
|
|
518
280
|
}
|
|
519
|
-
function
|
|
520
|
-
if (typeof e != "number" || !Number.isFinite(e) || e <=
|
|
521
|
-
let t = Math.min(1, Math.max(0, e -
|
|
522
|
-
return Math.min(1, t *
|
|
281
|
+
function f(e) {
|
|
282
|
+
if (typeof e != "number" || !Number.isFinite(e) || e <= o) return 0;
|
|
283
|
+
let t = Math.min(1, Math.max(0, e - o));
|
|
284
|
+
return Math.min(1, t * s) ** +c;
|
|
523
285
|
}
|
|
524
|
-
function
|
|
525
|
-
let n =
|
|
286
|
+
function p(e, t) {
|
|
287
|
+
let n = f(e), r = n > t ? l : u;
|
|
526
288
|
return t + (n - t) * r;
|
|
527
289
|
}
|
|
528
|
-
function
|
|
290
|
+
function m(e) {
|
|
529
291
|
return typeof e == "object" && !!e && "kind" in e && typeof e.kind == "string";
|
|
530
292
|
}
|
|
531
|
-
function
|
|
293
|
+
function h(e, t = {}) {
|
|
532
294
|
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = {
|
|
533
|
-
state:
|
|
295
|
+
state: d(e.state ?? "") ?? "idle",
|
|
534
296
|
volume: 0,
|
|
535
297
|
inputVolume: 0,
|
|
536
298
|
outputVolume: 0
|
|
537
|
-
},
|
|
538
|
-
function
|
|
299
|
+
}, o = !1, s = 0, c = 0;
|
|
300
|
+
function l(e) {
|
|
539
301
|
i = e, n.forEach((t) => t(e));
|
|
540
302
|
}
|
|
541
|
-
function
|
|
542
|
-
|
|
303
|
+
function u(e, t) {
|
|
304
|
+
s = 0, c = 0, l({
|
|
543
305
|
state: e,
|
|
544
306
|
volume: 0,
|
|
545
307
|
inputVolume: 0,
|
|
@@ -547,159 +309,159 @@ function j(e, t = {}) {
|
|
|
547
309
|
...t === void 0 ? {} : { error: t }
|
|
548
310
|
});
|
|
549
311
|
}
|
|
550
|
-
function
|
|
312
|
+
function f(e) {
|
|
551
313
|
if (i.state !== "listening") return;
|
|
552
|
-
|
|
553
|
-
let t =
|
|
554
|
-
|
|
314
|
+
s = p(e, s);
|
|
315
|
+
let t = s;
|
|
316
|
+
l({
|
|
555
317
|
...i,
|
|
556
318
|
volume: t,
|
|
557
319
|
inputVolume: t,
|
|
558
320
|
outputVolume: 0
|
|
559
321
|
});
|
|
560
322
|
}
|
|
561
|
-
function
|
|
323
|
+
function h(e, n) {
|
|
562
324
|
if (i.state !== "speaking") return;
|
|
563
325
|
if (n && typeof n == "object") {
|
|
564
326
|
let e = n;
|
|
565
327
|
if (e.local || t.isBotParticipant && !t.isBotParticipant(e)) return;
|
|
566
328
|
}
|
|
567
|
-
|
|
568
|
-
let r =
|
|
569
|
-
|
|
329
|
+
c = p(e, c);
|
|
330
|
+
let r = c;
|
|
331
|
+
l({
|
|
570
332
|
...i,
|
|
571
333
|
volume: r,
|
|
572
334
|
inputVolume: 0,
|
|
573
335
|
outputVolume: r
|
|
574
336
|
});
|
|
575
337
|
}
|
|
576
|
-
function
|
|
338
|
+
function g(e) {
|
|
577
339
|
if (!e || typeof e != "object") return !0;
|
|
578
340
|
let n = e;
|
|
579
341
|
return n.local ? !1 : t.isBotParticipant?.(n) ?? !0;
|
|
580
342
|
}
|
|
581
|
-
function
|
|
582
|
-
if (t.playRemoteAudio === !1 || !
|
|
343
|
+
function _(e, n) {
|
|
344
|
+
if (t.playRemoteAudio === !1 || !m(e) || e.kind !== "audio" || !g(n)) return;
|
|
583
345
|
let i = t.createAudioElement?.() ?? new Audio();
|
|
584
346
|
i.autoplay = !0, i.srcObject = new MediaStream([e]), r.set(e, i), i.play().catch(() => void 0);
|
|
585
347
|
}
|
|
586
|
-
function
|
|
587
|
-
if (!
|
|
348
|
+
function v(e) {
|
|
349
|
+
if (!m(e)) return;
|
|
588
350
|
let t = r.get(e);
|
|
589
351
|
t && (t.pause(), t.srcObject = null, t.remove(), r.delete(e));
|
|
590
352
|
}
|
|
591
|
-
function
|
|
353
|
+
function y() {
|
|
592
354
|
r.forEach((e) => {
|
|
593
355
|
e.pause(), e.srcObject = null, e.remove();
|
|
594
356
|
}), r.clear();
|
|
595
357
|
}
|
|
596
|
-
let
|
|
597
|
-
[
|
|
598
|
-
[
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
358
|
+
let b = [
|
|
359
|
+
[a.connected, () => u("connecting")],
|
|
360
|
+
[a.botReady, () => u("listening")],
|
|
361
|
+
[a.disconnected, () => u("idle")],
|
|
362
|
+
[a.botDisconnected, () => u("idle")],
|
|
363
|
+
[a.transportStateChanged, (e) => {
|
|
602
364
|
if (typeof e != "string") return;
|
|
603
|
-
let t =
|
|
604
|
-
t &&
|
|
365
|
+
let t = d(e);
|
|
366
|
+
t && u(t);
|
|
605
367
|
}],
|
|
606
|
-
[
|
|
607
|
-
[
|
|
608
|
-
i.state === "listening" &&
|
|
368
|
+
[a.userStartedSpeaking, () => u("listening")],
|
|
369
|
+
[a.userStoppedSpeaking, () => {
|
|
370
|
+
i.state === "listening" && u("thinking");
|
|
609
371
|
}],
|
|
610
|
-
[
|
|
611
|
-
[
|
|
612
|
-
[
|
|
613
|
-
[
|
|
614
|
-
[
|
|
615
|
-
[
|
|
616
|
-
["trackStarted",
|
|
617
|
-
["trackStopped",
|
|
618
|
-
[
|
|
619
|
-
[
|
|
620
|
-
[
|
|
372
|
+
[a.botLlmStarted, () => u("thinking")],
|
|
373
|
+
[a.botTtsStarted, () => u("thinking")],
|
|
374
|
+
[a.botStartedSpeaking, () => u("speaking")],
|
|
375
|
+
[a.botStoppedSpeaking, () => u("listening")],
|
|
376
|
+
[a.localAudioLevel, f],
|
|
377
|
+
[a.remoteAudioLevel, h],
|
|
378
|
+
["trackStarted", _],
|
|
379
|
+
["trackStopped", v],
|
|
380
|
+
[a.error, (e) => u("error", e)],
|
|
381
|
+
[a.messageError, (e) => u("error", e)],
|
|
382
|
+
[a.deviceError, (e) => u("error", e)]
|
|
621
383
|
];
|
|
622
|
-
function
|
|
623
|
-
|
|
384
|
+
function x() {
|
|
385
|
+
o || (o = !0, b.forEach(([t, n]) => e.on(t, n)));
|
|
624
386
|
}
|
|
625
|
-
function
|
|
626
|
-
|
|
387
|
+
function S() {
|
|
388
|
+
o && (o = !1, b.forEach(([t, n]) => {
|
|
627
389
|
e.off ? e.off(t, n) : e.removeListener?.(t, n);
|
|
628
|
-
}),
|
|
390
|
+
}), y());
|
|
629
391
|
}
|
|
630
392
|
return {
|
|
631
393
|
subscribe(e) {
|
|
632
|
-
return n.add(e),
|
|
633
|
-
n.delete(e), n.size === 0 &&
|
|
394
|
+
return n.add(e), x(), e(i), () => {
|
|
395
|
+
n.delete(e), n.size === 0 && S();
|
|
634
396
|
};
|
|
635
397
|
},
|
|
636
398
|
async start() {
|
|
637
|
-
|
|
399
|
+
u("connecting");
|
|
638
400
|
try {
|
|
639
401
|
await (t.connect ? t.connect() : e.connect());
|
|
640
402
|
} catch (e) {
|
|
641
|
-
throw
|
|
403
|
+
throw u("error", e), e;
|
|
642
404
|
}
|
|
643
405
|
},
|
|
644
406
|
async stop() {
|
|
645
407
|
try {
|
|
646
408
|
await (t.disconnect ? t.disconnect() : e.disconnect());
|
|
647
409
|
} finally {
|
|
648
|
-
|
|
410
|
+
y(), u("idle");
|
|
649
411
|
}
|
|
650
412
|
}
|
|
651
413
|
};
|
|
652
414
|
}
|
|
653
415
|
//#endregion
|
|
654
416
|
//#region src/adapters/audio-level.ts
|
|
655
|
-
var
|
|
417
|
+
var g = {
|
|
656
418
|
noiseFloor: 0,
|
|
657
419
|
gain: 4,
|
|
658
420
|
exponent: .8,
|
|
659
421
|
attack: 1,
|
|
660
422
|
release: 1
|
|
661
423
|
};
|
|
662
|
-
function
|
|
424
|
+
function _(e, t, n) {
|
|
663
425
|
return Math.min(n, Math.max(t, e));
|
|
664
426
|
}
|
|
665
|
-
function
|
|
427
|
+
function v(e, t) {
|
|
666
428
|
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
667
429
|
}
|
|
668
|
-
function
|
|
430
|
+
function y(e) {
|
|
669
431
|
let t = typeof e == "function" ? e() : e;
|
|
670
432
|
return {
|
|
671
|
-
noiseFloor:
|
|
672
|
-
gain: Math.max(0,
|
|
673
|
-
exponent: Math.max(.01,
|
|
674
|
-
attack:
|
|
675
|
-
release:
|
|
433
|
+
noiseFloor: _(v(t?.noiseFloor, g.noiseFloor), 0, 1),
|
|
434
|
+
gain: Math.max(0, v(t?.gain, g.gain)),
|
|
435
|
+
exponent: Math.max(.01, v(t?.exponent, g.exponent)),
|
|
436
|
+
attack: _(v(t?.attack, g.attack), 0, 1),
|
|
437
|
+
release: _(v(t?.release, g.release), 0, 1)
|
|
676
438
|
};
|
|
677
439
|
}
|
|
678
|
-
function
|
|
679
|
-
let r = Number.isFinite(e) ?
|
|
440
|
+
function b(e, t, n) {
|
|
441
|
+
let r = Number.isFinite(e) ? _(e, 0, 1) : 0, i = y(n), a = _((r <= i.noiseFloor ? 0 : r - i.noiseFloor) * i.gain, 0, 1) ** +i.exponent, o = a > t ? i.attack : i.release;
|
|
680
442
|
return {
|
|
681
443
|
raw: r,
|
|
682
444
|
shaped: a,
|
|
683
|
-
normalized:
|
|
445
|
+
normalized: _(t + (a - t) * o, 0, 1)
|
|
684
446
|
};
|
|
685
447
|
}
|
|
686
448
|
//#endregion
|
|
687
449
|
//#region src/adapters/openai-realtime/index.ts
|
|
688
|
-
var
|
|
450
|
+
var x = "https://api.openai.com/v1/realtime/calls", S = .015, C = 8, w = {
|
|
689
451
|
noiseFloor: .003,
|
|
690
452
|
gain: 4,
|
|
691
453
|
exponent: .8,
|
|
692
454
|
attack: .55,
|
|
693
455
|
release: .1
|
|
694
456
|
};
|
|
695
|
-
function
|
|
457
|
+
function T() {
|
|
696
458
|
let e = window.AudioContext;
|
|
697
459
|
return e ? new e() : void 0;
|
|
698
460
|
}
|
|
699
|
-
function
|
|
461
|
+
function E(e) {
|
|
700
462
|
return Math.min(1, Math.max(0, (e * 4) ** .8));
|
|
701
463
|
}
|
|
702
|
-
function
|
|
464
|
+
function D(e, t, n) {
|
|
703
465
|
try {
|
|
704
466
|
let r = t();
|
|
705
467
|
if (!r) return;
|
|
@@ -718,12 +480,12 @@ function U(e, t, n) {
|
|
|
718
480
|
return;
|
|
719
481
|
}
|
|
720
482
|
}
|
|
721
|
-
function
|
|
483
|
+
function O(e) {
|
|
722
484
|
let t = typeof e == "string" ? e : e.value;
|
|
723
485
|
if (!t) throw Error("[orb-ui/openai-realtime] getClientSecret returned an empty value.");
|
|
724
486
|
return t;
|
|
725
487
|
}
|
|
726
|
-
function
|
|
488
|
+
function k(e) {
|
|
727
489
|
let t = /* @__PURE__ */ new Set(), n = {
|
|
728
490
|
state: "idle",
|
|
729
491
|
volume: 0,
|
|
@@ -733,7 +495,7 @@ function G(e) {
|
|
|
733
495
|
function f() {
|
|
734
496
|
let t = typeof e.outputVolumeCalibration == "function" ? e.outputVolumeCalibration() : e.outputVolumeCalibration;
|
|
735
497
|
return {
|
|
736
|
-
...
|
|
498
|
+
...w,
|
|
737
499
|
...t
|
|
738
500
|
};
|
|
739
501
|
}
|
|
@@ -751,7 +513,7 @@ function G(e) {
|
|
|
751
513
|
}
|
|
752
514
|
function h(e) {
|
|
753
515
|
if (n.state !== "listening") return;
|
|
754
|
-
let t =
|
|
516
|
+
let t = E(e);
|
|
755
517
|
p({
|
|
756
518
|
...n,
|
|
757
519
|
volume: t,
|
|
@@ -760,11 +522,11 @@ function G(e) {
|
|
|
760
522
|
});
|
|
761
523
|
}
|
|
762
524
|
function g(t) {
|
|
763
|
-
let r =
|
|
525
|
+
let r = b(t, u, f);
|
|
764
526
|
u = r.normalized, e.onOutputVolumeSample?.(r);
|
|
765
527
|
let i = r.normalized;
|
|
766
|
-
if (i >
|
|
767
|
-
else if (n.state === "speaking" && (l += 1, l >=
|
|
528
|
+
if (i > S) l = 0, n.state !== "speaking" && m("speaking");
|
|
529
|
+
else if (n.state === "speaking" && (l += 1, l >= C)) {
|
|
768
530
|
l = 0, m("listening");
|
|
769
531
|
return;
|
|
770
532
|
}
|
|
@@ -815,12 +577,12 @@ function G(e) {
|
|
|
815
577
|
if (!r) {
|
|
816
578
|
m("connecting"), d = !1;
|
|
817
579
|
try {
|
|
818
|
-
let t = e.getUserMedia ?? ((e) => navigator.mediaDevices.getUserMedia(e)), n = e.createPeerConnection ?? (() => new RTCPeerConnection()), l = e.fetch ?? fetch, u = e.createAudioElement ?? (() => new Audio()), f = e.createAudioContext ??
|
|
819
|
-
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), s =
|
|
580
|
+
let t = e.getUserMedia ?? ((e) => navigator.mediaDevices.getUserMedia(e)), n = e.createPeerConnection ?? (() => new RTCPeerConnection()), l = e.fetch ?? fetch, u = e.createAudioElement ?? (() => new Audio()), f = e.createAudioContext ?? T, p = O(await e.getClientSecret());
|
|
581
|
+
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), s = D(a, f, h);
|
|
820
582
|
let v = n();
|
|
821
583
|
r = v, a.getAudioTracks().forEach((e) => v.addTrack(e, a)), o = u(), o.autoplay = !0, v.ontrack = (e) => {
|
|
822
584
|
let t = e.streams[0] ?? new MediaStream([e.track]);
|
|
823
|
-
o && (o.srcObject = t), o?.play().catch(() => void 0), c?.stop(), c =
|
|
585
|
+
o && (o.srcObject = t), o?.play().catch(() => void 0), c?.stop(), c = D(t, f, g);
|
|
824
586
|
}, v.onconnectionstatechange = () => {
|
|
825
587
|
d || (v.connectionState === "failed" ? m("error", /* @__PURE__ */ Error("[orb-ui/openai-realtime] WebRTC connection failed.")) : (v.connectionState === "disconnected" || v.connectionState === "closed") && m("idle"));
|
|
826
588
|
};
|
|
@@ -834,7 +596,7 @@ function G(e) {
|
|
|
834
596
|
};
|
|
835
597
|
let b = await v.createOffer();
|
|
836
598
|
await v.setLocalDescription(b);
|
|
837
|
-
let
|
|
599
|
+
let S = await l(e.callsUrl ?? x, {
|
|
838
600
|
method: "POST",
|
|
839
601
|
body: b.sdp,
|
|
840
602
|
headers: {
|
|
@@ -842,13 +604,13 @@ function G(e) {
|
|
|
842
604
|
"Content-Type": "application/sdp"
|
|
843
605
|
}
|
|
844
606
|
});
|
|
845
|
-
if (!
|
|
846
|
-
let e = await
|
|
847
|
-
throw Error(`[orb-ui/openai-realtime] Session negotiation failed (${
|
|
607
|
+
if (!S.ok) {
|
|
608
|
+
let e = await S.text();
|
|
609
|
+
throw Error(`[orb-ui/openai-realtime] Session negotiation failed (${S.status}): ${e}`);
|
|
848
610
|
}
|
|
849
611
|
await v.setRemoteDescription({
|
|
850
612
|
type: "answer",
|
|
851
|
-
sdp: await
|
|
613
|
+
sdp: await S.text()
|
|
852
614
|
});
|
|
853
615
|
} catch (e) {
|
|
854
616
|
throw await v(!1), m("error", e), e;
|
|
@@ -862,22 +624,22 @@ function G(e) {
|
|
|
862
624
|
}
|
|
863
625
|
//#endregion
|
|
864
626
|
//#region src/adapters/gemini-live/index.ts
|
|
865
|
-
var
|
|
627
|
+
var A = 16e3, j = {
|
|
866
628
|
noiseFloor: .003,
|
|
867
629
|
gain: 4,
|
|
868
630
|
exponent: .8,
|
|
869
631
|
attack: .3,
|
|
870
632
|
release: .1
|
|
871
633
|
};
|
|
872
|
-
function
|
|
634
|
+
function M(e) {
|
|
873
635
|
let t = 0;
|
|
874
636
|
for (let n of e) t += n * n;
|
|
875
637
|
return Math.sqrt(t / e.length);
|
|
876
638
|
}
|
|
877
|
-
function
|
|
878
|
-
return Math.min(1, Math.max(0, (
|
|
639
|
+
function N(e) {
|
|
640
|
+
return Math.min(1, Math.max(0, (M(e) * 4) ** .8));
|
|
879
641
|
}
|
|
880
|
-
function
|
|
642
|
+
function P(e, t, n) {
|
|
881
643
|
if (t === n) return e;
|
|
882
644
|
let r = t / n, i = Math.max(1, Math.round(e.length / r)), a = new Float32Array(i);
|
|
883
645
|
for (let t = 0; t < i; t += 1) {
|
|
@@ -886,7 +648,7 @@ function X(e, t, n) {
|
|
|
886
648
|
}
|
|
887
649
|
return a;
|
|
888
650
|
}
|
|
889
|
-
function
|
|
651
|
+
function F(e) {
|
|
890
652
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
891
653
|
e.forEach((e, t) => {
|
|
892
654
|
let r = Math.max(-1, Math.min(1, e));
|
|
@@ -897,18 +659,18 @@ function Z(e) {
|
|
|
897
659
|
r += String.fromCharCode(e);
|
|
898
660
|
}), btoa(r);
|
|
899
661
|
}
|
|
900
|
-
function
|
|
662
|
+
function I(e) {
|
|
901
663
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
902
664
|
for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
|
|
903
665
|
let r = new DataView(n.buffer), i = new Float32Array(Math.floor(n.length / 2));
|
|
904
666
|
for (let e = 0; e < i.length; e += 1) i[e] = r.getInt16(e * 2, !0) / 32768;
|
|
905
667
|
return i;
|
|
906
668
|
}
|
|
907
|
-
function
|
|
669
|
+
function L(e) {
|
|
908
670
|
let t = e?.match(/rate=(\d+)/i);
|
|
909
671
|
return t ? Number(t[1]) : 24e3;
|
|
910
672
|
}
|
|
911
|
-
function
|
|
673
|
+
function R(e) {
|
|
912
674
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = {
|
|
913
675
|
state: "idle",
|
|
914
676
|
volume: 0,
|
|
@@ -921,15 +683,15 @@ function ee(e) {
|
|
|
921
683
|
function y() {
|
|
922
684
|
let t = typeof e.outputVolumeCalibration == "function" ? e.outputVolumeCalibration() : e.outputVolumeCalibration;
|
|
923
685
|
return {
|
|
924
|
-
...
|
|
686
|
+
...j,
|
|
925
687
|
...t
|
|
926
688
|
};
|
|
927
689
|
}
|
|
928
|
-
function
|
|
690
|
+
function x(e) {
|
|
929
691
|
r = e, t.forEach((t) => t(e));
|
|
930
692
|
}
|
|
931
|
-
function
|
|
932
|
-
r.state === e && t === void 0 || (e !== "speaking" && (h = 0),
|
|
693
|
+
function S(e, t) {
|
|
694
|
+
r.state === e && t === void 0 || (e !== "speaking" && (h = 0), x({
|
|
933
695
|
state: e,
|
|
934
696
|
volume: 0,
|
|
935
697
|
inputVolume: 0,
|
|
@@ -937,20 +699,20 @@ function ee(e) {
|
|
|
937
699
|
...t === void 0 ? {} : { error: t }
|
|
938
700
|
}));
|
|
939
701
|
}
|
|
940
|
-
function
|
|
702
|
+
function C() {
|
|
941
703
|
f &&= (clearTimeout(f), null);
|
|
942
704
|
}
|
|
943
|
-
function
|
|
944
|
-
t > (e.speechThreshold ?? .04) ? (!p && v() && i?.sendRealtimeInput({ activityStart: {} }), p = !0,
|
|
945
|
-
f = null, p = !1, v() && i?.sendRealtimeInput({ activityEnd: {} }), r.state === "listening" &&
|
|
946
|
-
}, e.speechEndDelayMs ?? 500)), r.state === "listening" &&
|
|
705
|
+
function w(t) {
|
|
706
|
+
t > (e.speechThreshold ?? .04) ? (!p && v() && i?.sendRealtimeInput({ activityStart: {} }), p = !0, C(), r.state !== "listening" && S("listening")) : p && !f && (f = setTimeout(() => {
|
|
707
|
+
f = null, p = !1, v() && i?.sendRealtimeInput({ activityEnd: {} }), r.state === "listening" && S("thinking");
|
|
708
|
+
}, e.speechEndDelayMs ?? 500)), r.state === "listening" && x({
|
|
947
709
|
...r,
|
|
948
710
|
volume: t,
|
|
949
711
|
inputVolume: t,
|
|
950
712
|
outputVolume: 0
|
|
951
713
|
});
|
|
952
714
|
}
|
|
953
|
-
function
|
|
715
|
+
function T() {
|
|
954
716
|
n.forEach((e) => {
|
|
955
717
|
try {
|
|
956
718
|
e.stop();
|
|
@@ -958,41 +720,41 @@ function ee(e) {
|
|
|
958
720
|
e.disconnect();
|
|
959
721
|
}), n.clear(), m = o?.currentTime ?? 0;
|
|
960
722
|
}
|
|
961
|
-
function
|
|
962
|
-
g && n.size === 0 && (g = !1,
|
|
723
|
+
function E() {
|
|
724
|
+
g && n.size === 0 && (g = !1, S("listening"));
|
|
963
725
|
}
|
|
964
|
-
function
|
|
726
|
+
function D(e) {
|
|
965
727
|
if (!o || !u || !e.data) return;
|
|
966
|
-
let t =
|
|
728
|
+
let t = I(e.data), i = o.createBuffer(1, t.length, L(e.mimeType));
|
|
967
729
|
i.getChannelData(0).set(t);
|
|
968
730
|
let a = o.createBufferSource();
|
|
969
731
|
a.buffer = i, a.connect(u);
|
|
970
732
|
let s = Math.max(o.currentTime, m);
|
|
971
733
|
m = s + i.duration, n.add(a), a.onended = () => {
|
|
972
|
-
n.delete(a), a.disconnect(),
|
|
973
|
-
}, a.start(s), r.state !== "speaking" &&
|
|
734
|
+
n.delete(a), a.disconnect(), E();
|
|
735
|
+
}, a.start(s), r.state !== "speaking" && S("speaking");
|
|
974
736
|
}
|
|
975
|
-
function
|
|
976
|
-
e.setupComplete &&
|
|
737
|
+
function O(e) {
|
|
738
|
+
e.setupComplete && S("listening");
|
|
977
739
|
let t = e.serverContent;
|
|
978
740
|
if (!t) return;
|
|
979
741
|
if (t.interrupted) {
|
|
980
|
-
|
|
742
|
+
T(), g = !1, S("listening");
|
|
981
743
|
return;
|
|
982
744
|
}
|
|
983
745
|
let n = t.modelTurn?.parts?.filter((e) => e.inlineData?.data) ?? [];
|
|
984
|
-
t.modelTurn && n.length === 0 && r.state !== "speaking" &&
|
|
746
|
+
t.modelTurn && n.length === 0 && r.state !== "speaking" && S("thinking"), n.forEach((e) => D(e.inlineData)), t.waitingForInput && (T(), S("listening")), (t.turnComplete || t.generationComplete) && (g = !0, E());
|
|
985
747
|
}
|
|
986
|
-
function
|
|
748
|
+
function k() {
|
|
987
749
|
if (!u) return;
|
|
988
750
|
let t = new Float32Array(u.fftSize);
|
|
989
751
|
d = setInterval(() => {
|
|
990
752
|
if (!u || r.state !== "speaking") return;
|
|
991
753
|
u.getFloatTimeDomainData(t);
|
|
992
|
-
let n =
|
|
754
|
+
let n = b(M(t), h, y);
|
|
993
755
|
h = n.normalized, e.onOutputVolumeSample?.(n);
|
|
994
756
|
let i = n.normalized;
|
|
995
|
-
|
|
757
|
+
x({
|
|
996
758
|
...r,
|
|
997
759
|
volume: i,
|
|
998
760
|
inputVolume: 0,
|
|
@@ -1000,20 +762,20 @@ function ee(e) {
|
|
|
1000
762
|
});
|
|
1001
763
|
}, 33);
|
|
1002
764
|
}
|
|
1003
|
-
function
|
|
765
|
+
function R() {
|
|
1004
766
|
!o || !a || !i || (s = o.createMediaStreamSource(a), c = o.createScriptProcessor(4096, 1, 1), l = o.createGain(), l.gain.value = 0, s.connect(c), c.connect(l), l.connect(o.destination), c.onaudioprocess = (t) => {
|
|
1005
767
|
if (!i || _) return;
|
|
1006
768
|
let n = t.inputBuffer.getChannelData(0);
|
|
1007
|
-
|
|
1008
|
-
let r =
|
|
769
|
+
w(N(n));
|
|
770
|
+
let r = P(n, o?.sampleRate ?? A, e.inputSampleRate ?? A);
|
|
1009
771
|
i.sendRealtimeInput({ audio: {
|
|
1010
|
-
data:
|
|
1011
|
-
mimeType: `audio/pcm;rate=${e.inputSampleRate ??
|
|
772
|
+
data: F(r),
|
|
773
|
+
mimeType: `audio/pcm;rate=${e.inputSampleRate ?? A}`
|
|
1012
774
|
} });
|
|
1013
775
|
});
|
|
1014
776
|
}
|
|
1015
|
-
async function
|
|
1016
|
-
_ = !0,
|
|
777
|
+
async function z(e) {
|
|
778
|
+
_ = !0, C(), d && clearInterval(d), d = null, T(), c?.disconnect(), s?.disconnect(), l?.disconnect(), u?.disconnect(), c = null, s = null, l = null, u = null, a?.getTracks().forEach((e) => e.stop()), a = null, o && o.state !== "closed" && await o.close(), o = null, i = null, p = !1, g = !1, h = 0, e && S("idle"), _ = !1;
|
|
1017
779
|
}
|
|
1018
780
|
return {
|
|
1019
781
|
subscribe(e) {
|
|
@@ -1021,19 +783,19 @@ function ee(e) {
|
|
|
1021
783
|
},
|
|
1022
784
|
async start() {
|
|
1023
785
|
if (!i) {
|
|
1024
|
-
|
|
786
|
+
S("connecting"), _ = !1;
|
|
1025
787
|
try {
|
|
1026
788
|
let t = e.getUserMedia ?? ((e) => navigator.mediaDevices.getUserMedia(e)), n = e.createAudioContext ?? (() => new window.AudioContext());
|
|
1027
|
-
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), o = n(), o.state === "suspended" && await o.resume(), u = o.createAnalyser(), u.fftSize = 512, u.smoothingTimeConstant = .25, u.connect(o.destination),
|
|
1028
|
-
onopen: () =>
|
|
1029
|
-
onmessage:
|
|
1030
|
-
onerror: (e) =>
|
|
789
|
+
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), o = n(), o.state === "suspended" && await o.resume(), u = o.createAnalyser(), u.fftSize = 512, u.smoothingTimeConstant = .25, u.connect(o.destination), k(), i = await e.connect({
|
|
790
|
+
onopen: () => S("listening"),
|
|
791
|
+
onmessage: O,
|
|
792
|
+
onerror: (e) => S("error", e),
|
|
1031
793
|
onclose: () => {
|
|
1032
|
-
_ ||
|
|
794
|
+
_ || S("idle");
|
|
1033
795
|
}
|
|
1034
|
-
}),
|
|
796
|
+
}), R(), S("listening");
|
|
1035
797
|
} catch (e) {
|
|
1036
|
-
throw i?.close(), await
|
|
798
|
+
throw i?.close(), await z(!1), S("error", e), e;
|
|
1037
799
|
}
|
|
1038
800
|
}
|
|
1039
801
|
},
|
|
@@ -1042,9 +804,9 @@ function ee(e) {
|
|
|
1042
804
|
try {
|
|
1043
805
|
p && v() && i?.sendRealtimeInput({ activityEnd: {} }), i?.sendRealtimeInput({ audioStreamEnd: !0 });
|
|
1044
806
|
} catch {}
|
|
1045
|
-
i?.close(), await
|
|
807
|
+
i?.close(), await z(!0);
|
|
1046
808
|
}
|
|
1047
809
|
};
|
|
1048
810
|
}
|
|
1049
811
|
//#endregion
|
|
1050
|
-
export {
|
|
812
|
+
export { g as DEFAULT_OUTPUT_VOLUME_CALIBRATION, i as createElevenLabsAdapter, R as createGeminiLiveAdapter, e as createLiveKitAdapter, k as createOpenAIRealtimeAdapter, h as createPipecatAdapter, r as createVapiAdapter };
|