@burdenoff/fe-libs 2026.1013.9 → 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/index.d.ts +1 -0
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +96 -72
- package/dist/shared/assistant/speech/pieceSink.d.ts +51 -0
- package/dist/shared/assistant/speech/pieceSink.js +90 -0
- package/dist/shared/assistant/speech/routingSpeechEngine.js +47 -37
- package/dist/shared/assistant/speech/types.d.ts +105 -1
- package/dist/shared/assistant/speech/types.js +4 -0
- 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 -238
- package/package.json +1 -1
|
@@ -14,7 +14,13 @@ export type VoiceSessionNotice = "network" | "not-capturing" | "nothing-heard" |
|
|
|
14
14
|
/** H3: a barge-in stopped the assistant but no words followed (a cough, a door). */
|
|
15
15
|
| "hands-free-nothing-heard"
|
|
16
16
|
/** H3: hands-free gave up for this conversation; the tap-first path is in charge. */
|
|
17
|
-
| "hands-free-fallback"
|
|
17
|
+
| "hands-free-fallback"
|
|
18
|
+
/**
|
|
19
|
+
* BOFF-8822 (operator decision D7 b): this turn's reply was refused by its
|
|
20
|
+
* audio output (`output-not-cleared`) and never heard; its text is in the
|
|
21
|
+
* transcript.
|
|
22
|
+
*/
|
|
23
|
+
| "reply-not-heard";
|
|
18
24
|
/**
|
|
19
25
|
* A line the PANEL says in the voice conversation, outside any turn (BOFF-7803
|
|
20
26
|
* FE9: the readback of a change that waits for its button).
|
|
@@ -3,245 +3,253 @@ import { planSubmitTimer as t, resolveVoiceGraceMs as n } from "../voice/handsFr
|
|
|
3
3
|
import { readHandsFreeOverride as r, resolveHandsFreeEnabled as ee } from "../voice/handsfree/handsFreeSetting.js";
|
|
4
4
|
import { silencePlaybackReference as te } from "../voice/handsfree/playbackReference.js";
|
|
5
5
|
import { speechFeed as ne } from "../speech/speechFeed.js";
|
|
6
|
-
import { INITIAL_SESSION as re, INTERRUPT_MAX_MS as ie, NOTHING_HEARD as ae, advanceHeardClock as oe, isCapturing as
|
|
7
|
-
import { useHandsFreeInterrupt as
|
|
8
|
-
import { isTurnSuperseded as
|
|
9
|
-
import { captionChunks as
|
|
10
|
-
import { turnClockMs as
|
|
11
|
-
import { useAssistantSpeech as
|
|
12
|
-
import { useCallback as
|
|
6
|
+
import { INITIAL_SESSION as re, INTERRUPT_MAX_MS as ie, NOTHING_HEARD as ae, advanceHeardClock as oe, isCapturing as se, isSubmittable as ce, planListeningHold as le, planReplyConsumption as ue, planVoiceAnnouncement as de, shouldRecognise as fe, spokenSoFar as i, voiceSessionReducer as pe } from "../voice/voiceSession.js";
|
|
7
|
+
import { useHandsFreeInterrupt as me } from "../voice/handsfree/useHandsFreeInterrupt.js";
|
|
8
|
+
import { isTurnSuperseded as a } from "../voice/supersededTurns.js";
|
|
9
|
+
import { captionChunks as he } from "../voice/speechPlayback.js";
|
|
10
|
+
import { turnClockMs as o } from "../turnTimeline.js";
|
|
11
|
+
import { useAssistantSpeech as ge } from "./AssistantSpeechProvider.js";
|
|
12
|
+
import { useCallback as s, useEffect as c, useLayoutEffect as _e, useMemo as ve, useReducer as ye, useRef as l, useState as u } from "react";
|
|
13
13
|
//#region src/shared/assistant/ui/useVoiceSession.ts
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
}, []),
|
|
14
|
+
var be = 4e3, xe = 2500, Se = 5e3, Ce = 12e3, we = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
|
|
15
|
+
function Te({ onSubmit: Te, latestReply: d, language: f, graceMs: Ee, onSupersede: De, handsFreeInterrupt: Oe, handsFreeStreamNoticeAccepted: ke, onAcceptHandsFreeStreamNotice: Ae, onBargeIn: je }) {
|
|
16
|
+
let Me = n(Ee), p = l(null), [m, h] = ye(s((e, t) => pe(e, t, p.current), []), re), g = ge(), { setSessionSpeaking: _, setSessionMicOpen: v, speakingMessageId: y, stop: b } = g, x = l(g.toggle), S = g.toggle;
|
|
17
|
+
_e(() => {
|
|
18
|
+
x.current = S;
|
|
19
|
+
}, [S]);
|
|
20
|
+
let C = l(null), w = l({}), T = l(ae), E = l(null), D = l(!1), O = l(null), [k, A] = u(null), [j, M] = u(!1), [Ne, N] = u(!1), [P, F] = u(!1), I = l(m);
|
|
21
|
+
I.current = m;
|
|
22
|
+
let L = l([]), R = l(null), z = l(!1), B = s(() => {
|
|
23
|
+
L.current = [], R.current = null, z.current = !1;
|
|
24
|
+
}, []), V = s(() => {
|
|
25
25
|
for (;;) {
|
|
26
|
-
let e =
|
|
26
|
+
let e = L.current.shift();
|
|
27
27
|
if (!e) return !1;
|
|
28
28
|
if (!(e.stillWanted && !e.stillWanted())) {
|
|
29
|
-
|
|
29
|
+
R.current = e, p.current = p.current ? `${p.current} ${e.text}` : e.text;
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
x.current(e.id, e.text, e.lang);
|
|
32
32
|
} catch {
|
|
33
|
-
|
|
33
|
+
R.current = null;
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
return !0;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}, []),
|
|
40
|
-
let t =
|
|
39
|
+
}, []), H = l(!1), Pe = s((e) => {
|
|
40
|
+
let t = le({
|
|
41
41
|
requested: e,
|
|
42
|
-
held:
|
|
43
|
-
muted:
|
|
42
|
+
held: H.current,
|
|
43
|
+
muted: I.current.muted
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
H.current = t.held, t.mute !== null && h({
|
|
46
46
|
type: "mute",
|
|
47
47
|
muted: t.mute
|
|
48
48
|
});
|
|
49
|
-
}, []),
|
|
50
|
-
let t =
|
|
51
|
-
t !== "drop" && (
|
|
52
|
-
}, []),
|
|
53
|
-
if (
|
|
54
|
-
|
|
49
|
+
}, []), U = s((e) => {
|
|
50
|
+
let t = de(I.current);
|
|
51
|
+
t !== "drop" && (R.current?.id === e.id || L.current.some((t) => t.id === e.id) || (L.current.push(e), t === "start" && !z.current && (z.current = !0, h({ type: "announce" }))));
|
|
52
|
+
}, []), Fe = s((e) => {
|
|
53
|
+
if (I.current.phase !== "thinking") {
|
|
54
|
+
U(e);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
}, [
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
62
|
-
|
|
57
|
+
L.current.push(e), z.current = !0, h({ type: "answered-locally" });
|
|
58
|
+
}, [U]), Ie = l(d);
|
|
59
|
+
Ie.current = d, c(() => {
|
|
60
|
+
if (m.phase === "speaking") {
|
|
61
|
+
let e = O.current;
|
|
62
|
+
p.current = e && E.current === e.id && d?.id !== e.id ? e.text : d?.text ?? null;
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
65
|
+
if (p.current === null) return;
|
|
66
66
|
let e = setTimeout(() => {
|
|
67
|
-
|
|
68
|
-
},
|
|
67
|
+
p.current = null;
|
|
68
|
+
}, xe);
|
|
69
69
|
return () => clearTimeout(e);
|
|
70
|
-
}, [
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
|
|
70
|
+
}, [m.phase, d]);
|
|
71
|
+
let W = l(f);
|
|
72
|
+
W.current = f;
|
|
73
|
+
let G = s((e, t) => {
|
|
74
|
+
h({
|
|
75
75
|
type: "speech",
|
|
76
76
|
transcript: e,
|
|
77
77
|
final: t,
|
|
78
78
|
at: Date.now(),
|
|
79
|
-
language:
|
|
79
|
+
language: W.current
|
|
80
80
|
});
|
|
81
|
-
}, []),
|
|
82
|
-
|
|
81
|
+
}, []), Le = s((e, t, n) => {
|
|
82
|
+
h({
|
|
83
83
|
type: "speech",
|
|
84
84
|
transcript: e,
|
|
85
85
|
final: t,
|
|
86
86
|
at: Date.now(),
|
|
87
|
-
language: n ??
|
|
87
|
+
language: n ?? W.current,
|
|
88
88
|
gated: !0
|
|
89
89
|
});
|
|
90
|
-
}, []),
|
|
91
|
-
|
|
92
|
-
}, [
|
|
93
|
-
onFinalize:
|
|
94
|
-
language:
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
let
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
enabled: ee(
|
|
101
|
-
phase:
|
|
102
|
-
muted:
|
|
103
|
-
language:
|
|
104
|
-
streamNoticeAccepted:
|
|
105
|
-
onAcceptStreamNotice:
|
|
106
|
-
onBargeIn:
|
|
107
|
-
onTranscript:
|
|
108
|
-
}),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, [
|
|
112
|
-
|
|
90
|
+
}, []), K = l(0), Re = s(() => {
|
|
91
|
+
B(), b(), K.current = Date.now(), M(!0), h({ type: "interrupt" });
|
|
92
|
+
}, [b, B]), q = e({
|
|
93
|
+
onFinalize: s((e) => G(e, !0), [G]),
|
|
94
|
+
language: f
|
|
95
|
+
}), ze = l(je);
|
|
96
|
+
ze.current = je;
|
|
97
|
+
let Be = s(() => {
|
|
98
|
+
B(), te(), b(), K.current = Date.now(), M(!0), h({ type: "interrupt" }), ze.current?.();
|
|
99
|
+
}, [b, B]), J = me({
|
|
100
|
+
enabled: ee(Oe, r()),
|
|
101
|
+
phase: m.phase,
|
|
102
|
+
muted: m.muted,
|
|
103
|
+
language: f,
|
|
104
|
+
streamNoticeAccepted: ke ?? null,
|
|
105
|
+
onAcceptStreamNotice: Ae,
|
|
106
|
+
onBargeIn: Be,
|
|
107
|
+
onTranscript: Le
|
|
108
|
+
}), Ve = J.mode === "notice", Y = q.isListening || J.suppressWebSpeech && J.mode === "active";
|
|
109
|
+
c(() => {
|
|
110
|
+
q.interim && G(q.interim, !1);
|
|
111
|
+
}, [q.interim, G]), c(() => {
|
|
112
|
+
C.current && clearTimeout(C.current), N(!1), T.current = oe(T.current, m, o());
|
|
113
113
|
let e = t({
|
|
114
|
-
phase:
|
|
115
|
-
muted:
|
|
116
|
-
spoken:
|
|
117
|
-
holding:
|
|
118
|
-
graceMs:
|
|
114
|
+
phase: m.phase,
|
|
115
|
+
muted: m.muted,
|
|
116
|
+
spoken: i(m),
|
|
117
|
+
holding: P,
|
|
118
|
+
graceMs: Me
|
|
119
119
|
});
|
|
120
120
|
if (!e.arm) return;
|
|
121
|
-
let n = setTimeout(() =>
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
speechEnded:
|
|
121
|
+
let n = setTimeout(() => N(!0), Math.min(800, e.delayMs)), r = o();
|
|
122
|
+
return C.current = setTimeout(() => {
|
|
123
|
+
w.current = {
|
|
124
|
+
speechEnded: T.current.at ?? r,
|
|
125
125
|
graceStarted: r,
|
|
126
|
-
graceEnded:
|
|
127
|
-
},
|
|
126
|
+
graceEnded: o()
|
|
127
|
+
}, h({
|
|
128
128
|
type: "silence",
|
|
129
129
|
at: Date.now()
|
|
130
130
|
});
|
|
131
131
|
}, e.delayMs), () => {
|
|
132
|
-
clearTimeout(n),
|
|
132
|
+
clearTimeout(n), C.current && clearTimeout(C.current);
|
|
133
133
|
};
|
|
134
134
|
}, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
]),
|
|
139
|
-
(
|
|
140
|
-
}, [
|
|
141
|
-
if (!
|
|
142
|
-
let e = Date.now() -
|
|
135
|
+
m,
|
|
136
|
+
P,
|
|
137
|
+
Me
|
|
138
|
+
]), c(() => {
|
|
139
|
+
(m.phase !== "listening" || m.muted) && F(!1);
|
|
140
|
+
}, [m.phase, m.muted]), c(() => {
|
|
141
|
+
if (!j) return;
|
|
142
|
+
let e = Date.now() - K.current, t = Y ? Math.max(0, 500 - e) : Math.max(0, ie - e), n = setTimeout(() => M(!1), t);
|
|
143
143
|
return () => clearTimeout(n);
|
|
144
|
-
}, [
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
let e =
|
|
150
|
-
e &&
|
|
151
|
-
}, [
|
|
152
|
-
let e =
|
|
153
|
-
e.claim && (
|
|
144
|
+
}, [j, Y]);
|
|
145
|
+
let He = l("");
|
|
146
|
+
m.phase === "listening" && (He.current = i(m)), c(() => {
|
|
147
|
+
if (m.phase !== "thinking") return;
|
|
148
|
+
v(!1), B();
|
|
149
|
+
let e = He.current.trim();
|
|
150
|
+
e && Te(e, Z.current ?? `vs-orphan-${Date.now().toString(36)}`, w.current, { correction: I.current.correcting }), w.current = {}, T.current = ae;
|
|
151
|
+
}, [m.phase]), c(() => {
|
|
152
|
+
let e = ue(d?.id, m.phase, E.current, a(d?.id));
|
|
153
|
+
e.claim && (E.current = d?.id ?? null, e.advance && d && h({
|
|
154
154
|
type: "reply",
|
|
155
|
-
text:
|
|
155
|
+
text: d.text
|
|
156
156
|
}));
|
|
157
|
-
}, [
|
|
158
|
-
if (
|
|
159
|
-
if (
|
|
160
|
-
|
|
157
|
+
}, [d, m.phase]), c(() => {
|
|
158
|
+
if (y === null || m.phase !== "thinking" || E.current === y) return;
|
|
159
|
+
if (a(y)) {
|
|
160
|
+
b();
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
let e = ne.peek(
|
|
164
|
-
!e || e.channel !== "voice" || e.voiceSessionId === void 0 || e.voiceSessionId !==
|
|
165
|
-
id:
|
|
163
|
+
let e = ne.peek(y);
|
|
164
|
+
!e || e.channel !== "voice" || e.voiceSessionId === void 0 || e.voiceSessionId !== Z.current || (E.current = y, O.current = {
|
|
165
|
+
id: y,
|
|
166
166
|
text: e.text
|
|
167
|
-
},
|
|
167
|
+
}, h({
|
|
168
168
|
type: "reply-audio-started",
|
|
169
|
-
replyId:
|
|
169
|
+
replyId: y
|
|
170
170
|
}));
|
|
171
171
|
}, [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
]),
|
|
176
|
-
let e =
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
|
|
180
|
-
}, [
|
|
181
|
-
if (
|
|
172
|
+
y,
|
|
173
|
+
m.phase,
|
|
174
|
+
b
|
|
175
|
+
]), c(() => {
|
|
176
|
+
let e = y !== null;
|
|
177
|
+
D.current && !e && (R.current = null, (I.current.phase !== "speaking" || !V()) && h({ type: "speech-ended" })), D.current = e;
|
|
178
|
+
}, [y, V]), c(() => {
|
|
179
|
+
m.phase !== "listening" && A((e) => e === "nothing-heard" ? null : e);
|
|
180
|
+
}, [m.phase]), c(() => {
|
|
181
|
+
if (m.phase !== "speaking" || y !== null) return;
|
|
182
182
|
let e = setTimeout(() => {
|
|
183
|
-
|
|
184
|
-
},
|
|
183
|
+
D.current || (B(), h({ type: "speech-ended" }));
|
|
184
|
+
}, be);
|
|
185
185
|
return () => clearTimeout(e);
|
|
186
186
|
}, [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
m.phase,
|
|
188
|
+
y,
|
|
189
|
+
B
|
|
190
190
|
]);
|
|
191
|
-
let
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
let X = g.outputNotCleared;
|
|
192
|
+
c(() => {
|
|
193
|
+
if (X === null || E.current !== X.messageId) return;
|
|
194
|
+
let { phase: e } = I.current;
|
|
195
|
+
e === "idle" || e === "ended" || e === "thinking" || A("reply-not-heard");
|
|
196
|
+
}, [X]), c(() => {
|
|
197
|
+
m.phase === "listening" || m.phase === "thinking" || A((e) => e === "reply-not-heard" ? null : e);
|
|
198
|
+
}, [m.phase]);
|
|
199
|
+
let Ue = l(De);
|
|
200
|
+
Ue.current = De;
|
|
201
|
+
let We = l(0);
|
|
202
|
+
c(() => {
|
|
203
|
+
let e = m.superseded;
|
|
204
|
+
e !== We.current && (We.current = e, e !== 0 && (B(), b(), Ue.current?.()));
|
|
197
205
|
}, [
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
]),
|
|
202
|
-
|
|
206
|
+
m.superseded,
|
|
207
|
+
B,
|
|
208
|
+
b
|
|
209
|
+
]), c(() => {
|
|
210
|
+
v(se(m)), fe(m) && !J.suppressWebSpeech ? q.isActive || q.start("auto") : q.isActive && q.stop();
|
|
203
211
|
}, [
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
]),
|
|
209
|
-
|
|
210
|
-
}, [
|
|
211
|
-
|
|
212
|
+
m,
|
|
213
|
+
q,
|
|
214
|
+
v,
|
|
215
|
+
J.suppressWebSpeech
|
|
216
|
+
]), c(() => {
|
|
217
|
+
m.phase !== "speaking" || !z.current || (z.current = !1, V() || h({ type: "speech-ended" }));
|
|
218
|
+
}, [m.phase, V]), c(() => {
|
|
219
|
+
q.error === "not-allowed" || q.error === "audio-capture" ? h({
|
|
212
220
|
type: "fail",
|
|
213
221
|
error: "mic-denied"
|
|
214
|
-
}) :
|
|
222
|
+
}) : q.error === "language-not-supported" ? h({
|
|
215
223
|
type: "fail",
|
|
216
224
|
error: "no-speech-support"
|
|
217
|
-
}) :
|
|
218
|
-
}, [
|
|
219
|
-
|
|
220
|
-
}, [
|
|
221
|
-
if (
|
|
222
|
-
let e = setTimeout(() =>
|
|
225
|
+
}) : q.error === "network" ? A("network") : q.error === "unknown" && A("recognition-failed");
|
|
226
|
+
}, [q.error]), c(() => {
|
|
227
|
+
q.error !== null || !Y || A((e) => e === "network" || e === "recognition-failed" ? null : e);
|
|
228
|
+
}, [q.error, Y]), c(() => {
|
|
229
|
+
if (Y && A((e) => e === "not-capturing" ? null : e), !se(m) || Y || Ve) return;
|
|
230
|
+
let e = setTimeout(() => A("not-capturing"), Se);
|
|
223
231
|
return () => clearTimeout(e);
|
|
224
232
|
}, [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
]),
|
|
229
|
-
if (
|
|
230
|
-
let e = setTimeout(() =>
|
|
233
|
+
m,
|
|
234
|
+
Y,
|
|
235
|
+
Ve
|
|
236
|
+
]), c(() => {
|
|
237
|
+
if (m.phase !== "listening" || m.muted || !Y || i(m) !== "") return;
|
|
238
|
+
let e = setTimeout(() => A("nothing-heard"), Ce);
|
|
231
239
|
return () => clearTimeout(e);
|
|
232
|
-
}, [
|
|
233
|
-
|
|
234
|
-
}, [
|
|
235
|
-
let
|
|
236
|
-
if (
|
|
237
|
-
|
|
240
|
+
}, [m, Y]), c(() => {
|
|
241
|
+
i(m) !== "" && A(null);
|
|
242
|
+
}, [m]);
|
|
243
|
+
let Z = l(null), Ge = s(() => {
|
|
244
|
+
if (M(!1), N(!1), F(!1), B(), H.current = !1, !q.isSupported) {
|
|
245
|
+
h({
|
|
238
246
|
type: "fail",
|
|
239
247
|
error: "no-speech-support"
|
|
240
248
|
});
|
|
241
249
|
return;
|
|
242
250
|
}
|
|
243
|
-
if (
|
|
244
|
-
|
|
251
|
+
if (g.isBlocked) {
|
|
252
|
+
h({
|
|
245
253
|
type: "fail",
|
|
246
254
|
error: "no-voice-support"
|
|
247
255
|
});
|
|
@@ -256,102 +264,102 @@ function we({ onSubmit: we, latestReply: f, language: p, graceMs: Te, onSupersed
|
|
|
256
264
|
} catch {}
|
|
257
265
|
try {
|
|
258
266
|
if (typeof window < "u" && typeof window.Audio == "function") {
|
|
259
|
-
let e = new window.Audio(
|
|
267
|
+
let e = new window.Audio(we);
|
|
260
268
|
e.volume = 0, e.play().catch(() => {});
|
|
261
269
|
}
|
|
262
270
|
} catch {}
|
|
263
|
-
|
|
271
|
+
_(!0), A(null), E.current = Ie.current?.id ?? null, O.current = null, Z.current = `vs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, h({ type: "start" });
|
|
264
272
|
}, [
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
]),
|
|
270
|
-
|
|
273
|
+
q.isSupported,
|
|
274
|
+
g.isBlocked,
|
|
275
|
+
_,
|
|
276
|
+
B
|
|
277
|
+
]), Q = s(() => {
|
|
278
|
+
M(!1), N(!1), F(!1), B(), H.current = !1, Z.current = null, h({ type: "end" }), b(), _(!1);
|
|
271
279
|
}, [
|
|
272
|
-
C,
|
|
273
280
|
b,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
e
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
_,
|
|
282
|
+
B
|
|
283
|
+
]), Ke = s((e) => Z.current === e, []), qe = s(() => {
|
|
284
|
+
let e = I.current;
|
|
285
|
+
e.phase !== "listening" || e.muted || F(!0);
|
|
286
|
+
}, []), Je = s(() => {
|
|
287
|
+
F(!1);
|
|
288
|
+
let e = I.current;
|
|
289
|
+
if (e.phase !== "listening" || e.muted || !ce(i(e))) return;
|
|
290
|
+
let t = o();
|
|
291
|
+
w.current = {
|
|
292
|
+
speechEnded: T.current.at ?? t,
|
|
285
293
|
graceStarted: t,
|
|
286
294
|
graceEnded: t
|
|
287
|
-
},
|
|
295
|
+
}, h({
|
|
288
296
|
type: "silence",
|
|
289
297
|
at: Date.now()
|
|
290
298
|
});
|
|
291
|
-
}, []),
|
|
292
|
-
|
|
299
|
+
}, []), Ye = s(() => {
|
|
300
|
+
h({
|
|
293
301
|
type: "mute",
|
|
294
|
-
muted: !
|
|
302
|
+
muted: !I.current.muted
|
|
295
303
|
});
|
|
296
304
|
}, []);
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}, [
|
|
300
|
-
let
|
|
301
|
-
return
|
|
302
|
-
session:
|
|
303
|
-
notice:
|
|
304
|
-
spokenChunks:
|
|
305
|
-
capturing:
|
|
306
|
-
active:
|
|
307
|
-
interrupting:
|
|
308
|
-
awaitingEndpoint:
|
|
309
|
-
holding:
|
|
310
|
-
correcting:
|
|
305
|
+
c(() => () => {
|
|
306
|
+
_(!1), v(!1);
|
|
307
|
+
}, [_, v]);
|
|
308
|
+
let $ = he(g.spokenChunks, m.phase, y);
|
|
309
|
+
return ve(() => ({
|
|
310
|
+
session: m,
|
|
311
|
+
notice: k ?? (J.fallbackReason !== null && J.fallbackReason !== "notice-declined" ? "hands-free-fallback" : J.nothingHeard ? "hands-free-nothing-heard" : null),
|
|
312
|
+
spokenChunks: $,
|
|
313
|
+
capturing: Y,
|
|
314
|
+
active: m.phase !== "idle" && (m.phase !== "ended" || m.error !== null),
|
|
315
|
+
interrupting: j,
|
|
316
|
+
awaitingEndpoint: Ne,
|
|
317
|
+
holding: P,
|
|
318
|
+
correcting: m.correcting,
|
|
311
319
|
handsFree: {
|
|
312
|
-
mode:
|
|
313
|
-
nothingHeard:
|
|
314
|
-
transportKind:
|
|
315
|
-
fallbackReason:
|
|
316
|
-
privacyNotice:
|
|
320
|
+
mode: J.mode,
|
|
321
|
+
nothingHeard: J.nothingHeard,
|
|
322
|
+
transportKind: J.transportKind,
|
|
323
|
+
fallbackReason: J.fallbackReason,
|
|
324
|
+
privacyNotice: J.privacyNotice
|
|
317
325
|
},
|
|
318
|
-
available:
|
|
319
|
-
start:
|
|
320
|
-
end:
|
|
321
|
-
isCurrentSession:
|
|
322
|
-
toggleMute:
|
|
323
|
-
interrupt:
|
|
324
|
-
letMeFinish:
|
|
325
|
-
imDone:
|
|
326
|
-
announce:
|
|
327
|
-
holdListening:
|
|
328
|
-
answerLocally:
|
|
326
|
+
available: q.isSupported && !g.isBlocked,
|
|
327
|
+
start: Ge,
|
|
328
|
+
end: Q,
|
|
329
|
+
isCurrentSession: Ke,
|
|
330
|
+
toggleMute: Ye,
|
|
331
|
+
interrupt: Re,
|
|
332
|
+
letMeFinish: qe,
|
|
333
|
+
imDone: Je,
|
|
334
|
+
announce: U,
|
|
335
|
+
holdListening: Pe,
|
|
336
|
+
answerLocally: Fe
|
|
329
337
|
}), [
|
|
330
|
-
|
|
331
|
-
|
|
338
|
+
m,
|
|
339
|
+
k,
|
|
340
|
+
j,
|
|
341
|
+
Ne,
|
|
332
342
|
P,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
y.isBlocked,
|
|
343
|
-
Je,
|
|
344
|
-
He,
|
|
345
|
-
Ue,
|
|
346
|
-
We,
|
|
347
|
-
qe,
|
|
348
|
-
Fe,
|
|
343
|
+
Y,
|
|
344
|
+
J.mode,
|
|
345
|
+
J.nothingHeard,
|
|
346
|
+
J.transportKind,
|
|
347
|
+
J.fallbackReason,
|
|
348
|
+
J.privacyNotice,
|
|
349
|
+
q.isSupported,
|
|
350
|
+
g.isBlocked,
|
|
351
|
+
$,
|
|
349
352
|
Ge,
|
|
353
|
+
Q,
|
|
350
354
|
Ke,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
Ye,
|
|
356
|
+
Re,
|
|
357
|
+
qe,
|
|
358
|
+
Je,
|
|
359
|
+
U,
|
|
360
|
+
Pe,
|
|
361
|
+
Fe
|
|
354
362
|
]);
|
|
355
363
|
}
|
|
356
364
|
//#endregion
|
|
357
|
-
export {
|
|
365
|
+
export { Te as useVoiceSession };
|