@burdenoff/fe-libs 2026.1117.5 → 2026.1117.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/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +8 -0
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/liveDeltas.d.ts +6 -0
- package/dist/shared/assistant/liveDeltas.js +4 -3
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +132 -98
- package/dist/shared/assistant/speech/routingSpeechEngine.js +6 -0
- package/dist/shared/assistant/speech/speechFeed.d.ts +14 -0
- package/dist/shared/assistant/speech/speechFeed.js +7 -0
- package/dist/shared/assistant/speech/types.d.ts +10 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1181 -1170
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +281 -245
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.d.ts +4 -0
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.js +9 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.d.ts +29 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.js +50 -39
- package/dist/shared/assistant/voice/phraseSpeechConfig.d.ts +44 -2
- package/dist/shared/assistant/voice/phraseSpeechConfig.js +9 -6
- package/dist/shared/assistant/voice/speakableText.d.ts +18 -0
- package/dist/shared/assistant/voice/speakableText.js +113 -107
- package/dist/shared-assistant.js +381 -380
- package/package.json +1 -1
|
@@ -5,26 +5,27 @@ import { getSpeechEngine as r, subscribeSpeechEngine as i } from "../speech/crea
|
|
|
5
5
|
import { HOSTED_VOICES as a } from "../speech/hostedVoiceCatalogue.js";
|
|
6
6
|
import { speechFeed as o } from "../speech/speechFeed.js";
|
|
7
7
|
import { hasPendingReplyRequests as s, releaseReplyRequestsOutside as c, replyWantsAvatar as ee, settleReplyRequest as l, subscribeReplyRequests as u } from "../speech/replySpeechRequests.js";
|
|
8
|
-
import { chunkForSpeech as te, toSpeakableText as d } from "../voice/speakableText.js";
|
|
9
|
-
import { createPhrasePlayback as
|
|
8
|
+
import { chunkForSpeech as te, settledFirstChunk as ne, toSpeakableText as d } from "../voice/speakableText.js";
|
|
9
|
+
import { createPhrasePlayback as re } from "../voice/phrasePlayback.js";
|
|
10
10
|
import { phraseSpeechEnabled as f } from "../voice/phraseSpeechConfig.js";
|
|
11
|
+
import { firstClipPrefetchEnabled as ie } from "../voice/firstClipPrefetchConfig.js";
|
|
11
12
|
import { speechLabelsFor as p } from "../voice/speechLabels.js";
|
|
12
|
-
import { VOICE_LIST_TIMEOUT_MS as
|
|
13
|
-
import { resolveSpeechLocale as
|
|
14
|
-
import { findAssistantLanguage as
|
|
15
|
-
import { resolveLanguagePair as
|
|
16
|
-
import { IDLE_PLAYBACK as
|
|
17
|
-
import { isVoiceTurn as
|
|
18
|
-
import { isTurnSuperseded as
|
|
19
|
-
import { isTurnInFlight as
|
|
20
|
-
import { beginListenTurn as
|
|
21
|
-
import { registerTurnTimingPageExit as
|
|
22
|
-
import { parseToolActivity as
|
|
23
|
-
import { useAssistantTr as
|
|
24
|
-
import { createContext as
|
|
25
|
-
import { jsx as
|
|
13
|
+
import { VOICE_LIST_TIMEOUT_MS as ae, languageDisplayName as oe, selectVoiceForLocale as se, speechGate as ce, speechLangForLocale as m, voiceAvailability as le, voicesForLocale as h } from "../voice/speechVoices.js";
|
|
14
|
+
import { resolveSpeechLocale as g } from "../voice/replyLanguage.js";
|
|
15
|
+
import { findAssistantLanguage as _ } from "../voice/languages.js";
|
|
16
|
+
import { resolveLanguagePair as v } from "../voice/languagePair.js";
|
|
17
|
+
import { IDLE_PLAYBACK as ue, isSpeakingMessage as y, publishedChunks as de, speechPlaybackReducer as fe } from "../voice/speechPlayback.js";
|
|
18
|
+
import { isVoiceTurn as pe } from "../voice/turnVisibility.js";
|
|
19
|
+
import { isTurnSuperseded as me } from "../voice/supersededTurns.js";
|
|
20
|
+
import { isTurnInFlight as he } from "../turnState.js";
|
|
21
|
+
import { beginListenTurn as ge, describeTurn as _e, finishListenTurn as b, markTurn as ve } from "../turnTimeline.js";
|
|
22
|
+
import { registerTurnTimingPageExit as ye } from "../turnTimingReporter.js";
|
|
23
|
+
import { parseToolActivity as be } from "./AssistantToolActivity.js";
|
|
24
|
+
import { useAssistantTr as xe } from "../i18n.js";
|
|
25
|
+
import { createContext as Se, useCallback as x, useContext as Ce, useEffect as S, useMemo as C, useReducer as we, useRef as w, useState as T, useSyncExternalStore as Te } from "react";
|
|
26
|
+
import { jsx as Ee } from "react/jsx-runtime";
|
|
26
27
|
// src/shared/assistant/ui/AssistantSpeechProvider.tsx
|
|
27
|
-
var
|
|
28
|
+
var De = {
|
|
28
29
|
codeBlock: "",
|
|
29
30
|
codeBlockAgain: "",
|
|
30
31
|
image: "",
|
|
@@ -35,30 +36,30 @@ var Te = {
|
|
|
35
36
|
emailAt: "at",
|
|
36
37
|
emailDot: "dot",
|
|
37
38
|
nestedItem: ""
|
|
38
|
-
},
|
|
39
|
+
}, Oe = 4e3, E = () => {}, ke = {
|
|
39
40
|
subscribe: () => E,
|
|
40
41
|
getSnapshot: () => !1
|
|
41
|
-
},
|
|
42
|
+
}, Ae = {
|
|
42
43
|
subscribe: u,
|
|
43
44
|
getSnapshot: s
|
|
44
45
|
};
|
|
45
|
-
function
|
|
46
|
+
function je(e, t) {
|
|
46
47
|
return ee(t) ? {
|
|
47
48
|
...e,
|
|
48
49
|
autoSpeakEnabled: !0
|
|
49
50
|
} : e;
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function Me(e, t) {
|
|
52
53
|
let n = e.activeConversationId;
|
|
53
54
|
if (!n || n !== t.activeConversationId) return null;
|
|
54
55
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
55
|
-
if (r?.status !== "complete" || !
|
|
56
|
+
if (r?.status !== "complete" || !he(i?.status)) return null;
|
|
56
57
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
57
58
|
if (!a) return null;
|
|
58
59
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
59
60
|
return o && o.role === "assistant" ? o : null;
|
|
60
61
|
}
|
|
61
|
-
var
|
|
62
|
+
var Ne = Se({
|
|
62
63
|
isSupported: !1,
|
|
63
64
|
availability: "unsupported",
|
|
64
65
|
isBlocked: !0,
|
|
@@ -84,35 +85,35 @@ var je = be({
|
|
|
84
85
|
previewVoice: () => {}
|
|
85
86
|
});
|
|
86
87
|
function D() {
|
|
87
|
-
return
|
|
88
|
+
return Ce(Ne);
|
|
88
89
|
}
|
|
89
|
-
var O = ({ children: s, visible: u = !0, engine:
|
|
90
|
-
let
|
|
90
|
+
var O = ({ children: s, visible: u = !0, engine: Se }) => {
|
|
91
|
+
let Ce = Te(i, r, r), E = Se ?? Ce, D = xe(), { locale: O } = e(), [k, A] = we(fe, ue), [j, Pe] = T(() => E.listVoices()), [M, Fe] = T(!1), [Ie, N] = T(() => /* @__PURE__ */ new Map()), [Le, Re] = T(() => /* @__PURE__ */ new Set()), [ze, Be] = T(null), P = w(0), Ve = w(null), He = w(null), F = w(void 0), I = w(null), L = w(null), Ue = w(/* @__PURE__ */ new Set()), R = w(null);
|
|
91
92
|
S(() => () => {
|
|
92
|
-
|
|
93
|
+
R.current !== null && clearTimeout(R.current);
|
|
93
94
|
}, []);
|
|
94
|
-
let [
|
|
95
|
-
|
|
96
|
-
}, []),
|
|
97
|
-
|
|
98
|
-
}, []),
|
|
95
|
+
let [We, Ge] = T(null), z = w(null), Ke = w(() => {}), B = x(() => {
|
|
96
|
+
z.current?.(), z.current = null;
|
|
97
|
+
}, []), V = t((e) => e.autoSpeakEnabled), qe = t((e) => e.setAutoSpeak), [H, Je] = T(!1), Ye = w(!1), Xe = x((e) => {
|
|
98
|
+
Ye.current = e;
|
|
99
|
+
}, []), Ze = t((e) => e.activeConversationId), U = C(() => E.isSupported(), [E]), Qe = E.wouldSpeakOnAvatar === void 0 ? ke : Ae, $e = Te(Qe.subscribe, Qe.getSnapshot, Qe.getSnapshot);
|
|
99
100
|
S(() => {
|
|
100
|
-
if (!
|
|
101
|
+
if (!U) return;
|
|
101
102
|
let e = () => {
|
|
102
|
-
|
|
103
|
+
Pe(E.listVoices()), N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
103
104
|
};
|
|
104
105
|
return e(), E.subscribeVoices(e);
|
|
105
|
-
}, [E,
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
}, [E, U]);
|
|
107
|
+
let et = t((e) => e.assistantLanguage), tt = t((e) => e.replyLanguage), W = t((e) => e.preferredVoices), nt = t((e) => e.setPreferredVoice), G = C(() => v(et, tt, O).reply, [
|
|
108
|
+
et,
|
|
109
|
+
tt,
|
|
109
110
|
O
|
|
110
|
-
]),
|
|
111
|
-
|
|
111
|
+
]), K = G.code, q = x((e) => _(e)?.tag ?? m(e), []), rt = x((e) => _(e)?.rate ?? .9, []), it = C(() => le(U, j, G.tag, M), [
|
|
112
|
+
U,
|
|
112
113
|
j,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
]),
|
|
114
|
+
G,
|
|
115
|
+
M
|
|
116
|
+
]), J = C(() => ({
|
|
116
117
|
codeBlock: D("speech.codeBlock", "There’s a code example on screen"),
|
|
117
118
|
codeBlockAgain: D("speech.codeBlockAgain", "There’s another code example on screen"),
|
|
118
119
|
image: D("speech.image", "an image"),
|
|
@@ -124,7 +125,7 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
124
125
|
emailAt: D("speech.emailAt", "at"),
|
|
125
126
|
emailDot: D("speech.emailDot", "dot")
|
|
126
127
|
}), [D]), Y = x((e = "ended") => {
|
|
127
|
-
let t =
|
|
128
|
+
let t = L.current;
|
|
128
129
|
if (t) {
|
|
129
130
|
e === "retrying" && t.notifyEnded(e);
|
|
130
131
|
try {
|
|
@@ -133,97 +134,107 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
133
134
|
t.notifyEnded();
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
|
-
}, []),
|
|
137
|
-
|
|
137
|
+
}, []), at = x((e) => {
|
|
138
|
+
B(), He.current = null, b(F.current, "stopped"), F.current = void 0, Y(e), E.cancel(), l(Ve.current, "stopped"), A({ type: "stop" });
|
|
138
139
|
}, [
|
|
139
|
-
|
|
140
|
+
B,
|
|
140
141
|
Y,
|
|
141
142
|
E
|
|
142
|
-
]), X = x(() =>
|
|
143
|
+
]), X = x(() => at("ended"), [at]), ot = x((e) => {
|
|
143
144
|
let t = E.listVoices().find((t) => t.name === e) ?? null;
|
|
144
145
|
if (t) {
|
|
145
146
|
X();
|
|
146
147
|
try {
|
|
147
|
-
E.speak([n(
|
|
148
|
+
E.speak([n(K)], {
|
|
148
149
|
voice: t,
|
|
149
|
-
lang:
|
|
150
|
+
lang: q(K),
|
|
150
151
|
fallback: !1
|
|
151
152
|
});
|
|
152
153
|
} catch {}
|
|
153
154
|
}
|
|
154
155
|
}, [
|
|
155
156
|
E,
|
|
156
|
-
|
|
157
|
+
K,
|
|
157
158
|
X,
|
|
158
|
-
|
|
159
|
-
]),
|
|
160
|
-
|
|
159
|
+
q
|
|
160
|
+
]), st = x((e) => Ie.get(e) ?? null, [Ie]), ct = x((e) => Le.has(e) ? D("speech.deviceFallback", "Device voice used: the selected voice was unavailable.") : null, [Le, D]), lt = x((e, t, n, r, i) => {
|
|
161
|
+
B();
|
|
161
162
|
let a = !1, o = () => {}, s = (s) => {
|
|
162
|
-
a || (a = !0,
|
|
163
|
-
}, c = setTimeout(() => s(E.listVoices()),
|
|
164
|
-
o = E.subscribeVoices(() => s(E.listVoices())),
|
|
165
|
-
a || (a = !0, clearTimeout(c), o(),
|
|
163
|
+
a || (a = !0, z.current = null, clearTimeout(c), o(), s.length === 0 ? (Fe(!0), l(e, "declined")) : (Pe(s), Ke.current(e, t, s, n, r, i)));
|
|
164
|
+
}, c = setTimeout(() => s(E.listVoices()), ae);
|
|
165
|
+
o = E.subscribeVoices(() => s(E.listVoices())), z.current = () => {
|
|
166
|
+
a || (a = !0, clearTimeout(c), o(), z.current = null, l(e, "stopped"));
|
|
167
|
+
};
|
|
168
|
+
}, [B, E]), ut = x((e, t) => {
|
|
169
|
+
let n = q(t);
|
|
170
|
+
return {
|
|
171
|
+
voice: se(e, n, W[t]),
|
|
172
|
+
lang: n,
|
|
173
|
+
rate: rt(t)
|
|
166
174
|
};
|
|
167
|
-
}, [
|
|
175
|
+
}, [
|
|
176
|
+
W,
|
|
177
|
+
rt,
|
|
178
|
+
q
|
|
179
|
+
]), dt = x((e, t, n, r, i = !1, s, c = !1) => {
|
|
168
180
|
let u = n;
|
|
169
181
|
if (u.length === 0) {
|
|
170
182
|
let e = E.listVoices();
|
|
171
|
-
e.length > 0 && (u = e,
|
|
183
|
+
e.length > 0 && (u = e, Pe(e));
|
|
172
184
|
}
|
|
173
|
-
let
|
|
174
|
-
if (
|
|
175
|
-
let t = D("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language:
|
|
176
|
-
|
|
185
|
+
let ne = q(r), d = ce(le(!0, u, r, M));
|
|
186
|
+
if (d === "block") {
|
|
187
|
+
let t = D("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: oe(ne, O) });
|
|
188
|
+
N((n) => new Map(n).set(e, t)), l(e, "declined");
|
|
177
189
|
return;
|
|
178
190
|
}
|
|
179
|
-
if (c && (
|
|
180
|
-
if (
|
|
181
|
-
|
|
191
|
+
if (c && (d !== "speak" || !E.open)) return;
|
|
192
|
+
if (d === "wait-for-voices") {
|
|
193
|
+
lt(e, t, r, i, s);
|
|
182
194
|
return;
|
|
183
195
|
}
|
|
184
|
-
let p =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
rate: et(r)
|
|
188
|
-
}, re = ut.current;
|
|
189
|
-
if (i && !re.autoSpeakEnabled && !re.sessionSpeaking && ee(e)) {
|
|
190
|
-
if (E.wouldSpeakOnAvatar?.(p) !== !0) {
|
|
196
|
+
let f = ut(u, r), p = Q.current;
|
|
197
|
+
if (i && !p.autoSpeakEnabled && !p.sessionSpeaking && ee(e)) {
|
|
198
|
+
if (E.wouldSpeakOnAvatar?.(f) !== !0) {
|
|
191
199
|
l(e, "declined");
|
|
192
200
|
return;
|
|
193
201
|
}
|
|
194
|
-
|
|
202
|
+
f.avatarOnly = !0;
|
|
195
203
|
}
|
|
196
|
-
|
|
204
|
+
N((t) => {
|
|
197
205
|
if (!t.has(e)) return t;
|
|
198
206
|
let n = new Map(t);
|
|
199
207
|
return n.delete(e), n;
|
|
200
208
|
});
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
if (t.has(e) ===
|
|
209
|
+
let ae = W[r], se = typeof ae == "string" && a.some((e) => e.name === ae) && !u.some((e) => e.name === ae);
|
|
210
|
+
Re((t) => {
|
|
211
|
+
if (t.has(e) === se) return t;
|
|
204
212
|
let n = new Set(t);
|
|
205
|
-
return
|
|
206
|
-
}),
|
|
207
|
-
let m =
|
|
208
|
-
|
|
213
|
+
return se ? n.add(e) : n.delete(e), n;
|
|
214
|
+
}), B(), Y();
|
|
215
|
+
let m = P.current + 1;
|
|
216
|
+
P.current = m, Ve.current !== e && l(Ve.current, "stopped"), Ve.current = e, l(e, "speaking"), A({
|
|
209
217
|
type: "start",
|
|
210
218
|
messageId: e,
|
|
211
219
|
requestId: m
|
|
212
|
-
}),
|
|
213
|
-
let h = i ? void 0 :
|
|
214
|
-
|
|
215
|
-
let g = s === void 0 ? te(t) : te(t, void 0, void 0, {
|
|
216
|
-
|
|
220
|
+
}), He.current = i ? m : null, i && ve(e, "ttsStarted"), b(F.current, "stopped");
|
|
221
|
+
let h = i ? void 0 : ge(e);
|
|
222
|
+
F.current = h;
|
|
223
|
+
let g = s === void 0 ? te(t) : te(t, void 0, void 0, {
|
|
224
|
+
firstChunkMaxChars: s,
|
|
225
|
+
...ie() ? { leadSentenceMinChars: 40 } : {}
|
|
226
|
+
});
|
|
227
|
+
Ge({
|
|
217
228
|
requestId: m,
|
|
218
229
|
chunks: g,
|
|
219
230
|
index: -1
|
|
220
|
-
}),
|
|
221
|
-
c ||
|
|
222
|
-
},
|
|
231
|
+
}), R.current !== null && clearTimeout(R.current), R.current = setTimeout(() => {
|
|
232
|
+
c || Ge((e) => e?.requestId === m && e.index < 0 ? null : e);
|
|
233
|
+
}, Oe);
|
|
223
234
|
let _ = !1, v = (t = "ended") => {
|
|
224
|
-
_ || (_ = !0, c &&
|
|
235
|
+
_ || (_ = !0, c && P.current === m && (L.current = null, o.audio(e, t)));
|
|
225
236
|
}, ue = () => {
|
|
226
|
-
b(h, "failed"), v(),
|
|
237
|
+
b(h, "failed"), v(), P.current === m && R.current !== null && (clearTimeout(R.current), R.current = null), l(e, "failed"), A({
|
|
227
238
|
type: "failed",
|
|
228
239
|
requestId: m
|
|
229
240
|
});
|
|
@@ -231,36 +242,36 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
231
242
|
try {
|
|
232
243
|
let n = {
|
|
233
244
|
onStart: () => {
|
|
234
|
-
|
|
245
|
+
P.current === m && b(h, "answered"), P.current === m && He.current === m && ve(e, "firstAudio");
|
|
235
246
|
},
|
|
236
247
|
onChunkStart: (t) => {
|
|
237
|
-
y = !0, c &&
|
|
248
|
+
y = !0, c && P.current === m && (o.peek(e)?.final === !1 && _e(e, { spokeNarration: !0 }), o.audio(e, "started")), P.current === m && R.current !== null && (clearTimeout(R.current), R.current = null), Ge((e) => e?.requestId === m ? {
|
|
238
249
|
...e,
|
|
239
250
|
index: t
|
|
240
|
-
} :
|
|
251
|
+
} : P.current === m ? {
|
|
241
252
|
requestId: m,
|
|
242
253
|
chunks: g,
|
|
243
254
|
index: t
|
|
244
255
|
} : e);
|
|
245
256
|
},
|
|
246
257
|
onPause: () => {
|
|
247
|
-
c &&
|
|
258
|
+
c && P.current === m && o.audio(e, "paused");
|
|
248
259
|
},
|
|
249
260
|
onDeviceFallback: () => {
|
|
250
|
-
|
|
261
|
+
P.current === m && Re((t) => t.has(e) ? t : new Set(t).add(e));
|
|
251
262
|
},
|
|
252
263
|
onEnd: () => {
|
|
253
|
-
b(h, "stopped"), v(),
|
|
264
|
+
b(h, "stopped"), v(), P.current === m && He.current === m && ve(e, "audioEnded"), l(e, "spoken"), A({
|
|
254
265
|
type: "finished",
|
|
255
266
|
requestId: m
|
|
256
267
|
});
|
|
257
268
|
},
|
|
258
269
|
onError: (t) => {
|
|
259
|
-
b(h, t === "cancelled" ? "stopped" : "failed"), v(), !y &&
|
|
270
|
+
b(h, t === "cancelled" ? "stopped" : "failed"), v(), !y && P.current === m && Re((t) => {
|
|
260
271
|
if (!t.has(e)) return t;
|
|
261
272
|
let n = new Set(t);
|
|
262
273
|
return n.delete(e), n;
|
|
263
|
-
}), t === "output-not-cleared" &&
|
|
274
|
+
}), t === "output-not-cleared" && P.current === m && Be({ messageId: e }), l(e, t === "output-not-cleared" ? "not-cleared" : t === "output-left" ? y ? "cut" : "declined" : t === "cancelled" ? "stopped" : "failed"), A({
|
|
264
275
|
type: "failed",
|
|
265
276
|
requestId: m
|
|
266
277
|
});
|
|
@@ -269,53 +280,53 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
269
280
|
if (c && E.open) {
|
|
270
281
|
let i = E.open.bind(E);
|
|
271
282
|
o.audio(e, "queued");
|
|
272
|
-
let a =
|
|
273
|
-
g = [...e],
|
|
283
|
+
let a = re((e) => i(f, e), n, (e) => {
|
|
284
|
+
g = [...e], Ge((e) => e?.requestId === m ? {
|
|
274
285
|
...e,
|
|
275
286
|
chunks: g
|
|
276
287
|
} : e);
|
|
277
|
-
}, () =>
|
|
278
|
-
_ ? a.cancel() : (
|
|
288
|
+
}, () => _e(e, { speechDivergence: !0 }));
|
|
289
|
+
_ ? a.cancel() : (L.current = {
|
|
279
290
|
messageId: e,
|
|
280
291
|
requestId: m,
|
|
281
292
|
locale: r,
|
|
282
293
|
playback: a,
|
|
283
294
|
notifyEnded: v
|
|
284
295
|
}, a.append(t));
|
|
285
|
-
} else E.speak(g,
|
|
296
|
+
} else E.speak(g, f, n);
|
|
286
297
|
} catch {
|
|
287
298
|
ue();
|
|
288
299
|
}
|
|
289
300
|
}, [
|
|
290
|
-
|
|
301
|
+
B,
|
|
291
302
|
Y,
|
|
292
303
|
E,
|
|
293
304
|
O,
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
305
|
+
W,
|
|
306
|
+
ut,
|
|
307
|
+
q,
|
|
297
308
|
D,
|
|
298
|
-
|
|
299
|
-
|
|
309
|
+
M,
|
|
310
|
+
lt
|
|
300
311
|
]);
|
|
301
312
|
S(() => {
|
|
302
|
-
|
|
303
|
-
}, [
|
|
313
|
+
Ke.current = dt;
|
|
314
|
+
}, [dt]);
|
|
304
315
|
let Z = x((e, t, n, r) => {
|
|
305
|
-
if (!
|
|
306
|
-
let i =
|
|
307
|
-
labels: p(i,
|
|
316
|
+
if (!U) return;
|
|
317
|
+
let i = g(d(t, { labels: De }), n ?? K), a = d(t, {
|
|
318
|
+
labels: p(i, J),
|
|
308
319
|
locale: i
|
|
309
320
|
});
|
|
310
|
-
a &&
|
|
321
|
+
a && dt(e, a, j, i, r?.auto === !0, r?.firstChunkMaxChars, r?.phraseStream);
|
|
311
322
|
}, [
|
|
312
|
-
|
|
313
|
-
nt,
|
|
323
|
+
U,
|
|
314
324
|
J,
|
|
315
|
-
|
|
325
|
+
K,
|
|
326
|
+
dt,
|
|
316
327
|
j
|
|
317
|
-
]),
|
|
318
|
-
|
|
328
|
+
]), ft = x((e, t, n) => {
|
|
329
|
+
y(k, e) ? X() : Z(e, t, n);
|
|
319
330
|
}, [
|
|
320
331
|
k,
|
|
321
332
|
Z,
|
|
@@ -324,220 +335,245 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
324
335
|
S(() => {
|
|
325
336
|
u || X();
|
|
326
337
|
}, [u, X]);
|
|
327
|
-
let
|
|
328
|
-
autoSpeakEnabled:
|
|
329
|
-
sessionSpeaking:
|
|
338
|
+
let Q = w({
|
|
339
|
+
autoSpeakEnabled: V,
|
|
340
|
+
sessionSpeaking: H,
|
|
330
341
|
visible: u,
|
|
331
|
-
isSupported:
|
|
342
|
+
isSupported: U
|
|
332
343
|
});
|
|
333
344
|
S(() => {
|
|
334
|
-
|
|
335
|
-
autoSpeakEnabled:
|
|
336
|
-
sessionSpeaking:
|
|
345
|
+
Q.current = {
|
|
346
|
+
autoSpeakEnabled: V,
|
|
347
|
+
sessionSpeaking: H,
|
|
337
348
|
visible: u,
|
|
338
|
-
isSupported:
|
|
349
|
+
isSupported: U
|
|
339
350
|
};
|
|
340
351
|
}, [
|
|
341
|
-
|
|
342
|
-
|
|
352
|
+
V,
|
|
353
|
+
H,
|
|
343
354
|
u,
|
|
344
|
-
|
|
355
|
+
U
|
|
345
356
|
]);
|
|
346
|
-
let
|
|
357
|
+
let pt = w(null), mt = w(null), ht = w(() => {});
|
|
347
358
|
S(() => {
|
|
348
|
-
X(),
|
|
349
|
-
let e =
|
|
350
|
-
|
|
351
|
-
}, [
|
|
352
|
-
|
|
353
|
-
}, [
|
|
354
|
-
|
|
359
|
+
X(), Ue.current.clear(), N(/* @__PURE__ */ new Map()), Re(/* @__PURE__ */ new Set()), c(t.getState().activeConversationId), pt.current = Ze;
|
|
360
|
+
let e = mt.current;
|
|
361
|
+
mt.current = null, e && e.conversationId === Ze && ht.current(e.conversationId, e.messageId);
|
|
362
|
+
}, [Ze, X]), S(() => {
|
|
363
|
+
N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), X();
|
|
364
|
+
}, [K, X]), S(() => () => {
|
|
365
|
+
z.current?.(), z.current = null, b(F.current, "stopped"), F.current = void 0, Y(), E.cancel();
|
|
355
366
|
}, [Y, E]), S(() => {
|
|
356
367
|
if (typeof window > "u") return;
|
|
357
|
-
let { settle: e, unregister: t } =
|
|
358
|
-
e(),
|
|
368
|
+
let { settle: e, unregister: t } = ye(() => (b(F.current, "stopped"), F.current)), n = () => {
|
|
369
|
+
e(), F.current = void 0, Y(), E.cancel();
|
|
359
370
|
};
|
|
360
371
|
return window.addEventListener("pagehide", n), () => {
|
|
361
372
|
t(), window.removeEventListener("pagehide", n);
|
|
362
373
|
};
|
|
363
374
|
}, [Y, E]), S(() => {
|
|
364
|
-
if (typeof document > "u" || !
|
|
375
|
+
if (typeof document > "u" || !U) return;
|
|
365
376
|
let e = () => {
|
|
366
377
|
if (document.visibilityState !== "visible") return;
|
|
367
378
|
let e = E.listVoices();
|
|
368
|
-
e.length > 0 &&
|
|
379
|
+
e.length > 0 && B(), Pe(e), Fe(!1), N((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
369
380
|
};
|
|
370
381
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
371
382
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
372
383
|
};
|
|
373
384
|
}, [
|
|
374
|
-
|
|
385
|
+
B,
|
|
375
386
|
E,
|
|
376
|
-
|
|
387
|
+
U
|
|
377
388
|
]);
|
|
378
|
-
let
|
|
389
|
+
let gt = w(Z);
|
|
379
390
|
S(() => {
|
|
380
|
-
|
|
391
|
+
gt.current = Z;
|
|
381
392
|
}, [Z]);
|
|
382
|
-
let
|
|
383
|
-
if (
|
|
384
|
-
let { text: n } =
|
|
393
|
+
let $ = x((e, t) => {
|
|
394
|
+
if (pe(e) !== t || me(e.id) || I.current?.messageId === e.id || Ye.current) return;
|
|
395
|
+
let { text: n } = be(e.content);
|
|
385
396
|
if (n.trim()) try {
|
|
386
|
-
|
|
397
|
+
gt.current(e.id, n, e.metadata?.lang, { auto: !0 });
|
|
387
398
|
} catch {}
|
|
388
|
-
}, []),
|
|
389
|
-
if (e !==
|
|
390
|
-
t.getState().activeConversationId === e && (
|
|
399
|
+
}, []), _t = x((e, n) => {
|
|
400
|
+
if (e !== pt.current) {
|
|
401
|
+
t.getState().activeConversationId === e && (mt.current = {
|
|
391
402
|
conversationId: e,
|
|
392
403
|
messageId: n
|
|
393
404
|
});
|
|
394
405
|
return;
|
|
395
406
|
}
|
|
396
|
-
let r =
|
|
407
|
+
let r = je(Q.current, n);
|
|
397
408
|
if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
|
|
398
409
|
let i = t.getState();
|
|
399
410
|
if (i.activeConversationId !== e) return;
|
|
400
411
|
let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === n);
|
|
401
|
-
a && a.role === "assistant" &&
|
|
402
|
-
}, [
|
|
412
|
+
a && a.role === "assistant" && $(a, r.sessionSpeaking);
|
|
413
|
+
}, [$]);
|
|
403
414
|
S(() => {
|
|
404
|
-
|
|
405
|
-
}, [
|
|
406
|
-
if ((
|
|
415
|
+
ht.current = _t;
|
|
416
|
+
}, [_t]), S(() => {
|
|
417
|
+
if ((V || H) && u && U) return t.subscribe((e, t) => {
|
|
407
418
|
let n = e.activeConversationId;
|
|
408
419
|
if (!n || n !== t.activeConversationId) return;
|
|
409
420
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
410
|
-
if (r?.status !== "complete" || !
|
|
421
|
+
if (r?.status !== "complete" || !he(i?.status)) return;
|
|
411
422
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
412
423
|
if (!a) return;
|
|
413
424
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
414
|
-
o && o.role === "assistant" &&
|
|
425
|
+
o && o.role === "assistant" && $(o, H);
|
|
415
426
|
});
|
|
416
427
|
}, [
|
|
428
|
+
V,
|
|
429
|
+
H,
|
|
417
430
|
U,
|
|
418
|
-
W,
|
|
419
|
-
G,
|
|
420
431
|
u,
|
|
421
|
-
|
|
432
|
+
$
|
|
422
433
|
]), S(() => {
|
|
423
|
-
if (!
|
|
424
|
-
let n =
|
|
425
|
-
n && ee(n.id) &&
|
|
434
|
+
if (!V && !H && $e && u && U) return t.subscribe((e, t) => {
|
|
435
|
+
let n = Me(e, t);
|
|
436
|
+
n && ee(n.id) && $(n, !1);
|
|
426
437
|
});
|
|
427
438
|
}, [
|
|
439
|
+
V,
|
|
440
|
+
H,
|
|
441
|
+
$e,
|
|
428
442
|
U,
|
|
429
|
-
W,
|
|
430
|
-
Ye,
|
|
431
|
-
G,
|
|
432
443
|
u,
|
|
433
|
-
|
|
444
|
+
$
|
|
434
445
|
]);
|
|
435
|
-
let
|
|
446
|
+
let vt = w(null), yt = x((e, n) => {
|
|
447
|
+
if (!ie() || !E.prefetch || !U || vt.current === e || n.channel !== "voice") return;
|
|
448
|
+
let r = je(Q.current, e);
|
|
449
|
+
if (!r.sessionSpeaking || !r.visible || !r.isSupported || me(e) || t.getState().activeConversationId !== n.conversationId) return;
|
|
450
|
+
let i = be(n.text).text, a = g(d(i, { labels: De }), n.lang ?? K), o = d(i, {
|
|
451
|
+
labels: p(a, J),
|
|
452
|
+
locale: a
|
|
453
|
+
}), s = ne(o, {
|
|
454
|
+
firstChunkMaxChars: 110,
|
|
455
|
+
leadSentenceMinChars: 40
|
|
456
|
+
});
|
|
457
|
+
s !== null && ce(le(!0, j, a, M)) === "speak" && (vt.current = e, E.prefetch(s, ut(j, a)));
|
|
458
|
+
}, [
|
|
459
|
+
E,
|
|
460
|
+
U,
|
|
461
|
+
J,
|
|
462
|
+
ut,
|
|
463
|
+
K,
|
|
464
|
+
M,
|
|
465
|
+
j
|
|
466
|
+
]), bt = x((e) => {
|
|
436
467
|
if (e.type === "audio") return;
|
|
468
|
+
if (e.type === "prefetch") {
|
|
469
|
+
yt(e.messageId, e.item);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
437
472
|
if (e.type === "retract") {
|
|
438
|
-
|
|
473
|
+
L.current?.messageId === e.messageId && L.current.playback.retract();
|
|
439
474
|
return;
|
|
440
475
|
}
|
|
441
476
|
if (e.type === "abort") {
|
|
442
|
-
|
|
443
|
-
let t =
|
|
477
|
+
Ue.current.delete(e.messageId), vt.current === e.messageId && (vt.current = null, E.cancelPrefetch?.());
|
|
478
|
+
let t = I.current;
|
|
444
479
|
if (!t || t.messageId !== e.messageId) return;
|
|
445
|
-
|
|
480
|
+
I.current = null, (t.requestId === null ? t.waiting && z.current !== null : P.current === t.requestId) && at(e.retrying ? "retrying" : "ended");
|
|
446
481
|
return;
|
|
447
482
|
}
|
|
448
483
|
let { messageId: n, item: r } = e;
|
|
449
|
-
if (e.type === "append" &&
|
|
450
|
-
if (
|
|
451
|
-
|
|
484
|
+
if (e.type === "append" && L.current?.messageId !== n) {
|
|
485
|
+
if (Ue.current.has(n)) return;
|
|
486
|
+
Ue.current.add(n);
|
|
452
487
|
}
|
|
453
|
-
let i =
|
|
454
|
-
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking ||
|
|
455
|
-
let a =
|
|
456
|
-
if (a?.messageId === n && a.requestId ===
|
|
457
|
-
let t = d(e.type === "append" ? e.phrases.join(" ") :
|
|
458
|
-
labels: p(a.locale,
|
|
488
|
+
let i = je(Q.current, n);
|
|
489
|
+
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || me(n) || Ye.current || t.getState().activeConversationId !== r.conversationId || pt.current !== r.conversationId) return;
|
|
490
|
+
let a = L.current;
|
|
491
|
+
if (a?.messageId === n && a.requestId === P.current) {
|
|
492
|
+
let t = d(e.type === "append" ? e.phrases.join(" ") : be(r.text).text, {
|
|
493
|
+
labels: p(a.locale, J),
|
|
459
494
|
locale: a.locale
|
|
460
495
|
});
|
|
461
496
|
e.type === "append" ? a.playback.append(t) : a.playback.finish(t);
|
|
462
497
|
return;
|
|
463
498
|
}
|
|
464
|
-
if (
|
|
465
|
-
let { text: o } =
|
|
499
|
+
if (I.current?.messageId === n || e.type === "append" && (!f() || !E.open || r.channel !== "voice")) return;
|
|
500
|
+
let { text: o } = be(e.type === "append" ? e.phrases.join(" ") : r.text);
|
|
466
501
|
if (!o.trim()) return;
|
|
467
|
-
let s =
|
|
502
|
+
let s = P.current;
|
|
468
503
|
try {
|
|
469
|
-
|
|
504
|
+
gt.current(n, o, r.lang, {
|
|
470
505
|
auto: !0,
|
|
471
506
|
firstChunkMaxChars: 110,
|
|
472
507
|
phraseStream: e.type === "append"
|
|
473
508
|
});
|
|
474
509
|
} catch {}
|
|
475
|
-
let c =
|
|
476
|
-
(e.type !== "append" || c) && (
|
|
510
|
+
let c = P.current !== s;
|
|
511
|
+
(e.type !== "append" || c) && (Ue.current.delete(n), I.current = {
|
|
477
512
|
messageId: n,
|
|
478
|
-
requestId: c ?
|
|
479
|
-
waiting: !c &&
|
|
513
|
+
requestId: c ? P.current : null,
|
|
514
|
+
waiting: !c && z.current !== null
|
|
480
515
|
});
|
|
481
516
|
}, [
|
|
482
|
-
|
|
517
|
+
at,
|
|
483
518
|
E,
|
|
484
|
-
|
|
519
|
+
J,
|
|
520
|
+
yt
|
|
485
521
|
]);
|
|
486
|
-
S(() => o.subscribe(
|
|
487
|
-
let
|
|
522
|
+
S(() => o.subscribe(bt), [bt]);
|
|
523
|
+
let xt = C(() => h(j, G.tag), [j, G]), St = C(() => se(j, G.tag, W[K]), [
|
|
488
524
|
j,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
]),
|
|
493
|
-
isSupported:
|
|
494
|
-
availability:
|
|
495
|
-
isBlocked:
|
|
496
|
-
disabledReason:
|
|
497
|
-
blockedFor:
|
|
498
|
-
deviceFallbackFor:
|
|
499
|
-
voiceChoices:
|
|
500
|
-
spokenChunks:
|
|
501
|
-
activeVoiceName:
|
|
502
|
-
preferredVoiceName: K
|
|
503
|
-
setVoice: (e) =>
|
|
525
|
+
G,
|
|
526
|
+
W,
|
|
527
|
+
K
|
|
528
|
+
]), Ct = C(() => ({
|
|
529
|
+
isSupported: U,
|
|
530
|
+
availability: it,
|
|
531
|
+
isBlocked: it === "no-voices",
|
|
532
|
+
disabledReason: it === "no-voices" ? D("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
533
|
+
blockedFor: st,
|
|
534
|
+
deviceFallbackFor: ct,
|
|
535
|
+
voiceChoices: xt,
|
|
536
|
+
spokenChunks: de(k, We),
|
|
537
|
+
activeVoiceName: St?.name ?? null,
|
|
538
|
+
preferredVoiceName: W[K] ?? null,
|
|
539
|
+
setVoice: (e) => nt(K, e),
|
|
504
540
|
speakingMessageId: k.status === "speaking" ? k.messageId : null,
|
|
505
|
-
outputNotCleared:
|
|
506
|
-
isSpeaking: (e) =>
|
|
507
|
-
toggle:
|
|
541
|
+
outputNotCleared: ze,
|
|
542
|
+
isSpeaking: (e) => y(k, e),
|
|
543
|
+
toggle: ft,
|
|
508
544
|
stop: X,
|
|
509
|
-
autoSpeakEnabled:
|
|
510
|
-
setAutoSpeak:
|
|
511
|
-
sessionSpeaking:
|
|
512
|
-
setSessionSpeaking:
|
|
513
|
-
setSessionMicOpen:
|
|
514
|
-
speakFinishedReply:
|
|
515
|
-
previewVoice:
|
|
545
|
+
autoSpeakEnabled: V,
|
|
546
|
+
setAutoSpeak: qe,
|
|
547
|
+
sessionSpeaking: H,
|
|
548
|
+
setSessionSpeaking: Je,
|
|
549
|
+
setSessionMicOpen: Xe,
|
|
550
|
+
speakFinishedReply: _t,
|
|
551
|
+
previewVoice: ot
|
|
516
552
|
}), [
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
553
|
+
U,
|
|
554
|
+
it,
|
|
555
|
+
st,
|
|
556
|
+
ct,
|
|
557
|
+
xt,
|
|
558
|
+
St,
|
|
559
|
+
W,
|
|
560
|
+
nt,
|
|
523
561
|
K,
|
|
524
|
-
Qe,
|
|
525
|
-
J,
|
|
526
562
|
k,
|
|
527
|
-
|
|
528
|
-
|
|
563
|
+
ze,
|
|
564
|
+
ft,
|
|
529
565
|
X,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
566
|
+
V,
|
|
567
|
+
qe,
|
|
568
|
+
H,
|
|
569
|
+
Xe,
|
|
570
|
+
_t,
|
|
571
|
+
ot,
|
|
536
572
|
D,
|
|
537
|
-
|
|
573
|
+
We
|
|
538
574
|
]);
|
|
539
|
-
return /* @__PURE__ */
|
|
540
|
-
value:
|
|
575
|
+
return /* @__PURE__ */ Ee(Ne.Provider, {
|
|
576
|
+
value: Ct,
|
|
541
577
|
children: s
|
|
542
578
|
});
|
|
543
579
|
};
|