@burdenoff/fe-libs 2026.1013.10 → 2026.1013.11
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/i18nManifest.d.ts +1 -0
- package/dist/shared/assistant/i18nManifest.js +1 -0
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +86 -81
- package/dist/shared/assistant/speech/pieceSink.d.ts +15 -7
- package/dist/shared/assistant/speech/pieceSink.js +55 -49
- package/dist/shared/assistant/speech/routingSpeechEngine.js +47 -37
- package/dist/shared/assistant/speech/types.d.ts +34 -3
- package/dist/shared/assistant/speech/types.js +2 -2
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts +11 -0
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +255 -250
- package/dist/shared/assistant/ui/useVoiceSession.d.ts +7 -1
- package/dist/shared/assistant/ui/useVoiceSession.js +253 -245
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +157 -145
- package/dist/shared-assistant.js +240 -240
- package/package.json +1 -1
|
@@ -3,24 +3,24 @@ import { useAssistantTr as t } from "../i18n.js";
|
|
|
3
3
|
import { useAssistantStore as n } from "../store.js";
|
|
4
4
|
import { isVoiceTurn as r } from "../voice/turnVisibility.js";
|
|
5
5
|
import { VOICE_LIST_TIMEOUT_MS as i, languageDisplayName as a, selectVoiceForLocale as o, speechGate as s, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../voice/speechVoices.js";
|
|
6
|
-
import { getSpeechEngine as d, subscribeSpeechEngine as
|
|
7
|
-
import { speechFeed as
|
|
8
|
-
import { isTurnSuperseded as
|
|
9
|
-
import { chunkForSpeech as
|
|
10
|
-
import { voicePreviewText as
|
|
11
|
-
import { findAssistantLanguage as
|
|
12
|
-
import { resolveLanguagePair as
|
|
13
|
-
import { speechLabelsFor as
|
|
14
|
-
import { resolveSpeechLocale as
|
|
15
|
-
import { IDLE_PLAYBACK as
|
|
16
|
-
import { isTurnInFlight as
|
|
17
|
-
import { parseToolActivity as
|
|
6
|
+
import { getSpeechEngine as d, subscribeSpeechEngine as f } from "../speech/createSpeechEngine.js";
|
|
7
|
+
import { speechFeed as p } from "../speech/speechFeed.js";
|
|
8
|
+
import { isTurnSuperseded as m } from "../voice/supersededTurns.js";
|
|
9
|
+
import { chunkForSpeech as ee, toSpeakableText as h } from "../voice/speakableText.js";
|
|
10
|
+
import { voicePreviewText as te } from "../voice/voicePreview.js";
|
|
11
|
+
import { findAssistantLanguage as ne } from "../voice/languages.js";
|
|
12
|
+
import { resolveLanguagePair as re } from "../voice/languagePair.js";
|
|
13
|
+
import { speechLabelsFor as ie } from "../voice/speechLabels.js";
|
|
14
|
+
import { resolveSpeechLocale as ae } from "../voice/replyLanguage.js";
|
|
15
|
+
import { IDLE_PLAYBACK as oe, isSpeakingMessage as se, publishedChunks as ce, speechPlaybackReducer as le } from "../voice/speechPlayback.js";
|
|
16
|
+
import { isTurnInFlight as ue } from "../turnState.js";
|
|
17
|
+
import { parseToolActivity as de } from "./AssistantToolActivity.js";
|
|
18
18
|
import "../speech/index.js";
|
|
19
|
-
import { markTurn as
|
|
20
|
-
import { createContext as
|
|
21
|
-
import { jsx as
|
|
19
|
+
import { markTurn as g } from "../turnTimeline.js";
|
|
20
|
+
import { createContext as fe, useCallback as _, useContext as v, useEffect as y, useMemo as b, useReducer as pe, useRef as x, useState as S, useSyncExternalStore as me } from "react";
|
|
21
|
+
import { jsx as he } from "react/jsx-runtime";
|
|
22
22
|
//#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
|
|
23
|
-
var
|
|
23
|
+
var ge = {
|
|
24
24
|
codeBlock: "",
|
|
25
25
|
image: "",
|
|
26
26
|
link: "",
|
|
@@ -29,7 +29,7 @@ var _e = {
|
|
|
29
29
|
emailAt: "at",
|
|
30
30
|
emailDot: "dot",
|
|
31
31
|
nestedItem: ""
|
|
32
|
-
},
|
|
32
|
+
}, _e = 4e3, ve = fe({
|
|
33
33
|
isSupported: !1,
|
|
34
34
|
availability: "unsupported",
|
|
35
35
|
isBlocked: !0,
|
|
@@ -41,6 +41,7 @@ var _e = {
|
|
|
41
41
|
preferredVoiceName: null,
|
|
42
42
|
setVoice: () => {},
|
|
43
43
|
speakingMessageId: null,
|
|
44
|
+
outputNotCleared: null,
|
|
44
45
|
isSpeaking: () => !1,
|
|
45
46
|
toggle: () => {},
|
|
46
47
|
stop: () => {},
|
|
@@ -52,359 +53,363 @@ var _e = {
|
|
|
52
53
|
speakFinishedReply: () => {},
|
|
53
54
|
previewVoice: () => {}
|
|
54
55
|
});
|
|
55
|
-
function
|
|
56
|
-
return
|
|
56
|
+
function ye() {
|
|
57
|
+
return v(ve);
|
|
57
58
|
}
|
|
58
|
-
var
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
var be = ({ children: fe, visible: v = !0, engine: ye }) => {
|
|
60
|
+
let be = me(f, d, d), C = ye ?? be, w = t(), { locale: T } = e(), [E, D] = pe(le, oe), [O, k] = S(() => C.listVoices()), [A, xe] = S(!1), [Se, j] = S(() => /* @__PURE__ */ new Map()), [Ce, we] = S(null), M = x(0), N = x(null), P = x(null), F = x(null);
|
|
61
|
+
y(() => () => {
|
|
62
|
+
F.current !== null && clearTimeout(F.current);
|
|
62
63
|
}, []);
|
|
63
|
-
let [
|
|
64
|
-
|
|
65
|
-
}, []),
|
|
66
|
-
|
|
67
|
-
}, []),
|
|
68
|
-
|
|
69
|
-
if (!
|
|
64
|
+
let [Te, I] = S(null), L = x(null), Ee = x(() => {}), R = _(() => {
|
|
65
|
+
L.current?.(), L.current = null;
|
|
66
|
+
}, []), z = n((e) => e.autoSpeakEnabled), De = n((e) => e.setAutoSpeak), [B, Oe] = S(!1), V = x(!1), ke = _((e) => {
|
|
67
|
+
V.current = e;
|
|
68
|
+
}, []), H = n((e) => e.activeConversationId), U = b(() => C.isSupported(), [C]);
|
|
69
|
+
y(() => {
|
|
70
|
+
if (!U) return;
|
|
70
71
|
let e = () => {
|
|
71
|
-
|
|
72
|
+
k(C.listVoices()), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
72
73
|
};
|
|
73
|
-
return e(),
|
|
74
|
-
}, [
|
|
75
|
-
let
|
|
76
|
-
ke,
|
|
74
|
+
return e(), C.subscribeVoices(e);
|
|
75
|
+
}, [C, U]);
|
|
76
|
+
let Ae = n((e) => e.assistantLanguage), je = n((e) => e.replyLanguage), W = n((e) => e.preferredVoices), Me = n((e) => e.setPreferredVoice), G = b(() => re(Ae, je, T).reply, [
|
|
77
77
|
Ae,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
78
|
+
je,
|
|
79
|
+
T
|
|
80
|
+
]), K = G.code, q = _((e) => ne(e)?.tag ?? c(e), []), Ne = _((e) => ne(e)?.rate ?? .9, []), J = b(() => l(U, O, G.tag, A), [
|
|
81
|
+
U,
|
|
82
|
+
O,
|
|
83
|
+
G,
|
|
84
|
+
A
|
|
85
|
+
]), Pe = b(() => ({
|
|
86
|
+
codeBlock: w("speech.codeBlock", "Code block"),
|
|
87
|
+
image: w("speech.image", "image"),
|
|
88
|
+
link: w("speech.link", "link"),
|
|
89
|
+
largeTable: w("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
|
|
90
|
+
truncated: w("speech.truncated", "The rest of this message is not read aloud"),
|
|
91
|
+
nestedItem: w("speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
92
|
+
emailAt: w("speech.emailAt", "at"),
|
|
93
|
+
emailDot: w("speech.emailDot", "dot")
|
|
94
|
+
}), [w]), Y = _(() => {
|
|
95
|
+
R(), N.current = null, C.cancel(), D({ type: "stop" });
|
|
96
|
+
}, [R, C]), Fe = _((e) => {
|
|
97
|
+
let t = C.listVoices().find((t) => t.name === e) ?? null;
|
|
97
98
|
if (t) {
|
|
98
|
-
|
|
99
|
+
Y();
|
|
99
100
|
try {
|
|
100
|
-
|
|
101
|
+
C.speak([te(K)], {
|
|
101
102
|
voice: t,
|
|
102
|
-
lang: K
|
|
103
|
+
lang: q(K),
|
|
103
104
|
fallback: !1
|
|
104
105
|
});
|
|
105
106
|
} catch {}
|
|
106
107
|
}
|
|
107
108
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]),
|
|
113
|
-
|
|
109
|
+
C,
|
|
110
|
+
K,
|
|
111
|
+
Y,
|
|
112
|
+
q
|
|
113
|
+
]), Ie = _((e) => Se.get(e) ?? null, [Se]), Le = _((e, t, n, r, a) => {
|
|
114
|
+
R();
|
|
114
115
|
let o = !1, s = () => {}, c = (i) => {
|
|
115
116
|
if (!o) {
|
|
116
|
-
if (o = !0,
|
|
117
|
-
|
|
117
|
+
if (o = !0, L.current = null, clearTimeout(l), s(), i.length === 0) {
|
|
118
|
+
xe(!0);
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
+
k(i), Ee.current(e, t, i, n, r, a);
|
|
121
122
|
}
|
|
122
|
-
}, l = setTimeout(() => c(
|
|
123
|
-
s =
|
|
124
|
-
o || (o = !0, clearTimeout(l), s(),
|
|
123
|
+
}, l = setTimeout(() => c(C.listVoices()), i);
|
|
124
|
+
s = C.subscribeVoices(() => c(C.listVoices())), L.current = () => {
|
|
125
|
+
o || (o = !0, clearTimeout(l), s(), L.current = null);
|
|
125
126
|
};
|
|
126
|
-
}, [
|
|
127
|
+
}, [R, C]), X = _((e, t, n, r, i = !1, c) => {
|
|
127
128
|
let u = n;
|
|
128
129
|
if (u.length === 0) {
|
|
129
|
-
let e =
|
|
130
|
-
e.length > 0 && (u = e,
|
|
130
|
+
let e = C.listVoices();
|
|
131
|
+
e.length > 0 && (u = e, k(e));
|
|
131
132
|
}
|
|
132
|
-
let d =
|
|
133
|
-
if (
|
|
134
|
-
let t =
|
|
135
|
-
|
|
133
|
+
let d = q(r), f = s(l(!0, u, r, A));
|
|
134
|
+
if (f === "block") {
|
|
135
|
+
let t = w("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, T) });
|
|
136
|
+
j((n) => new Map(n).set(e, t));
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
|
-
if (
|
|
139
|
-
|
|
139
|
+
if (f === "wait-for-voices") {
|
|
140
|
+
Le(e, t, r, i, c);
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
+
j((t) => {
|
|
143
144
|
if (!t.has(e)) return t;
|
|
144
145
|
let n = new Map(t);
|
|
145
146
|
return n.delete(e), n;
|
|
146
|
-
}),
|
|
147
|
-
let
|
|
148
|
-
|
|
147
|
+
}), R();
|
|
148
|
+
let p = M.current + 1;
|
|
149
|
+
M.current = p, D({
|
|
149
150
|
type: "start",
|
|
150
151
|
messageId: e,
|
|
151
|
-
requestId:
|
|
152
|
-
}),
|
|
153
|
-
let
|
|
154
|
-
|
|
155
|
-
requestId:
|
|
156
|
-
chunks:
|
|
152
|
+
requestId: p
|
|
153
|
+
}), N.current = i ? p : null, i && g(e, "ttsStarted");
|
|
154
|
+
let m = c === void 0 ? ee(t) : ee(t, void 0, void 0, { firstChunkMaxChars: c });
|
|
155
|
+
I({
|
|
156
|
+
requestId: p,
|
|
157
|
+
chunks: m,
|
|
157
158
|
index: -1
|
|
158
|
-
}),
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
let
|
|
162
|
-
|
|
159
|
+
}), F.current !== null && clearTimeout(F.current), F.current = setTimeout(() => {
|
|
160
|
+
I((e) => e?.requestId === p && e.index < 0 ? null : e);
|
|
161
|
+
}, _e);
|
|
162
|
+
let h = () => {
|
|
163
|
+
M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), D({
|
|
163
164
|
type: "failed",
|
|
164
|
-
requestId:
|
|
165
|
+
requestId: p
|
|
165
166
|
});
|
|
166
167
|
};
|
|
167
168
|
try {
|
|
168
|
-
|
|
169
|
-
voice: o(u, d,
|
|
169
|
+
C.speak(m, {
|
|
170
|
+
voice: o(u, d, W[r]),
|
|
170
171
|
lang: d,
|
|
171
|
-
rate:
|
|
172
|
+
rate: Ne(r)
|
|
172
173
|
}, {
|
|
173
174
|
onStart: () => {
|
|
174
|
-
|
|
175
|
+
M.current === p && N.current === p && g(e, "firstAudio");
|
|
175
176
|
},
|
|
176
177
|
onChunkStart: (e) => {
|
|
177
|
-
|
|
178
|
+
M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), I((t) => t?.requestId === p ? {
|
|
178
179
|
...t,
|
|
179
180
|
index: e
|
|
180
|
-
} :
|
|
181
|
-
requestId:
|
|
182
|
-
chunks:
|
|
181
|
+
} : M.current === p ? {
|
|
182
|
+
requestId: p,
|
|
183
|
+
chunks: m,
|
|
183
184
|
index: e
|
|
184
185
|
} : t);
|
|
185
186
|
},
|
|
186
187
|
onEnd: () => {
|
|
187
|
-
|
|
188
|
+
M.current === p && N.current === p && g(e, "audioEnded"), D({
|
|
188
189
|
type: "finished",
|
|
189
|
-
requestId:
|
|
190
|
+
requestId: p
|
|
190
191
|
});
|
|
191
192
|
},
|
|
192
|
-
onError: () =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
onError: (t) => {
|
|
194
|
+
t === "output-not-cleared" && M.current === p && we({ messageId: e }), D({
|
|
195
|
+
type: "failed",
|
|
196
|
+
requestId: p
|
|
197
|
+
});
|
|
198
|
+
}
|
|
196
199
|
});
|
|
197
200
|
} catch {
|
|
198
|
-
|
|
201
|
+
h();
|
|
199
202
|
}
|
|
200
203
|
}, [
|
|
201
|
-
|
|
202
|
-
S,
|
|
203
|
-
w,
|
|
204
|
-
U,
|
|
205
|
-
Me,
|
|
206
|
-
K,
|
|
204
|
+
R,
|
|
207
205
|
C,
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
T,
|
|
207
|
+
W,
|
|
208
|
+
Ne,
|
|
209
|
+
q,
|
|
210
|
+
w,
|
|
211
|
+
A,
|
|
212
|
+
Le
|
|
210
213
|
]);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}, [
|
|
214
|
-
let
|
|
215
|
-
if (!
|
|
216
|
-
let i =
|
|
217
|
-
a &&
|
|
214
|
+
y(() => {
|
|
215
|
+
Ee.current = X;
|
|
216
|
+
}, [X]);
|
|
217
|
+
let Z = _((e, t, n, r) => {
|
|
218
|
+
if (!U) return;
|
|
219
|
+
let i = ae(h(t, { labels: ge }), n ?? K), a = h(t, { labels: ie(i, Pe) });
|
|
220
|
+
a && X(e, a, O, i, r?.auto === !0, r?.firstChunkMaxChars);
|
|
218
221
|
}, [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
]),
|
|
225
|
-
if (
|
|
226
|
-
|
|
222
|
+
U,
|
|
223
|
+
Pe,
|
|
224
|
+
K,
|
|
225
|
+
X,
|
|
226
|
+
O
|
|
227
|
+
]), Re = _((e, t, n) => {
|
|
228
|
+
if (se(E, e)) {
|
|
229
|
+
Y();
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
229
|
-
|
|
232
|
+
Z(e, t, n);
|
|
230
233
|
}, [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
E,
|
|
235
|
+
Z,
|
|
236
|
+
Y
|
|
234
237
|
]);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}, [
|
|
238
|
-
let
|
|
239
|
-
autoSpeakEnabled:
|
|
240
|
-
sessionSpeaking:
|
|
241
|
-
visible:
|
|
242
|
-
isSupported:
|
|
238
|
+
y(() => {
|
|
239
|
+
v || Y();
|
|
240
|
+
}, [v, Y]);
|
|
241
|
+
let ze = x({
|
|
242
|
+
autoSpeakEnabled: z,
|
|
243
|
+
sessionSpeaking: B,
|
|
244
|
+
visible: v,
|
|
245
|
+
isSupported: U
|
|
243
246
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
autoSpeakEnabled:
|
|
247
|
-
sessionSpeaking:
|
|
248
|
-
visible:
|
|
249
|
-
isSupported:
|
|
247
|
+
y(() => {
|
|
248
|
+
ze.current = {
|
|
249
|
+
autoSpeakEnabled: z,
|
|
250
|
+
sessionSpeaking: B,
|
|
251
|
+
visible: v,
|
|
252
|
+
isSupported: U
|
|
250
253
|
};
|
|
251
254
|
}, [
|
|
252
|
-
R,
|
|
253
255
|
z,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
B,
|
|
257
|
+
v,
|
|
258
|
+
U
|
|
256
259
|
]);
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
let e =
|
|
261
|
-
|
|
262
|
-
}, [
|
|
263
|
-
|
|
264
|
-
}, [
|
|
265
|
-
|
|
266
|
-
}, [
|
|
260
|
+
let Be = x(null), Ve = x(null), He = x(() => {});
|
|
261
|
+
y(() => {
|
|
262
|
+
Y(), j(/* @__PURE__ */ new Map()), Be.current = H;
|
|
263
|
+
let e = Ve.current;
|
|
264
|
+
Ve.current = null, e && e.conversationId === H && He.current(e.conversationId, e.messageId);
|
|
265
|
+
}, [H, Y]), y(() => {
|
|
266
|
+
j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
|
|
267
|
+
}, [K, Y]), y(() => () => {
|
|
268
|
+
L.current?.(), L.current = null, C.cancel();
|
|
269
|
+
}, [C]), y(() => {
|
|
267
270
|
if (typeof window > "u") return;
|
|
268
|
-
let e = () =>
|
|
271
|
+
let e = () => C.cancel();
|
|
269
272
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
270
|
-
}, [
|
|
271
|
-
if (typeof document > "u" || !
|
|
273
|
+
}, [C]), y(() => {
|
|
274
|
+
if (typeof document > "u" || !U) return;
|
|
272
275
|
let e = () => {
|
|
273
276
|
if (document.visibilityState !== "visible") return;
|
|
274
|
-
let e =
|
|
275
|
-
e.length > 0 &&
|
|
277
|
+
let e = C.listVoices();
|
|
278
|
+
e.length > 0 && R(), k(e), xe(!1), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
276
279
|
};
|
|
277
280
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
278
281
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
279
282
|
};
|
|
280
283
|
}, [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
R,
|
|
285
|
+
C,
|
|
286
|
+
U
|
|
284
287
|
]);
|
|
285
|
-
let
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}, [
|
|
289
|
-
let Q =
|
|
290
|
-
if (r(e) !== t ||
|
|
291
|
-
let { text: n } =
|
|
288
|
+
let Ue = x(Z);
|
|
289
|
+
y(() => {
|
|
290
|
+
Ue.current = Z;
|
|
291
|
+
}, [Z]);
|
|
292
|
+
let Q = _((e, t) => {
|
|
293
|
+
if (r(e) !== t || m(e.id) || P.current?.messageId === e.id || V.current) return;
|
|
294
|
+
let { text: n } = de(e.content);
|
|
292
295
|
if (n.trim()) try {
|
|
293
|
-
|
|
296
|
+
Ue.current(e.id, n, e.metadata?.lang, { auto: !0 });
|
|
294
297
|
} catch {}
|
|
295
|
-
}, []), $ =
|
|
296
|
-
if (e !==
|
|
297
|
-
n.getState().activeConversationId === e && (
|
|
298
|
+
}, []), $ = _((e, t) => {
|
|
299
|
+
if (e !== Be.current) {
|
|
300
|
+
n.getState().activeConversationId === e && (Ve.current = {
|
|
298
301
|
conversationId: e,
|
|
299
302
|
messageId: t
|
|
300
303
|
});
|
|
301
304
|
return;
|
|
302
305
|
}
|
|
303
|
-
let r =
|
|
306
|
+
let r = ze.current;
|
|
304
307
|
if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
|
|
305
308
|
let i = n.getState();
|
|
306
309
|
if (i.activeConversationId !== e) return;
|
|
307
310
|
let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === t);
|
|
308
311
|
!a || a.role !== "assistant" || Q(a, r.sessionSpeaking);
|
|
309
312
|
}, [Q]);
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}, [$]),
|
|
313
|
-
if (!(!
|
|
313
|
+
y(() => {
|
|
314
|
+
He.current = $;
|
|
315
|
+
}, [$]), y(() => {
|
|
316
|
+
if (!(!z && !B || !v || !U)) return n.subscribe((e, t) => {
|
|
314
317
|
let n = e.activeConversationId;
|
|
315
318
|
if (!n || n !== t.activeConversationId) return;
|
|
316
319
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
317
|
-
if (r?.status !== "complete" || !
|
|
320
|
+
if (r?.status !== "complete" || !ue(i?.status)) return;
|
|
318
321
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
319
322
|
if (!a) return;
|
|
320
323
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
321
|
-
!o || o.role !== "assistant" || Q(o,
|
|
324
|
+
!o || o.role !== "assistant" || Q(o, B);
|
|
322
325
|
});
|
|
323
326
|
}, [
|
|
324
|
-
R,
|
|
325
327
|
z,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
B,
|
|
329
|
+
U,
|
|
330
|
+
v,
|
|
328
331
|
Q
|
|
329
332
|
]);
|
|
330
|
-
let
|
|
333
|
+
let We = _((e) => {
|
|
331
334
|
if (e.type === "abort") {
|
|
332
|
-
let t =
|
|
335
|
+
let t = P.current;
|
|
333
336
|
if (!t || t.messageId !== e.messageId) return;
|
|
334
|
-
|
|
337
|
+
P.current = null, (t.requestId === null ? t.waiting && L.current !== null : M.current === t.requestId) && Y();
|
|
335
338
|
return;
|
|
336
339
|
}
|
|
337
|
-
let { messageId: t, item: r } = e, i =
|
|
338
|
-
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking ||
|
|
339
|
-
let { text: a } =
|
|
340
|
+
let { messageId: t, item: r } = e, i = ze.current;
|
|
341
|
+
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || m(t) || V.current || P.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Be.current !== r.conversationId) return;
|
|
342
|
+
let { text: a } = de(r.text);
|
|
340
343
|
if (!a.trim()) return;
|
|
341
|
-
let o =
|
|
344
|
+
let o = M.current;
|
|
342
345
|
try {
|
|
343
|
-
|
|
346
|
+
Ue.current(t, a, r.lang, {
|
|
344
347
|
auto: !0,
|
|
345
348
|
firstChunkMaxChars: 110
|
|
346
349
|
});
|
|
347
350
|
} catch {}
|
|
348
|
-
let s =
|
|
349
|
-
|
|
351
|
+
let s = M.current !== o;
|
|
352
|
+
P.current = {
|
|
350
353
|
messageId: t,
|
|
351
|
-
requestId: s ?
|
|
352
|
-
waiting: !s &&
|
|
354
|
+
requestId: s ? M.current : null,
|
|
355
|
+
waiting: !s && L.current !== null
|
|
353
356
|
};
|
|
354
|
-
}, [
|
|
355
|
-
|
|
356
|
-
let
|
|
357
|
-
|
|
357
|
+
}, [Y]);
|
|
358
|
+
y(() => p.subscribe(We), [We]);
|
|
359
|
+
let Ge = b(() => u(O, G.tag), [O, G]), Ke = b(() => o(O, G.tag, W[K]), [
|
|
360
|
+
O,
|
|
361
|
+
G,
|
|
358
362
|
W,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
isSpeaking: (e) =>
|
|
374
|
-
toggle:
|
|
375
|
-
stop:
|
|
376
|
-
autoSpeakEnabled:
|
|
377
|
-
setAutoSpeak:
|
|
378
|
-
sessionSpeaking:
|
|
379
|
-
setSessionSpeaking:
|
|
380
|
-
setSessionMicOpen:
|
|
363
|
+
K
|
|
364
|
+
]), qe = b(() => ({
|
|
365
|
+
isSupported: U,
|
|
366
|
+
availability: J,
|
|
367
|
+
isBlocked: J === "no-voices",
|
|
368
|
+
disabledReason: J === "no-voices" ? w("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
369
|
+
blockedFor: Ie,
|
|
370
|
+
voiceChoices: Ge,
|
|
371
|
+
spokenChunks: ce(E, Te),
|
|
372
|
+
activeVoiceName: Ke?.name ?? null,
|
|
373
|
+
preferredVoiceName: W[K] ?? null,
|
|
374
|
+
setVoice: (e) => Me(K, e),
|
|
375
|
+
speakingMessageId: E.status === "speaking" ? E.messageId : null,
|
|
376
|
+
outputNotCleared: Ce,
|
|
377
|
+
isSpeaking: (e) => se(E, e),
|
|
378
|
+
toggle: Re,
|
|
379
|
+
stop: Y,
|
|
380
|
+
autoSpeakEnabled: z,
|
|
381
|
+
setAutoSpeak: De,
|
|
382
|
+
sessionSpeaking: B,
|
|
383
|
+
setSessionSpeaking: Oe,
|
|
384
|
+
setSessionMicOpen: ke,
|
|
381
385
|
speakFinishedReply: $,
|
|
382
|
-
previewVoice:
|
|
386
|
+
previewVoice: Fe
|
|
383
387
|
}), [
|
|
384
|
-
H,
|
|
385
|
-
q,
|
|
386
|
-
Fe,
|
|
387
|
-
Ue,
|
|
388
|
-
We,
|
|
389
388
|
U,
|
|
390
|
-
je,
|
|
391
|
-
G,
|
|
392
|
-
T,
|
|
393
|
-
Le,
|
|
394
389
|
J,
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
Ie,
|
|
391
|
+
Ge,
|
|
392
|
+
Ke,
|
|
393
|
+
W,
|
|
394
|
+
Me,
|
|
395
|
+
K,
|
|
396
|
+
E,
|
|
397
|
+
Ce,
|
|
398
|
+
Re,
|
|
399
|
+
Y,
|
|
397
400
|
z,
|
|
398
|
-
|
|
401
|
+
De,
|
|
402
|
+
B,
|
|
403
|
+
ke,
|
|
399
404
|
$,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
405
|
+
Fe,
|
|
406
|
+
w,
|
|
407
|
+
Te
|
|
403
408
|
]);
|
|
404
|
-
return /* @__PURE__ */
|
|
405
|
-
value:
|
|
406
|
-
children:
|
|
409
|
+
return /* @__PURE__ */ he(ve.Provider, {
|
|
410
|
+
value: qe,
|
|
411
|
+
children: fe
|
|
407
412
|
});
|
|
408
413
|
};
|
|
409
414
|
//#endregion
|
|
410
|
-
export {
|
|
415
|
+
export { be as AssistantSpeechProvider, ye as useAssistantSpeech };
|