@burdenoff/fe-libs 2026.1004.7 → 2026.1004.8
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/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/ui/useVoiceSession.js +96 -93
- package/dist/shared/assistant/voice/affirmations.d.ts +44 -0
- package/dist/shared/assistant/voice/affirmations.d.ts.map +1 -0
- package/dist/shared/assistant/voice/affirmations.js +238 -0
- package/dist/shared/assistant/voice/handsFree.d.ts +16 -3
- package/dist/shared/assistant/voice/handsFree.d.ts.map +1 -1
- package/dist/shared/assistant/voice/handsFree.js +43 -37
- package/dist/shared/assistant/voice/voiceSession.d.ts +2 -0
- package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/voice/voiceSession.js +3 -1
- package/dist/shared-assistant.js +200 -199
- package/package.json +1 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { WRITE_REPLY_LEXICON as e, classifyWriteReply as t } from "../writeReplyBinder.js";
|
|
2
|
+
//#region src/shared/assistant/voice/affirmations.ts
|
|
3
|
+
var n = [
|
|
4
|
+
"ok",
|
|
5
|
+
"okay",
|
|
6
|
+
"yes",
|
|
7
|
+
"yeah"
|
|
8
|
+
], r = {
|
|
9
|
+
hi: {
|
|
10
|
+
affirm: [
|
|
11
|
+
...n,
|
|
12
|
+
"हाँ",
|
|
13
|
+
"हां",
|
|
14
|
+
"हा",
|
|
15
|
+
"जी",
|
|
16
|
+
"जी हाँ",
|
|
17
|
+
"जी हां",
|
|
18
|
+
"हाँ जी",
|
|
19
|
+
"हां जी",
|
|
20
|
+
"ठीक",
|
|
21
|
+
"ठीक है",
|
|
22
|
+
"ठीक है जी",
|
|
23
|
+
"ओके",
|
|
24
|
+
"ओके जी",
|
|
25
|
+
"बिल्कुल",
|
|
26
|
+
"बिलकुल",
|
|
27
|
+
"ज़रूर",
|
|
28
|
+
"जरूर",
|
|
29
|
+
"कर दो",
|
|
30
|
+
"करो",
|
|
31
|
+
"कर दीजिए",
|
|
32
|
+
"कीजिए",
|
|
33
|
+
"आगे बढ़ो",
|
|
34
|
+
"आगे बढ़ें",
|
|
35
|
+
"चलो"
|
|
36
|
+
],
|
|
37
|
+
courtesy: [
|
|
38
|
+
"कृपया",
|
|
39
|
+
"प्लीज",
|
|
40
|
+
"धन्यवाद",
|
|
41
|
+
"शुक्रिया"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
ta: {
|
|
45
|
+
affirm: [
|
|
46
|
+
...n,
|
|
47
|
+
"ஆம்",
|
|
48
|
+
"ஆமாம்",
|
|
49
|
+
"ஆமா",
|
|
50
|
+
"சரி",
|
|
51
|
+
"சரிங்க",
|
|
52
|
+
"சரிங்கோ",
|
|
53
|
+
"ஓகே",
|
|
54
|
+
"ஒகே",
|
|
55
|
+
"செய்",
|
|
56
|
+
"செய்யுங்கள்",
|
|
57
|
+
"செய்யுங்க",
|
|
58
|
+
"தொடருங்கள்",
|
|
59
|
+
"தொடரவும்"
|
|
60
|
+
],
|
|
61
|
+
courtesy: ["தயவுசெய்து", "நன்றி"]
|
|
62
|
+
},
|
|
63
|
+
es: {
|
|
64
|
+
affirm: [
|
|
65
|
+
...n,
|
|
66
|
+
"sí",
|
|
67
|
+
"si",
|
|
68
|
+
"claro",
|
|
69
|
+
"claro que sí",
|
|
70
|
+
"claro que si",
|
|
71
|
+
"vale",
|
|
72
|
+
"dale",
|
|
73
|
+
"de acuerdo",
|
|
74
|
+
"está bien",
|
|
75
|
+
"esta bien",
|
|
76
|
+
"por supuesto",
|
|
77
|
+
"adelante",
|
|
78
|
+
"hazlo",
|
|
79
|
+
"házlo",
|
|
80
|
+
"continúa",
|
|
81
|
+
"continua",
|
|
82
|
+
"sigue",
|
|
83
|
+
"confirmo",
|
|
84
|
+
"bueno",
|
|
85
|
+
"perfecto",
|
|
86
|
+
"listo",
|
|
87
|
+
"seguro"
|
|
88
|
+
],
|
|
89
|
+
courtesy: ["por favor", "gracias"]
|
|
90
|
+
},
|
|
91
|
+
ar: {
|
|
92
|
+
affirm: [
|
|
93
|
+
...n,
|
|
94
|
+
"نعم",
|
|
95
|
+
"أجل",
|
|
96
|
+
"ايوه",
|
|
97
|
+
"أيوه",
|
|
98
|
+
"ايوا",
|
|
99
|
+
"أيوة",
|
|
100
|
+
"تمام",
|
|
101
|
+
"حسنا",
|
|
102
|
+
"حسناً",
|
|
103
|
+
"موافق",
|
|
104
|
+
"طيب",
|
|
105
|
+
"أكيد",
|
|
106
|
+
"بالتأكيد",
|
|
107
|
+
"أوكي",
|
|
108
|
+
"نفذ",
|
|
109
|
+
"نفذها",
|
|
110
|
+
"افعل",
|
|
111
|
+
"افعلها",
|
|
112
|
+
"تفضل",
|
|
113
|
+
"امض قدما",
|
|
114
|
+
"تابع",
|
|
115
|
+
"استمر",
|
|
116
|
+
"هيا"
|
|
117
|
+
],
|
|
118
|
+
courtesy: ["من فضلك", "شكرا"]
|
|
119
|
+
},
|
|
120
|
+
zh: {
|
|
121
|
+
affirm: [
|
|
122
|
+
...n,
|
|
123
|
+
"是",
|
|
124
|
+
"是的",
|
|
125
|
+
"对",
|
|
126
|
+
"对的",
|
|
127
|
+
"對",
|
|
128
|
+
"對的",
|
|
129
|
+
"好",
|
|
130
|
+
"好的",
|
|
131
|
+
"好吧",
|
|
132
|
+
"行",
|
|
133
|
+
"可以",
|
|
134
|
+
"嗯",
|
|
135
|
+
"没问题",
|
|
136
|
+
"沒問題",
|
|
137
|
+
"没错",
|
|
138
|
+
"確認",
|
|
139
|
+
"确认",
|
|
140
|
+
"继续",
|
|
141
|
+
"繼續",
|
|
142
|
+
"去吧",
|
|
143
|
+
"同意",
|
|
144
|
+
"当然",
|
|
145
|
+
"當然",
|
|
146
|
+
"当然可以",
|
|
147
|
+
"做吧",
|
|
148
|
+
"执行",
|
|
149
|
+
"執行",
|
|
150
|
+
"照做"
|
|
151
|
+
],
|
|
152
|
+
courtesy: [
|
|
153
|
+
"请",
|
|
154
|
+
"請",
|
|
155
|
+
"谢谢",
|
|
156
|
+
"謝謝",
|
|
157
|
+
"麻烦你",
|
|
158
|
+
"麻煩你"
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
function i(e) {
|
|
163
|
+
let t = e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu, " ").trim();
|
|
164
|
+
return t ? t.split(" ") : [];
|
|
165
|
+
}
|
|
166
|
+
var a = 6, o = (e) => e === "zh";
|
|
167
|
+
function s(e) {
|
|
168
|
+
let t = typeof e == "string" ? e.trim().toLowerCase().split(/[-_]/)[0] ?? "" : "";
|
|
169
|
+
switch (t) {
|
|
170
|
+
case "hi":
|
|
171
|
+
case "ta":
|
|
172
|
+
case "es":
|
|
173
|
+
case "ar":
|
|
174
|
+
case "zh": return t;
|
|
175
|
+
default: return "en";
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function c(e) {
|
|
179
|
+
return e.replace(/[ً-ٰٟ]/g, "").replace(/[أإآ]/g, "ا").replace(/ة/g, "ه");
|
|
180
|
+
}
|
|
181
|
+
function l(e, t) {
|
|
182
|
+
let n = e.normalize("NFKC"), r = i(t === "ar" ? c(n) : n);
|
|
183
|
+
return o(t) ? [...r.join("")] : r;
|
|
184
|
+
}
|
|
185
|
+
var u = /* @__PURE__ */ new Map();
|
|
186
|
+
function d(t) {
|
|
187
|
+
let n = u.get(t);
|
|
188
|
+
if (n) return n;
|
|
189
|
+
let i = t === "en" ? {
|
|
190
|
+
affirm: e.affirm,
|
|
191
|
+
courtesy: e.courtesy
|
|
192
|
+
} : r[t], a = (e) => e.map((e) => l(e, t)), o = a(i.affirm).filter((e) => e.length > 0), s = a(i.courtesy).filter((e) => e.length > 0), c = {
|
|
193
|
+
affirm: o,
|
|
194
|
+
courtesy: s,
|
|
195
|
+
tokens: new Set([...o, ...s].flat())
|
|
196
|
+
};
|
|
197
|
+
return u.set(t, c), c;
|
|
198
|
+
}
|
|
199
|
+
var f = (e, t, n) => t + n.length <= e.length && n.every((n, r) => e[t + r] === n);
|
|
200
|
+
function p(e, t) {
|
|
201
|
+
let n = /* @__PURE__ */ new Map(), r = (i, a) => {
|
|
202
|
+
if (i === e.length) return a;
|
|
203
|
+
let o = `${i}:${+!!a}`, s = n.get(o);
|
|
204
|
+
if (s !== void 0) return s;
|
|
205
|
+
let c = !1;
|
|
206
|
+
for (let n of t.affirm) if (f(e, i, n) && r(i + n.length, !0)) {
|
|
207
|
+
c = !0;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (!c) {
|
|
211
|
+
for (let n of t.courtesy) if (f(e, i, n) && r(i + n.length, a)) {
|
|
212
|
+
c = !0;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return n.set(o, c), c;
|
|
217
|
+
};
|
|
218
|
+
return r(0, !1);
|
|
219
|
+
}
|
|
220
|
+
function m(e, n) {
|
|
221
|
+
let r = s(n);
|
|
222
|
+
if (r === "en") return t(e, "en") === "affirm";
|
|
223
|
+
let i = l(e, r);
|
|
224
|
+
return i.length === 0 || i.length > a ? !1 : p(i, d(r));
|
|
225
|
+
}
|
|
226
|
+
function h(e, t, n = !1) {
|
|
227
|
+
let r = s(t), i = l(e, r);
|
|
228
|
+
if (i.length === 0) return !1;
|
|
229
|
+
let a = d(r).tokens, c = (e, t) => {
|
|
230
|
+
if (a.has(e)) return !0;
|
|
231
|
+
if (!n || !t || o(r)) return !1;
|
|
232
|
+
for (let t of a) if (t.startsWith(e)) return !0;
|
|
233
|
+
return !1;
|
|
234
|
+
};
|
|
235
|
+
return i.some((e, t) => !c(e, t === i.length - 1));
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { h as hasContentBeyondAffirmation, m as isBareAffirmation, s as resolveAffirmationLanguage };
|
|
@@ -93,6 +93,9 @@ export declare function speechWords(text: string): string[];
|
|
|
93
93
|
* - a phrase of two or more words that the turn already ENDS with is a
|
|
94
94
|
* repeat: dropped;
|
|
95
95
|
* - anything else is new speech: appended.
|
|
96
|
+
* A phrase with exactly the words already heard (compared by `speechWords`, so
|
|
97
|
+
* punctuation and case do not count) is the same speech: pending is returned
|
|
98
|
+
* unchanged, which is what keeps the end-of-speech grace from restarting.
|
|
96
99
|
* A single repeated word is kept unless it is the whole turn — "no no" is
|
|
97
100
|
* emphasis, but a lone "hello" arriving twice is the recogniser.
|
|
98
101
|
*/
|
|
@@ -142,9 +145,9 @@ export type ThinkingSpeechPlan = {
|
|
|
142
145
|
* Classify a result that arrives while the assistant is PREPARING an answer.
|
|
143
146
|
*
|
|
144
147
|
* Ignored: nothing; the recogniser finishing, repeating or revising the turn
|
|
145
|
-
* just submitted; noise; and a bare affirmation
|
|
146
|
-
*
|
|
147
|
-
* a correction.
|
|
148
|
+
* just submitted; noise; and a bare affirmation, or the beginning of one, in
|
|
149
|
+
* the language being spoken (a spoken "yes" is never a correction, and never
|
|
150
|
+
* commits a write — see the header). Everything else is a correction.
|
|
148
151
|
*
|
|
149
152
|
* Echo is not checked here: nothing plays during `thinking`. The caller still
|
|
150
153
|
* passes the previous reply through `isEcho` first, because its tail can sound
|
|
@@ -156,5 +159,15 @@ export declare function planThinkingSpeech(input: {
|
|
|
156
159
|
submitted: string;
|
|
157
160
|
/** Milliseconds since it was sent, or null when no clock was given. */
|
|
158
161
|
sinceSubmitMs: number | null;
|
|
162
|
+
/**
|
|
163
|
+
* The language being SPOKEN (the recogniser's, e.g. "hi-IN"). A bare yes is
|
|
164
|
+
* recognised in en, hi, ta, es, ar and zh; absent or unknown is English.
|
|
165
|
+
*/
|
|
166
|
+
language?: string | null;
|
|
167
|
+
/**
|
|
168
|
+
* Is this a committed result (true, and the default) or a live guess? A
|
|
169
|
+
* guess is revised word by word: "ok", then "ok go", then "ok go ahead".
|
|
170
|
+
*/
|
|
171
|
+
final?: boolean;
|
|
159
172
|
}): ThinkingSpeechPlan;
|
|
160
173
|
//# sourceMappingURL=handsFree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handsFree.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/handsFree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,6BAA8B,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAAmB,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAEhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAIpC;AAMD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMlD;AA6BD
|
|
1
|
+
{"version":3,"file":"handsFree.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/handsFree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,6BAA8B,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC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E,GAC1E;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,kBAAkB,CAiBrB"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasContentBeyondAffirmation as e, isBareAffirmation as t } from "./affirmations.js";
|
|
2
2
|
//#region src/shared/assistant/voice/handsFree.ts
|
|
3
|
-
var
|
|
3
|
+
var n = [
|
|
4
4
|
2e3,
|
|
5
5
|
3e3,
|
|
6
6
|
5e3
|
|
7
|
-
],
|
|
8
|
-
function r(e) {
|
|
9
|
-
return t.find((t) => t === e) ?? 2e3;
|
|
10
|
-
}
|
|
7
|
+
], r = 2e3;
|
|
11
8
|
function i(e) {
|
|
12
|
-
|
|
9
|
+
return n.find((t) => t === e) ?? 2e3;
|
|
10
|
+
}
|
|
11
|
+
function a(e) {
|
|
12
|
+
let t = i(e.graceMs);
|
|
13
13
|
return {
|
|
14
14
|
arm: e.phase === "listening" && !e.muted && !e.holding && e.spoken.trim().length > 0,
|
|
15
15
|
delayMs: t
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function o(e) {
|
|
19
19
|
let t = e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu, " ").trim();
|
|
20
20
|
return t ? t.split(" ") : [];
|
|
21
21
|
}
|
|
22
|
-
var
|
|
22
|
+
var s = (e, t) => t.length <= e.length && t.every((t, n) => e[n] === t), c = (e, t) => t.length <= e.length && t.every((n, r) => e[e.length - t.length + r] === n), l = (e, t) => {
|
|
23
23
|
if (t.length === 0) return !0;
|
|
24
24
|
for (let n = 0; n + t.length <= e.length; n += 1) if (t.every((t, r) => e[n + r] === t)) return !0;
|
|
25
25
|
return !1;
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function u(e, t) {
|
|
28
28
|
let n = Array(t.length + 1).fill(0);
|
|
29
29
|
for (let r of e) {
|
|
30
30
|
let e = Array(t.length + 1).fill(0);
|
|
@@ -33,29 +33,29 @@ function l(e, t) {
|
|
|
33
33
|
}
|
|
34
34
|
return n[t.length] ?? 0;
|
|
35
35
|
}
|
|
36
|
-
function u(e, t) {
|
|
37
|
-
let n = a(e), r = a(t);
|
|
38
|
-
return r.length === 0 ? e : n.length === 0 || o(r, n) ? t.replace(/\s+/g, " ").trim() : r.length >= 2 && s(n, r) ? e : `${e} ${t}`.replace(/\s+/g, " ").trim();
|
|
39
|
-
}
|
|
40
36
|
function d(e, t) {
|
|
41
|
-
let n =
|
|
37
|
+
let n = o(e), r = o(t);
|
|
38
|
+
return r.length === 0 ? e : n.length === 0 ? t.replace(/\s+/g, " ").trim() : r.length === n.length && s(r, n) ? e : s(r, n) ? t.replace(/\s+/g, " ").trim() : r.length >= 2 && c(n, r) ? e : `${e} ${t}`.replace(/\s+/g, " ").trim();
|
|
39
|
+
}
|
|
40
|
+
function f(e, t) {
|
|
41
|
+
let n = o(t);
|
|
42
42
|
if (n.length === 0) return e.replace(/\s+/g, " ").trim();
|
|
43
43
|
let r = e.split(/\s+/).filter(Boolean), i = 0;
|
|
44
44
|
for (let t = 0; t < r.length; t += 1) {
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
if (
|
|
45
|
+
let a = o(r[t] ?? "");
|
|
46
|
+
if (a.length !== 0) for (let o of a) {
|
|
47
|
+
if (o !== n[i]) return e.replace(/\s+/g, " ").trim();
|
|
48
48
|
if (i += 1, i === n.length) return r.slice(t + 1).join(" ").trim();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
return e.replace(/\s+/g, " ").trim();
|
|
52
52
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
55
|
-
let r =
|
|
56
|
-
return r.length === 0 ? !0 : i.length === 0 ? !1 : r.length === i.length && r.every((e, t) => e === i[t]) ? !0 : n === null || n >= 1500 ? !1 :
|
|
53
|
+
var p = 1500, m = .6;
|
|
54
|
+
function h(e, t, n) {
|
|
55
|
+
let r = o(e), i = o(t);
|
|
56
|
+
return r.length === 0 ? !0 : i.length === 0 ? !1 : r.length === i.length && r.every((e, t) => e === i[t]) ? !0 : n === null || n >= 1500 ? !1 : l(i, r) ? !0 : s(r, i) && r.length - i.length >= 2 ? !1 : u(r, i) / Math.max(r.length, i.length) >= m;
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var g = new Set([
|
|
59
59
|
"uh",
|
|
60
60
|
"um",
|
|
61
61
|
"uhm",
|
|
@@ -72,33 +72,39 @@ var h = new Set([
|
|
|
72
72
|
"mhm",
|
|
73
73
|
"huh",
|
|
74
74
|
"oh"
|
|
75
|
-
]),
|
|
76
|
-
function
|
|
77
|
-
let t =
|
|
78
|
-
if (t.length === 0 || t.every((e) =>
|
|
75
|
+
]), _ = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
76
|
+
function v(e) {
|
|
77
|
+
let t = o(e);
|
|
78
|
+
if (t.length === 0 || t.every((e) => g.has(e))) return !1;
|
|
79
79
|
let n = [...t.join("")];
|
|
80
|
-
return n.length >= 2 ? !0 : n.length === 1 &&
|
|
80
|
+
return n.length >= 2 ? !0 : n.length === 1 && _.test(n[0] ?? "");
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
if (
|
|
82
|
+
function y(n) {
|
|
83
|
+
if (o(n.transcript).length === 0) return {
|
|
84
84
|
kind: "ignore",
|
|
85
85
|
reason: "empty"
|
|
86
86
|
};
|
|
87
|
-
if (
|
|
87
|
+
if (h(n.transcript, n.submitted, n.sinceSubmitMs)) return {
|
|
88
88
|
kind: "ignore",
|
|
89
89
|
reason: "trailing"
|
|
90
90
|
};
|
|
91
|
-
let
|
|
92
|
-
|
|
91
|
+
let r = f(n.transcript, n.submitted);
|
|
92
|
+
if (!v(r)) return {
|
|
93
|
+
kind: "ignore",
|
|
94
|
+
reason: "noise"
|
|
95
|
+
};
|
|
96
|
+
if (t(r, n.language)) return {
|
|
93
97
|
kind: "ignore",
|
|
94
98
|
reason: "affirmation"
|
|
95
|
-
}
|
|
99
|
+
};
|
|
100
|
+
let i = n.final === !1;
|
|
101
|
+
return e(r, n.language, i) ? {
|
|
96
102
|
kind: "supersede",
|
|
97
|
-
text:
|
|
103
|
+
text: r
|
|
98
104
|
} : {
|
|
99
105
|
kind: "ignore",
|
|
100
|
-
reason: "
|
|
106
|
+
reason: "affirmation"
|
|
101
107
|
};
|
|
102
108
|
}
|
|
103
109
|
//#endregion
|
|
104
|
-
export {
|
|
110
|
+
export { r as DEFAULT_VOICE_GRACE_MS, p as TRAILING_RESULT_WINDOW_MS, n as VOICE_GRACE_CHOICES_MS, v as isGenuineUserSpeech, h as isTrailingResultOfSubmitted, d as mergeFinalPhrase, a as planSubmitTimer, y as planThinkingSpeech, i as resolveVoiceGraceMs, o as speechWords, f as stripSubmittedPrefix };
|
|
@@ -87,6 +87,8 @@ export type VoiceSessionEvent =
|
|
|
87
87
|
final: boolean;
|
|
88
88
|
/** Wall-clock ms when it was heard — what the H2 trailing-result window is measured with. */
|
|
89
89
|
at?: number;
|
|
90
|
+
/** BOFF-8613: the language being spoken, so a bare "yes" is read in it. */
|
|
91
|
+
language?: string;
|
|
90
92
|
}
|
|
91
93
|
/** Nothing heard for the person's grace (`resolveVoiceGraceMs`). */
|
|
92
94
|
| {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voiceSession.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/voiceSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEzF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,iBAAiB,CAAC;IACzB,8DAA8D;IAC9D,KAAK,EAAE,OAAO,CAAC;IACf,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAChC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,YAAY,CAAC;AAExF,MAAM,MAAM,iBAAiB;AAC3B,uEAAuE;AACrE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,6FAA6F;IAC7F,EAAE,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"voiceSession.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/voiceSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEz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E,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAKtC;AAED,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,oBAAoB,CAUzD,CAAC;AA4CH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,oBAAoB,EAC9B,KAAK,EAAE,iBAAiB,EACxB,UAAU,GAAE,MAAM,GAAG,IAAW,GAC/B,oBAAoB,CA6ItB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAUhG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,IAAI,EAAE,OAAO,CAAC;IACd,8EAA8E;IAC9E,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAY1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAKnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAGvE;AAED,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAatG"}
|
|
@@ -64,7 +64,9 @@ function _(e, n, r) {
|
|
|
64
64
|
let i = t({
|
|
65
65
|
transcript: n.transcript,
|
|
66
66
|
submitted: e.submitted,
|
|
67
|
-
sinceSubmitMs: n.at !== void 0 && e.submittedAt !== null ? n.at - e.submittedAt : null
|
|
67
|
+
sinceSubmitMs: n.at !== void 0 && e.submittedAt !== null ? n.at - e.submittedAt : null,
|
|
68
|
+
language: n.language,
|
|
69
|
+
final: n.final
|
|
68
70
|
});
|
|
69
71
|
if (i.kind === "ignore") return e;
|
|
70
72
|
let a = i.text.replace(/\s+/g, " ").trim();
|