@burdenoff/fe-libs 2026.1117.4 → 2026.1117.5
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/ui/useVoiceSession.js +312 -301
- package/dist/shared/assistant/voice/handsFree.d.ts +16 -0
- package/dist/shared/assistant/voice/handsFree.js +2 -2
- package/dist/shared/assistant/voice/handsfree/audioTrackTransport.js +1 -0
- package/dist/shared/assistant/voice/handsfree/backendStreamTransport.d.ts +11 -0
- package/dist/shared/assistant/voice/handsfree/backendStreamTransport.js +118 -63
- package/dist/shared/assistant/voice/handsfree/bargeIn.d.ts +20 -1
- package/dist/shared/assistant/voice/handsfree/bargeIn.js +3 -3
- package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +10 -1
- package/dist/shared/assistant/voice/handsfree/handsFreeController.js +103 -83
- package/dist/shared/assistant/voice/handsfree/sttTransport.d.ts +20 -0
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +8 -0
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.js +31 -26
- package/dist/shared/assistant/voice/handsfree/webSpeechTransport.js +1 -0
- package/dist/shared-assistant.js +399 -399
- package/package.json +1 -1
|
@@ -35,6 +35,13 @@ export interface SttTransportError {
|
|
|
35
35
|
export interface SttTransportHandlers {
|
|
36
36
|
onTranscript(transcript: TransportTranscript): void;
|
|
37
37
|
onError(error: SttTransportError): void;
|
|
38
|
+
/**
|
|
39
|
+
* The recogniser is finished with this utterance: the stream said `done`, or
|
|
40
|
+
* dropped it (a retryable error naming it). Transports whose words arrive
|
|
41
|
+
* `after-utterance` call it; for them the controller judges "nothing heard"
|
|
42
|
+
* here (see `SttTransport.wordsArrive`).
|
|
43
|
+
*/
|
|
44
|
+
onUtteranceDone(utteranceId: string): void;
|
|
38
45
|
}
|
|
39
46
|
export interface SttAudioGraph {
|
|
40
47
|
context: AudioContext;
|
|
@@ -58,6 +65,19 @@ export interface SttTransport {
|
|
|
58
65
|
readonly recognitionOwner: 'transport' | 'session-hook';
|
|
59
66
|
/** Whether the words spoken BEFORE the onset was confirmed reach the recogniser. */
|
|
60
67
|
readonly keepsOpeningWords: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* When an utterance's first words can arrive (read only when
|
|
70
|
+
* `recognitionOwner` is `transport`):
|
|
71
|
+
* - `while-speaking`: the recogniser sends partial text as the person talks
|
|
72
|
+
* (Chrome's, with `interimResults`), so no words for `NOTHING_HEARD_MS`
|
|
73
|
+
* after a barge-in means nothing was heard;
|
|
74
|
+
* - `after-utterance`: the first words may come only once the utterance is
|
|
75
|
+
* finalised. Our stream on Google's `chirp_3` sends no partial text (alpha,
|
|
76
|
+
* 17 Nov: one final, 1.0 s after `end`), so a fixed timer would call every
|
|
77
|
+
* real interruption "nothing heard". The controller waits for
|
|
78
|
+
* `onUtteranceDone` instead.
|
|
79
|
+
*/
|
|
80
|
+
readonly wordsArrive: 'while-speaking' | 'after-utterance';
|
|
61
81
|
start(graph: SttAudioGraph | null, language: string, handlers: SttTransportHandlers): Promise<void>;
|
|
62
82
|
openUtterance(utterance: OpenUtterance): void;
|
|
63
83
|
/** A live 16 kHz frame while an utterance is open. */
|
|
@@ -51,5 +51,13 @@ export interface HandsFreeState {
|
|
|
51
51
|
nothingHeard: boolean;
|
|
52
52
|
/** Non-null exactly while `mode` is `notice`: what the notice's buttons do. */
|
|
53
53
|
privacyNotice: HandsFreePrivacyNoticeActions | null;
|
|
54
|
+
/**
|
|
55
|
+
* The running transport sends an utterance's words only once it is finalised
|
|
56
|
+
* (our stream on chirp_3, BOFF-12936): the session times its pause from the
|
|
57
|
+
* last voiced frame instead of from the words.
|
|
58
|
+
*/
|
|
59
|
+
wordsAfterUtterance: boolean;
|
|
60
|
+
/** On such a transport: words of this turn are still to come; nothing may be sent yet. */
|
|
61
|
+
wordsPending: boolean;
|
|
54
62
|
}
|
|
55
63
|
export declare function useHandsFreeInterrupt(options: UseHandsFreeInterruptOptions): HandsFreeState;
|
|
@@ -17,39 +17,41 @@ var y = (e) => e === "listening" || e === "thinking" || e === "speaking";
|
|
|
17
17
|
function b(t) {
|
|
18
18
|
let { enabled: r, phase: i, muted: b, language: x, streamNoticeAccepted: S } = t, C = m(t);
|
|
19
19
|
C.current = t;
|
|
20
|
-
let [w, T] = h(null), [E, D] = h(!1), [O, k] = h(!1), [A, j] = h(!1), M = m(!1), [
|
|
20
|
+
let [w, T] = h(null), [E, D] = h(!1), [O, k] = h(!1), [A, j] = h(!1), [M, N] = h(!1), [P, F] = h(!1), I = m(!1), [L, R] = h(!1), z = g(u, l, l), B = p(() => v(x, z), [x, z]), V = B.kind;
|
|
21
21
|
f(() => {
|
|
22
|
-
S !== "google-stt-eu-1" &&
|
|
22
|
+
S !== "google-stt-eu-1" && R(!1);
|
|
23
23
|
}, [S]), f(() => {
|
|
24
24
|
(i === "idle" || i === "ended") && (T(null), D(!1));
|
|
25
25
|
}, [i]), f(() => {
|
|
26
26
|
if (!r || typeof document > "u") return;
|
|
27
27
|
let e = null, t = () => {
|
|
28
|
-
e !== null && clearTimeout(e), e = null, document.visibilityState === "hidden" ? e = setTimeout(() =>
|
|
28
|
+
e !== null && clearTimeout(e), e = null, document.visibilityState === "hidden" ? e = setTimeout(() => N(!0), _) : N(!1);
|
|
29
29
|
};
|
|
30
30
|
return document.addEventListener("visibilitychange", t), () => {
|
|
31
31
|
document.removeEventListener("visibilitychange", t), e !== null && clearTimeout(e);
|
|
32
32
|
};
|
|
33
33
|
}, [r]);
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
}, []),
|
|
34
|
+
let H = r && B.supported && y(i) && !b && w === null && !M, U = V === "backend-stream" && !L && S !== "google-stt-eu-1", W = H && U, G = H && !U, K = d(() => {
|
|
35
|
+
R(!0), C.current.onAcceptStreamNotice?.(c);
|
|
36
|
+
}, []), q = d(() => {
|
|
37
37
|
T("notice-declined");
|
|
38
|
-
}, []),
|
|
39
|
-
accept:
|
|
40
|
-
decline:
|
|
41
|
-
}), [
|
|
38
|
+
}, []), J = p(() => ({
|
|
39
|
+
accept: K,
|
|
40
|
+
decline: q
|
|
41
|
+
}), [K, q]);
|
|
42
42
|
f(() => {
|
|
43
|
-
if (!
|
|
44
|
-
let t =
|
|
43
|
+
if (!G) return;
|
|
44
|
+
let t = n(V);
|
|
45
|
+
k(t.recognitionOwner === "transport" && t.wordsArrive === "after-utterance");
|
|
46
|
+
let r = e({
|
|
45
47
|
startCapture: o,
|
|
46
|
-
transport:
|
|
48
|
+
transport: t,
|
|
47
49
|
getSession: () => ({
|
|
48
50
|
phase: C.current.phase,
|
|
49
51
|
muted: C.current.muted
|
|
50
52
|
}),
|
|
51
53
|
getPlaybackSource: s,
|
|
52
|
-
getHeadsetHint: () =>
|
|
54
|
+
getHeadsetHint: () => I.current,
|
|
53
55
|
language: () => C.current.language,
|
|
54
56
|
onBargeIn: () => {
|
|
55
57
|
D(!1), C.current.onBargeIn();
|
|
@@ -60,24 +62,27 @@ function b(t) {
|
|
|
60
62
|
onSpeechFrame: (e) => C.current.onSpeechFrame?.(e),
|
|
61
63
|
onFallback: T,
|
|
62
64
|
onNothingHeard: () => D(!0),
|
|
65
|
+
onWordsPending: j,
|
|
63
66
|
isEnabled: () => C.current.enabled
|
|
64
|
-
}),
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
+
}), i = !1;
|
|
68
|
+
return r.start().then(() => {
|
|
69
|
+
i || F(!0);
|
|
67
70
|
}), navigator.mediaDevices?.enumerateDevices().then((e) => {
|
|
68
|
-
|
|
71
|
+
I.current = a(e.filter((e) => e.kind === "audiooutput").map((e) => e.label));
|
|
69
72
|
}).catch(() => void 0), () => {
|
|
70
|
-
|
|
73
|
+
i = !0, r.stop(), F(!1), k(!1), j(!1);
|
|
71
74
|
};
|
|
72
|
-
}, [
|
|
73
|
-
let
|
|
74
|
-
return r && !
|
|
75
|
-
mode:
|
|
76
|
-
transportKind:
|
|
77
|
-
suppressWebSpeech: r &&
|
|
75
|
+
}, [G, V]);
|
|
76
|
+
let Y = "off";
|
|
77
|
+
return r && !B.supported ? Y = "unavailable" : w === null ? W ? Y = "notice" : G && (Y = P ? "active" : "starting") : Y = "fallback", {
|
|
78
|
+
mode: Y,
|
|
79
|
+
transportKind: B.supported ? V : null,
|
|
80
|
+
suppressWebSpeech: r && B.supported && V !== "web-speech" && w === null && y(i),
|
|
78
81
|
fallbackReason: w,
|
|
79
82
|
nothingHeard: E,
|
|
80
|
-
privacyNotice:
|
|
83
|
+
privacyNotice: Y === "notice" ? J : null,
|
|
84
|
+
wordsAfterUtterance: O,
|
|
85
|
+
wordsPending: A
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
export { _ as HIDDEN_RELEASE_MS, b as useHandsFreeInterrupt };
|