tz-voice-chat 1.2.0 → 1.3.0
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/LICENSE +21 -0
- package/README.md +73 -13
- package/bin/tz-voice-chat.js +12 -1
- package/dist/assets/llmWorker-CmV-b4uq.js +1 -0
- package/dist/assets/whisperWorker-rOnua0b5.js +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1109 -831
- package/dist/style.css +1 -1
- package/dist-app/assets/{index-BDMCgrF_.css → index-Bcmhe9G_.css} +1 -1
- package/dist-app/assets/index-KxBxd4q9.js +41 -0
- package/dist-app/assets/llmWorker-CmV-b4uq.js +1 -0
- package/dist-app/assets/whisperWorker-rOnua0b5.js +1 -0
- package/dist-app/index.html +2 -2
- package/package.json +1 -1
- package/server/index.js +25 -0
- package/server/openai-tts.js +39 -0
- package/server/run.js +17 -3
- package/shared/settingsSchema.js +16 -0
- package/dist/assets/llmWorker-CVEGn6yI.js +0 -1
- package/dist/assets/whisperWorker-D69IwlqW.js +0 -1
- package/dist-app/assets/index-CFWv17S2.js +0 -41
- package/dist-app/assets/llmWorker-CVEGn6yI.js +0 -1
- package/dist-app/assets/whisperWorker-D69IwlqW.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsx as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
let e = "",
|
|
6
|
-
function
|
|
7
|
-
n.push(
|
|
1
|
+
import { useState as N, useRef as U, useEffect as j, useMemo as st, useCallback as Ee, Component as ot } from "react";
|
|
2
|
+
import { jsx as d, jsxs as _, Fragment as Ce } from "react/jsx-runtime";
|
|
3
|
+
const xe = 60, Se = 200;
|
|
4
|
+
function Ve() {
|
|
5
|
+
let e = "", s = !0;
|
|
6
|
+
function o(n, r, t) {
|
|
7
|
+
n.push(r), e = t, s = !1;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function a() {
|
|
10
10
|
const n = [];
|
|
11
11
|
for (; ; ) {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
12
|
+
const r = /([.!?]{1,3})(\s|$)/.exec(e);
|
|
13
|
+
if (r) {
|
|
14
|
+
const t = e.slice(0, r.index + r[0].length).trim();
|
|
15
|
+
if (t.length >= 10) {
|
|
16
|
+
o(n, t, e.slice(r.index + r[0].length));
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
20
|
+
if (s) {
|
|
21
21
|
if (e.length >= 25) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
|
|
22
|
+
const t = /[,;:—–](\s|$)/.exec(e);
|
|
23
|
+
if (t) {
|
|
24
|
+
const i = e.slice(0, t.index + t[0].length).trim();
|
|
25
|
+
if (i.length >= 20) {
|
|
26
|
+
o(n, i, e.slice(t.index + t[0].length));
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
if (e.length >=
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
if (e.length >= xe) {
|
|
32
|
+
const t = e.lastIndexOf(" ", xe - 1), i = t > 10 ? t : xe;
|
|
33
|
+
o(n, e.slice(0, i).trim(), e.slice(i).trimStart());
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
} else if (e.length >=
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
} else if (e.length >= Se) {
|
|
37
|
+
const t = e.slice(0, Se), i = Math.max(t.lastIndexOf(", "), t.lastIndexOf("; "), t.lastIndexOf(": ")), c = i > Se / 2 ? i + 1 : t.lastIndexOf(" ") > 10 ? t.lastIndexOf(" ") : Se;
|
|
38
|
+
o(n, e.slice(0, c).trim(), e.slice(c).trimStart());
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
break;
|
|
@@ -44,7 +44,7 @@ function Pe() {
|
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
46
|
write(n) {
|
|
47
|
-
return e += n,
|
|
47
|
+
return e += n, a();
|
|
48
48
|
},
|
|
49
49
|
flush() {
|
|
50
50
|
const n = e.trim();
|
|
@@ -52,209 +52,315 @@ function Pe() {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const rt = /\.(onnx|onnx_data|safetensors|bin|ort)$/i;
|
|
56
|
+
function Ke(e, { minBytes: s = 1e6, cap: o = 0.99 } = {}) {
|
|
57
|
+
const a = /* @__PURE__ */ new Map(), n = (t, i) => i >= s && (rt.test(t) || i >= 5e6);
|
|
58
|
+
let r = 0;
|
|
59
|
+
return (t = {}) => {
|
|
60
|
+
const i = t.file || t.name;
|
|
61
|
+
if (i && n(i, t.total)) {
|
|
62
|
+
const m = t.status === "done" ? t.total : t.loaded ?? (typeof t.progress == "number" ? t.total * t.progress / 100 : 0), v = a.get(i);
|
|
63
|
+
a.set(i, { loaded: Math.max((v == null ? void 0 : v.loaded) ?? 0, m), total: t.total });
|
|
64
|
+
} else if (i && t.status === "done" && a.has(i)) {
|
|
65
|
+
const m = a.get(i);
|
|
66
|
+
m.loaded = m.total;
|
|
67
|
+
}
|
|
68
|
+
let c = 0, p = 0;
|
|
69
|
+
for (const m of a.values())
|
|
70
|
+
c += m.loaded, p += m.total;
|
|
71
|
+
if (p <= 0) return;
|
|
72
|
+
const u = Math.min(o, c / p);
|
|
73
|
+
u > r && (r = u, e(r));
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const at = "tz-voice-chat-model-cache", it = 4 * 1024 * 1024;
|
|
77
|
+
let ze = null;
|
|
78
|
+
function ct() {
|
|
79
|
+
return ze || (ze = new Promise((e, s) => {
|
|
80
|
+
const o = indexedDB.open(at, 1);
|
|
81
|
+
o.onupgradeneeded = () => {
|
|
82
|
+
o.result.createObjectStore("meta"), o.result.createObjectStore("chunks");
|
|
83
|
+
}, o.onsuccess = () => e(o.result), o.onerror = () => s(o.error);
|
|
84
|
+
})), ze;
|
|
85
|
+
}
|
|
86
|
+
async function me(e, s, o) {
|
|
87
|
+
const a = await ct();
|
|
88
|
+
return new Promise((n, r) => {
|
|
89
|
+
const t = a.transaction(e, s), i = o(t.objectStore(e));
|
|
90
|
+
t.oncomplete = () => n(i == null ? void 0 : i.result), t.onerror = t.onabort = () => r(t.error);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const Be = (e) => typeof e == "string" ? e : e.url, $e = (e, s) => `${e}\0${s}`;
|
|
94
|
+
async function qe(e) {
|
|
95
|
+
const s = await me("meta", "readonly", (o) => o.get(e));
|
|
96
|
+
if (s) for (let o = 0; o < s.chunks; o++) await me("chunks", "readwrite", (a) => a.delete($e(e, o)));
|
|
97
|
+
await me("meta", "readwrite", (o) => o.delete(e));
|
|
98
|
+
}
|
|
99
|
+
function lt() {
|
|
100
|
+
return {
|
|
101
|
+
/** @returns {Promise<Response | undefined>} */
|
|
102
|
+
async match(e) {
|
|
103
|
+
try {
|
|
104
|
+
const s = Be(e), o = await me("meta", "readonly", (r) => r.get(s));
|
|
105
|
+
if (!o || !o.complete) return;
|
|
106
|
+
let a = 0;
|
|
107
|
+
const n = new ReadableStream({
|
|
108
|
+
async pull(r) {
|
|
109
|
+
if (a >= o.chunks) {
|
|
110
|
+
r.close();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const t = await me("chunks", "readonly", (i) => i.get($e(s, a)));
|
|
114
|
+
if (!t) {
|
|
115
|
+
r.error(new Error("model cache entry is incomplete"));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
r.enqueue(new Uint8Array(t)), a++;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return new Response(n, { status: 200, headers: new Headers(o.headers) });
|
|
122
|
+
} catch (s) {
|
|
123
|
+
console.warn("[tz-voice-chat] model cache read failed:", s);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
async put(e, s) {
|
|
128
|
+
const o = Be(e);
|
|
129
|
+
try {
|
|
130
|
+
await qe(o);
|
|
131
|
+
const a = s.body.getReader();
|
|
132
|
+
let n = [], r = 0, t = 0, i = 0;
|
|
133
|
+
const c = async (u) => {
|
|
134
|
+
if (!r || !u && r < it) return;
|
|
135
|
+
const m = new Uint8Array(r);
|
|
136
|
+
let v = 0;
|
|
137
|
+
for (const h of n)
|
|
138
|
+
m.set(h, v), v += h.length;
|
|
139
|
+
n = [], r = 0, await me("chunks", "readwrite", (h) => h.put(m.buffer, $e(o, t))), t++;
|
|
140
|
+
};
|
|
141
|
+
for (; ; ) {
|
|
142
|
+
const { done: u, value: m } = await a.read();
|
|
143
|
+
if (u) break;
|
|
144
|
+
n.push(m), r += m.length, i += m.length, await c(!1);
|
|
145
|
+
}
|
|
146
|
+
await c(!0);
|
|
147
|
+
const p = [];
|
|
148
|
+
s.headers.forEach((u, m) => {
|
|
149
|
+
m !== "content-encoding" && m !== "content-length" && p.push([m, u]);
|
|
150
|
+
}), p.push(["content-length", String(i)]), await me("meta", "readwrite", (u) => u.put({ complete: !0, chunks: t, size: i, headers: p }, o));
|
|
151
|
+
} catch (a) {
|
|
152
|
+
console.warn("[tz-voice-chat] could not cache a model file (continuing without):", a);
|
|
153
|
+
try {
|
|
154
|
+
await qe(o);
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function dt(e) {
|
|
162
|
+
return typeof caches < "u" || typeof indexedDB > "u" ? !1 : (e.useBrowserCache = !1, e.useCustomCache = !0, e.customCache = lt(), !0);
|
|
163
|
+
}
|
|
164
|
+
async function ut(e, {
|
|
165
|
+
dtype: s = "q8",
|
|
166
|
+
device: o = "cpu",
|
|
167
|
+
modelProxyUrl: a = "/api/models/"
|
|
59
168
|
} = {}) {
|
|
60
|
-
var
|
|
169
|
+
var m, v;
|
|
61
170
|
const { env: n } = await import(
|
|
62
171
|
/* @vite-ignore */
|
|
63
172
|
"/vendor/transformers/transformers.min.js"
|
|
64
173
|
);
|
|
65
|
-
n.remoteHost =
|
|
66
|
-
const
|
|
174
|
+
n.remoteHost = a, dt(n), (v = (m = n == null ? void 0 : n.backends) == null ? void 0 : m.onnx) != null && v.wasm && (n.backends.onnx.wasm.wasmPaths = "/vendor/transformers/"), n != null && n.onnx && (n.onnx.logSeverityLevel = 3);
|
|
175
|
+
const r = await import(
|
|
67
176
|
/* @vite-ignore */
|
|
68
177
|
"/vendor/kokoro/kokoro.web.js"
|
|
69
|
-
), { KokoroTTS:
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
dtype: A,
|
|
79
|
-
device: w,
|
|
80
|
-
progress_callback: p
|
|
178
|
+
), { KokoroTTS: t } = r;
|
|
179
|
+
let i = s;
|
|
180
|
+
o === "webgpu" && (s === "q4" || s === "q8") && (console.warn(`[modelLoader] dtype "${s}" not supported on WebGPU — using "fp32".`), i = "fp32");
|
|
181
|
+
let c = Ke((h) => e == null ? void 0 : e("kokoro", h));
|
|
182
|
+
async function p(h, w) {
|
|
183
|
+
return t.from_pretrained("onnx-community/Kokoro-82M-ONNX", {
|
|
184
|
+
dtype: w,
|
|
185
|
+
device: h,
|
|
186
|
+
progress_callback: c
|
|
81
187
|
});
|
|
82
188
|
}
|
|
83
|
-
let
|
|
189
|
+
let u;
|
|
84
190
|
try {
|
|
85
|
-
|
|
86
|
-
} catch (
|
|
87
|
-
if (
|
|
88
|
-
console.warn(`[modelLoader] Kokoro on "${
|
|
191
|
+
u = await p(o, i);
|
|
192
|
+
} catch (h) {
|
|
193
|
+
if (o !== "wasm")
|
|
194
|
+
console.warn(`[modelLoader] Kokoro on "${o}" failed (${h == null ? void 0 : h.message}) — falling back to WASM.`), c = Ke((w) => e == null ? void 0 : e("kokoro", w)), u = await p("wasm", s);
|
|
89
195
|
else
|
|
90
|
-
throw
|
|
196
|
+
throw h;
|
|
91
197
|
}
|
|
92
|
-
return e == null || e("kokoro", 1), { kokoro:
|
|
198
|
+
return e == null || e("kokoro", 1), { kokoro: u };
|
|
93
199
|
}
|
|
94
|
-
function
|
|
95
|
-
const { numberOfChannels: n, length:
|
|
96
|
-
let
|
|
200
|
+
function Pe(e, s, { threshold: o = 0.01, padMs: a = 25 } = {}) {
|
|
201
|
+
const { numberOfChannels: n, length: r, sampleRate: t } = s;
|
|
202
|
+
let i = r, c = -1;
|
|
97
203
|
for (let h = 0; h < n; h++) {
|
|
98
|
-
const w =
|
|
99
|
-
for (let
|
|
100
|
-
if (Math.abs(w[
|
|
101
|
-
|
|
204
|
+
const w = s.getChannelData(h);
|
|
205
|
+
for (let S = 0; S < r; S++)
|
|
206
|
+
if (Math.abs(w[S]) > o) {
|
|
207
|
+
S < i && (i = S);
|
|
102
208
|
break;
|
|
103
209
|
}
|
|
104
|
-
for (let
|
|
105
|
-
if (Math.abs(w[
|
|
106
|
-
|
|
210
|
+
for (let S = r - 1; S >= 0; S--)
|
|
211
|
+
if (Math.abs(w[S]) > o) {
|
|
212
|
+
S > c && (c = S);
|
|
107
213
|
break;
|
|
108
214
|
}
|
|
109
215
|
}
|
|
110
|
-
if (
|
|
111
|
-
const p = Math.round(
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
216
|
+
if (c < i) return s;
|
|
217
|
+
const p = Math.round(a / 1e3 * t), u = Math.max(0, i - p), m = Math.min(r, c + 1 + p);
|
|
218
|
+
if (u === 0 && m === r) return s;
|
|
219
|
+
const v = e.createBuffer(n, m - u, t);
|
|
114
220
|
for (let h = 0; h < n; h++)
|
|
115
|
-
|
|
116
|
-
return
|
|
221
|
+
v.copyToChannel(s.getChannelData(h).subarray(u, m), h);
|
|
222
|
+
return v;
|
|
117
223
|
}
|
|
118
|
-
function
|
|
119
|
-
const n = new AudioContext(),
|
|
120
|
-
let
|
|
121
|
-
async function p(
|
|
122
|
-
if (
|
|
123
|
-
const h = (
|
|
124
|
-
if (h instanceof ArrayBuffer) return
|
|
224
|
+
function ht(e, { voice: s = "af_bella", speed: o = 1, onPlayStart: a } = {}) {
|
|
225
|
+
const n = new AudioContext(), r = [];
|
|
226
|
+
let t = !1, i = null, c = !1;
|
|
227
|
+
async function p(v) {
|
|
228
|
+
if (v instanceof AudioBuffer) return Pe(n, v);
|
|
229
|
+
const h = (v == null ? void 0 : v.audio) ?? v;
|
|
230
|
+
if (h instanceof ArrayBuffer) return Pe(n, await n.decodeAudioData(h.slice(0)));
|
|
125
231
|
if (h instanceof Float32Array) {
|
|
126
|
-
const w = (
|
|
127
|
-
return
|
|
232
|
+
const w = (v == null ? void 0 : v.samplingRate) ?? 24e3, S = n.createBuffer(1, h.length, w);
|
|
233
|
+
return S.copyToChannel(h, 0), Pe(n, S);
|
|
128
234
|
}
|
|
129
235
|
throw new Error("Unsupported TTS payload");
|
|
130
236
|
}
|
|
131
|
-
async function
|
|
237
|
+
async function u(v) {
|
|
132
238
|
await n.resume();
|
|
133
239
|
const h = n.createBufferSource();
|
|
134
|
-
return h.buffer =
|
|
240
|
+
return h.buffer = v, h.connect(n.destination), new Promise((w) => {
|
|
135
241
|
h.onended = () => {
|
|
136
|
-
|
|
137
|
-
},
|
|
242
|
+
i === h && (i = null), w();
|
|
243
|
+
}, i = h, h.start(), c || (c = !0, a == null || a());
|
|
138
244
|
});
|
|
139
245
|
}
|
|
140
|
-
async function
|
|
141
|
-
if (!
|
|
142
|
-
for (
|
|
143
|
-
const
|
|
246
|
+
async function m() {
|
|
247
|
+
if (!t) {
|
|
248
|
+
for (t = !0; r.length > 0; ) {
|
|
249
|
+
const v = r.shift();
|
|
144
250
|
try {
|
|
145
|
-
const h = await
|
|
146
|
-
h && await
|
|
251
|
+
const h = await v;
|
|
252
|
+
h && await u(h);
|
|
147
253
|
} catch (h) {
|
|
148
254
|
console.error("[TtsQueue]", h);
|
|
149
255
|
}
|
|
150
256
|
}
|
|
151
|
-
|
|
257
|
+
t = !1;
|
|
152
258
|
}
|
|
153
259
|
}
|
|
154
260
|
return {
|
|
155
|
-
enqueue(
|
|
156
|
-
|
|
261
|
+
enqueue(v) {
|
|
262
|
+
r.push(e.generate(v, { voice: s, speed: o }).then(p)), m();
|
|
157
263
|
},
|
|
158
264
|
cancel() {
|
|
159
|
-
if (
|
|
265
|
+
if (r.length = 0, c = !1, i) {
|
|
160
266
|
try {
|
|
161
|
-
|
|
267
|
+
i.stop();
|
|
162
268
|
} catch {
|
|
163
269
|
}
|
|
164
|
-
|
|
270
|
+
i = null;
|
|
165
271
|
}
|
|
166
272
|
},
|
|
167
273
|
async finished() {
|
|
168
|
-
for (;
|
|
274
|
+
for (; t || r.length > 0; ) await new Promise((v) => setTimeout(v, 200));
|
|
169
275
|
}
|
|
170
276
|
};
|
|
171
277
|
}
|
|
172
|
-
function
|
|
173
|
-
const
|
|
174
|
-
let
|
|
175
|
-
async function
|
|
176
|
-
const
|
|
177
|
-
e && (
|
|
178
|
-
const
|
|
278
|
+
function pt({ voice: e = "", speed: s = 1, onPlayStart: o, onError: a, url: n = "/api/tts" } = {}) {
|
|
279
|
+
const r = new AudioContext(), t = [];
|
|
280
|
+
let i = !1, c = null, p = !1;
|
|
281
|
+
async function u(h) {
|
|
282
|
+
const w = { text: h };
|
|
283
|
+
e && (w.voice = e), s !== 1 && (w.speed = s);
|
|
284
|
+
const S = await fetch(n, {
|
|
179
285
|
method: "POST",
|
|
180
286
|
headers: { "Content-Type": "application/json" },
|
|
181
|
-
body: JSON.stringify(
|
|
287
|
+
body: JSON.stringify(w)
|
|
182
288
|
});
|
|
183
|
-
if (!
|
|
184
|
-
return
|
|
289
|
+
if (!S.ok) throw new Error(`TTS ${S.status}: ${await S.text()}`);
|
|
290
|
+
return Pe(r, await r.decodeAudioData(await S.arrayBuffer()));
|
|
185
291
|
}
|
|
186
|
-
async function
|
|
187
|
-
await
|
|
188
|
-
const
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
292
|
+
async function m(h) {
|
|
293
|
+
await r.resume();
|
|
294
|
+
const w = r.createBufferSource();
|
|
295
|
+
return w.buffer = h, w.connect(r.destination), new Promise((S) => {
|
|
296
|
+
w.onended = () => {
|
|
297
|
+
c === w && (c = null), S();
|
|
298
|
+
}, c = w, w.start(), p || (p = !0, o == null || o());
|
|
193
299
|
});
|
|
194
300
|
}
|
|
195
|
-
async function
|
|
196
|
-
if (!
|
|
197
|
-
for (
|
|
198
|
-
const
|
|
301
|
+
async function v() {
|
|
302
|
+
if (!i) {
|
|
303
|
+
for (i = !0; t.length > 0; ) {
|
|
304
|
+
const h = t.shift();
|
|
199
305
|
try {
|
|
200
|
-
await
|
|
201
|
-
} catch (
|
|
202
|
-
console.error("[ServerTTS]",
|
|
306
|
+
await m(await h);
|
|
307
|
+
} catch (w) {
|
|
308
|
+
console.error("[ServerTTS]", w), a == null || a((w == null ? void 0 : w.message) || "Text-to-speech failed.");
|
|
203
309
|
}
|
|
204
310
|
}
|
|
205
|
-
|
|
311
|
+
i = !1;
|
|
206
312
|
}
|
|
207
313
|
}
|
|
208
314
|
return {
|
|
209
|
-
enqueue(
|
|
210
|
-
|
|
315
|
+
enqueue(h) {
|
|
316
|
+
h != null && h.trim() && (t.push(u(h)), v());
|
|
211
317
|
},
|
|
212
318
|
cancel() {
|
|
213
|
-
if (
|
|
319
|
+
if (t.length = 0, c) {
|
|
214
320
|
try {
|
|
215
|
-
|
|
321
|
+
c.stop();
|
|
216
322
|
} catch {
|
|
217
323
|
}
|
|
218
|
-
|
|
324
|
+
c = null;
|
|
219
325
|
}
|
|
220
|
-
|
|
326
|
+
p = !1;
|
|
221
327
|
},
|
|
222
328
|
async finished() {
|
|
223
|
-
for (;
|
|
329
|
+
for (; i || t.length > 0; ) await new Promise((h) => setTimeout(h, 100));
|
|
224
330
|
}
|
|
225
331
|
};
|
|
226
332
|
}
|
|
227
|
-
function
|
|
333
|
+
function ft({ voice: e = "", rate: s = 1, pitch: o = 1, onPlayStart: a } = {}) {
|
|
228
334
|
const n = [];
|
|
229
|
-
let
|
|
230
|
-
function l() {
|
|
231
|
-
return e ? speechSynthesis.getVoices().find((d) => d.name === e || d.voiceURI === e) ?? null : null;
|
|
232
|
-
}
|
|
335
|
+
let r = !1, t = !1;
|
|
233
336
|
function i() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
337
|
+
return e ? speechSynthesis.getVoices().find((u) => u.name === e || u.voiceURI === e) ?? null : null;
|
|
338
|
+
}
|
|
339
|
+
function c() {
|
|
340
|
+
if (r || n.length === 0) return;
|
|
341
|
+
r = !0;
|
|
342
|
+
const p = n.shift(), u = new SpeechSynthesisUtterance(p), m = i();
|
|
343
|
+
m && (u.voice = m), u.rate = s, u.pitch = o, u.onstart = () => {
|
|
344
|
+
t || (t = !0, a == null || a());
|
|
345
|
+
}, u.onend = () => {
|
|
346
|
+
r = !1, c();
|
|
347
|
+
}, u.onerror = (v) => {
|
|
348
|
+
console.error("[WebSpeech TTS] error", v.error), r = !1, c();
|
|
349
|
+
}, speechSynthesis.speak(u);
|
|
244
350
|
}
|
|
245
351
|
return {
|
|
246
352
|
enqueue(p) {
|
|
247
|
-
p != null && p.trim() && (n.push(p),
|
|
353
|
+
p != null && p.trim() && (n.push(p), c());
|
|
248
354
|
},
|
|
249
355
|
cancel() {
|
|
250
|
-
n.length = 0, speechSynthesis.cancel(),
|
|
356
|
+
n.length = 0, speechSynthesis.cancel(), r = !1, t = !1;
|
|
251
357
|
},
|
|
252
358
|
async finished() {
|
|
253
|
-
for (;
|
|
359
|
+
for (; r || n.length > 0; ) await new Promise((p) => setTimeout(p, 100));
|
|
254
360
|
}
|
|
255
361
|
};
|
|
256
362
|
}
|
|
257
|
-
async function
|
|
363
|
+
async function mt({ onSpeechStart: e, onSpeechEnd: s, onError: o, deviceId: a }) {
|
|
258
364
|
try {
|
|
259
365
|
const { MicVAD: n } = window.vad;
|
|
260
366
|
return await n.new({
|
|
@@ -265,11 +371,11 @@ async function Je({ onSpeechStart: e, onSpeechEnd: a, onError: r, deviceId: c })
|
|
|
265
371
|
echoCancellation: !0,
|
|
266
372
|
noiseSuppression: !0,
|
|
267
373
|
autoGainControl: !1,
|
|
268
|
-
...
|
|
374
|
+
...a ? { deviceId: { exact: a } } : {}
|
|
269
375
|
},
|
|
270
376
|
onSpeechStart: () => e == null ? void 0 : e(),
|
|
271
|
-
onSpeechEnd: (
|
|
272
|
-
console.log("[VAD] onSpeechEnd — samples:",
|
|
377
|
+
onSpeechEnd: (t) => {
|
|
378
|
+
console.log("[VAD] onSpeechEnd — samples:", t == null ? void 0 : t.length), s == null || s(t);
|
|
273
379
|
},
|
|
274
380
|
onVADMisfire: () => {
|
|
275
381
|
},
|
|
@@ -280,555 +386,564 @@ async function Je({ onSpeechStart: e, onSpeechEnd: a, onError: r, deviceId: c })
|
|
|
280
386
|
preSpeechPadFrames: 1
|
|
281
387
|
});
|
|
282
388
|
} catch (n) {
|
|
283
|
-
throw
|
|
389
|
+
throw o == null || o("VAD initialization failed. Falling back to manual microphone capture."), n;
|
|
284
390
|
}
|
|
285
391
|
}
|
|
286
|
-
function
|
|
287
|
-
const
|
|
288
|
-
for (let
|
|
392
|
+
function vt(e, s = 16e3) {
|
|
393
|
+
const o = e.length * 2, a = new ArrayBuffer(44 + o), n = new DataView(a), r = (t, i) => {
|
|
394
|
+
for (let c = 0; c < i.length; c++) n.setUint8(t + c, i.charCodeAt(c));
|
|
289
395
|
};
|
|
290
|
-
|
|
291
|
-
for (let
|
|
292
|
-
const
|
|
293
|
-
n.setInt16(
|
|
396
|
+
r(0, "RIFF"), n.setUint32(4, 36 + o, !0), r(8, "WAVE"), r(12, "fmt "), n.setUint32(16, 16, !0), n.setUint16(20, 1, !0), n.setUint16(22, 1, !0), n.setUint32(24, s, !0), n.setUint32(28, s * 2, !0), n.setUint16(32, 2, !0), n.setUint16(34, 16, !0), r(36, "data"), n.setUint32(40, o, !0);
|
|
397
|
+
for (let t = 0, i = 44; t < e.length; t++, i += 2) {
|
|
398
|
+
const c = Math.max(-1, Math.min(1, e[t]));
|
|
399
|
+
n.setInt16(i, c < 0 ? c * 32768 : c * 32767, !0);
|
|
294
400
|
}
|
|
295
|
-
return new Blob([
|
|
401
|
+
return new Blob([a], { type: "audio/wav" });
|
|
296
402
|
}
|
|
297
|
-
const
|
|
403
|
+
const $ = {
|
|
298
404
|
IDLE: "idle",
|
|
299
405
|
LISTENING: "listening",
|
|
300
406
|
TRANSCRIBING: "transcribing",
|
|
301
407
|
THINKING: "thinking",
|
|
302
408
|
SPEAKING: "speaking"
|
|
303
|
-
},
|
|
304
|
-
function
|
|
409
|
+
}, yt = "You are a friendly assistant for quick voice interactions. Provide answers only in the form of a single concise sentence, without any introductory phrases. Don't use any formatting, markdown, emoji, or code blocks — just plain text. The answers will be spoken aloud, so keep them short and natural.";
|
|
410
|
+
function gt({
|
|
305
411
|
processInput: e,
|
|
306
|
-
systemPrompt:
|
|
307
|
-
ttsProvider:
|
|
308
|
-
ttsVoice:
|
|
412
|
+
systemPrompt: s = yt,
|
|
413
|
+
ttsProvider: o = "server-kokoro",
|
|
414
|
+
ttsVoice: a = "af_bella",
|
|
309
415
|
ttsSpeed: n = 1,
|
|
310
|
-
ttsServerUrl:
|
|
311
|
-
ttsSpeechRate:
|
|
312
|
-
ttsSpeechPitch:
|
|
313
|
-
sttProvider:
|
|
416
|
+
ttsServerUrl: r = "/api/tts",
|
|
417
|
+
ttsSpeechRate: t = 1,
|
|
418
|
+
ttsSpeechPitch: i = 1,
|
|
419
|
+
sttProvider: c = "whisper",
|
|
314
420
|
sttServerUrl: p = "/api/stt",
|
|
315
|
-
whisperModel:
|
|
316
|
-
whisperDtype:
|
|
317
|
-
whisperDevice:
|
|
421
|
+
whisperModel: u = "onnx-community/whisper-tiny.en",
|
|
422
|
+
whisperDtype: m = "q8",
|
|
423
|
+
whisperDevice: v = "wasm",
|
|
318
424
|
kokoroDtype: h = "q8",
|
|
319
425
|
kokoroBrowserDevice: w = "wasm",
|
|
320
|
-
modelProxyUrl:
|
|
426
|
+
modelProxyUrl: S = "/api/models/"
|
|
321
427
|
} = {}) {
|
|
322
|
-
const [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}, [
|
|
326
|
-
|
|
327
|
-
}, [
|
|
328
|
-
|
|
329
|
-
}, [
|
|
330
|
-
|
|
428
|
+
const [K, O] = N($.IDLE), [z, x] = N(!0), [q, R] = N({ whisper: 0, kokoro: 0 }), [B, W] = N(null), [l, A] = N([]), [b, L] = N(null), [f, D] = N(!1), [V, ne] = N(""), [de, X] = N([]), [oe, ee] = N(null), G = U($.IDLE), J = U(!1), P = U(null), k = U(null), y = U(null), M = U(null), F = U(null), we = U(null), ae = U([{ role: "system", content: s }]), ve = U(e), ue = U(0), Q = U({ id: null, enqueuedAt: null, ttsMs: null }), he = U(1), te = U({ provider: c, url: p });
|
|
429
|
+
te.current = { provider: c, url: p }, j(() => {
|
|
430
|
+
ae.current = [{ role: "system", content: s }, ...ae.current.slice(1)];
|
|
431
|
+
}, [s]), j(() => {
|
|
432
|
+
G.current = K;
|
|
433
|
+
}, [K]), j(() => {
|
|
434
|
+
J.current = f;
|
|
435
|
+
}, [f]), j(() => {
|
|
436
|
+
ve.current = e;
|
|
331
437
|
}, [e]), j(() => {
|
|
332
|
-
|
|
438
|
+
const T = navigator.mediaDevices;
|
|
439
|
+
if (!T) return;
|
|
440
|
+
async function C() {
|
|
333
441
|
try {
|
|
334
|
-
const
|
|
335
|
-
|
|
442
|
+
const g = await T.enumerateDevices();
|
|
443
|
+
X(g.filter((I) => I.kind === "audioinput"));
|
|
336
444
|
} catch {
|
|
337
445
|
}
|
|
338
446
|
}
|
|
339
|
-
return
|
|
340
|
-
}, [
|
|
341
|
-
let
|
|
342
|
-
|
|
343
|
-
async function
|
|
447
|
+
return C(), T.addEventListener("devicechange", C), () => T.removeEventListener("devicechange", C);
|
|
448
|
+
}, [f]), j(() => {
|
|
449
|
+
let T = !1;
|
|
450
|
+
x(!0), R({ whisper: 0, kokoro: 0 });
|
|
451
|
+
async function C() {
|
|
344
452
|
try {
|
|
345
|
-
const
|
|
346
|
-
var
|
|
347
|
-
const
|
|
348
|
-
|
|
453
|
+
const g = () => {
|
|
454
|
+
var H;
|
|
455
|
+
const E = Q.current;
|
|
456
|
+
E.enqueuedAt != null && E.ttsMs == null && (E.ttsMs = Math.round(performance.now() - E.enqueuedAt), E.id != null && pe(E.id, { timings: { ttsMs: E.ttsMs } })), o === "webspeech" && ((H = k.current) == null || H.pause());
|
|
349
457
|
};
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
voice:
|
|
353
|
-
rate:
|
|
354
|
-
pitch:
|
|
355
|
-
onPlayStart:
|
|
356
|
-
}),
|
|
357
|
-
else if (
|
|
358
|
-
const { kokoro:
|
|
359
|
-
(
|
|
360
|
-
{ dtype: h, device: w, modelProxyUrl:
|
|
458
|
+
if (o === "webspeech")
|
|
459
|
+
P.current = ft({
|
|
460
|
+
voice: a,
|
|
461
|
+
rate: t,
|
|
462
|
+
pitch: i,
|
|
463
|
+
onPlayStart: g
|
|
464
|
+
}), R((E) => ({ ...E, kokoro: 1 }));
|
|
465
|
+
else if (o === "kokoro") {
|
|
466
|
+
const { kokoro: E } = await ut(
|
|
467
|
+
(H, se) => R((ye) => ({ ...ye, [H]: se })),
|
|
468
|
+
{ dtype: h, device: w, modelProxyUrl: S }
|
|
361
469
|
);
|
|
362
|
-
if (
|
|
363
|
-
|
|
470
|
+
if (T) return;
|
|
471
|
+
P.current = ht(E, { voice: a, speed: n, onPlayStart: g });
|
|
364
472
|
} else
|
|
365
|
-
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
|
|
473
|
+
P.current = pt({ voice: a, speed: n, onPlayStart: g, url: r, onError: (E) => W(E) }), R((E) => ({ ...E, kokoro: 1 }));
|
|
474
|
+
if (T) return;
|
|
475
|
+
const I = typeof navigator > "u" || !navigator.mediaDevices;
|
|
476
|
+
if (c === "server" || c === "none" || I) {
|
|
477
|
+
M.current = null, R((E) => ({ ...E, whisper: 1 })), x(!1);
|
|
369
478
|
return;
|
|
370
479
|
}
|
|
371
|
-
|
|
480
|
+
M.current = new Worker(
|
|
372
481
|
new URL(
|
|
373
482
|
/* @vite-ignore */
|
|
374
|
-
"./assets/whisperWorker-
|
|
483
|
+
"./assets/whisperWorker-rOnua0b5.js",
|
|
375
484
|
import.meta.url
|
|
376
485
|
),
|
|
377
486
|
{ type: "module" }
|
|
378
|
-
),
|
|
379
|
-
|
|
380
|
-
transcribeMs: Math.round(performance.now() -
|
|
381
|
-
}) :
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
},
|
|
487
|
+
), M.current.onmessage = (E) => {
|
|
488
|
+
E.data.type === "transcript" ? be(E.data.text, {
|
|
489
|
+
transcribeMs: Math.round(performance.now() - ue.current)
|
|
490
|
+
}) : E.data.type === "progress" ? R((H) => ({ ...H, whisper: E.data.progress })) : E.data.type === "ready" ? (R((H) => ({ ...H, whisper: 1 })), x(!1)) : E.data.type === "error" && (W(`Whisper: ${E.data.message}`), x(!1));
|
|
491
|
+
}, M.current.onerror = () => {
|
|
492
|
+
W("Model load failed. Check WebGPU/WASM browser support."), x(!1);
|
|
493
|
+
}, M.current.postMessage({
|
|
385
494
|
type: "init",
|
|
386
|
-
model:
|
|
387
|
-
dtype:
|
|
388
|
-
device:
|
|
389
|
-
modelProxyUrl:
|
|
495
|
+
model: u,
|
|
496
|
+
dtype: m,
|
|
497
|
+
device: v,
|
|
498
|
+
modelProxyUrl: S
|
|
390
499
|
});
|
|
391
|
-
} catch (
|
|
392
|
-
|
|
500
|
+
} catch (g) {
|
|
501
|
+
T || (W("Initialisation failed: " + ((g == null ? void 0 : g.message) ?? String(g))), x(!1));
|
|
393
502
|
}
|
|
394
503
|
}
|
|
395
|
-
return
|
|
396
|
-
var
|
|
397
|
-
|
|
504
|
+
return C(), () => {
|
|
505
|
+
var g, I;
|
|
506
|
+
T = !0, (g = M.current) == null || g.terminate(), (I = P.current) == null || I.cancel();
|
|
398
507
|
};
|
|
399
508
|
}, [
|
|
400
|
-
r,
|
|
401
|
-
c,
|
|
402
|
-
n,
|
|
403
|
-
s,
|
|
404
|
-
l,
|
|
405
509
|
o,
|
|
510
|
+
a,
|
|
511
|
+
n,
|
|
512
|
+
t,
|
|
406
513
|
i,
|
|
514
|
+
r,
|
|
515
|
+
c,
|
|
407
516
|
p,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
517
|
+
u,
|
|
518
|
+
m,
|
|
519
|
+
v,
|
|
411
520
|
h,
|
|
412
521
|
w
|
|
413
522
|
]);
|
|
414
|
-
function
|
|
415
|
-
const
|
|
416
|
-
return
|
|
523
|
+
function re(T, C, g) {
|
|
524
|
+
const I = he.current++;
|
|
525
|
+
return A((E) => [...E, { id: I, role: T, content: C, timings: g, time: (/* @__PURE__ */ new Date()).toISOString() }]), I;
|
|
417
526
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
527
|
+
function pe(T, { timings: C }) {
|
|
528
|
+
A((g) => g.map((I) => I.id === T ? { ...I, timings: { ...I.timings, ...C } } : I));
|
|
420
529
|
}
|
|
421
|
-
async function
|
|
422
|
-
const
|
|
530
|
+
async function Ie(T) {
|
|
531
|
+
const C = ue.current;
|
|
423
532
|
try {
|
|
424
|
-
const
|
|
533
|
+
const g = await fetch(te.current.url, {
|
|
425
534
|
method: "POST",
|
|
426
535
|
headers: { "Content-Type": "audio/wav" },
|
|
427
|
-
body:
|
|
536
|
+
body: vt(T, 16e3)
|
|
428
537
|
});
|
|
429
|
-
if (!
|
|
430
|
-
const { text:
|
|
431
|
-
await
|
|
432
|
-
} catch (
|
|
433
|
-
|
|
538
|
+
if (!g.ok) throw new Error(`Speech-to-text failed: ${g.status} ${await g.text()}`);
|
|
539
|
+
const { text: I } = await g.json();
|
|
540
|
+
await be(I, { transcribeMs: Math.round(performance.now() - C) });
|
|
541
|
+
} catch (g) {
|
|
542
|
+
W(g.message || "Speech-to-text failed."), O(J.current ? $.LISTENING : $.IDLE);
|
|
434
543
|
}
|
|
435
544
|
}
|
|
436
|
-
async function
|
|
437
|
-
if (!(
|
|
438
|
-
|
|
545
|
+
async function be(T, { transcribeMs: C } = {}) {
|
|
546
|
+
if (!(T != null && T.trim())) {
|
|
547
|
+
O(J.current ? $.LISTENING : $.IDLE);
|
|
439
548
|
return;
|
|
440
549
|
}
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
|
|
550
|
+
O($.THINKING), re("user", T, C != null ? { transcribeMs: C } : void 0);
|
|
551
|
+
const g = [...ae.current, { role: "user", content: T }];
|
|
552
|
+
ae.current = g, await Le(T, g);
|
|
444
553
|
}
|
|
445
|
-
async function
|
|
446
|
-
var
|
|
447
|
-
(
|
|
554
|
+
async function Le(T, C) {
|
|
555
|
+
var g, I, E, H;
|
|
556
|
+
(g = y.current) == null || g.abort(), y.current = new AbortController(), (I = P.current) == null || I.cancel();
|
|
448
557
|
try {
|
|
449
|
-
if (!
|
|
450
|
-
const
|
|
451
|
-
let
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
var
|
|
456
|
-
|
|
558
|
+
if (!ve.current) throw new Error("processInput is not provided");
|
|
559
|
+
const se = Ve();
|
|
560
|
+
let ye = "", Me = !1, Oe = null;
|
|
561
|
+
const tt = performance.now(), ge = { id: null, enqueuedAt: null, ttsMs: null };
|
|
562
|
+
Q.current = ge;
|
|
563
|
+
const We = (_e) => {
|
|
564
|
+
var Ne;
|
|
565
|
+
ge.enqueuedAt == null && (ge.enqueuedAt = performance.now()), (Ne = P.current) == null || Ne.enqueue(_e);
|
|
457
566
|
};
|
|
458
|
-
|
|
459
|
-
for await (const
|
|
460
|
-
|
|
461
|
-
|
|
567
|
+
L("");
|
|
568
|
+
for await (const _e of ve.current(T, C, y.current.signal))
|
|
569
|
+
Oe == null && (Oe = Math.round(performance.now() - tt)), ye += _e, L(ye), se.write(_e).forEach((nt) => {
|
|
570
|
+
Me || (Me = !0, O($.SPEAKING)), We(nt);
|
|
462
571
|
});
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
thinkMs:
|
|
466
|
-
...
|
|
467
|
-
}),
|
|
468
|
-
} catch (
|
|
469
|
-
|
|
572
|
+
const Ue = se.flush();
|
|
573
|
+
Ue && (Me || O($.SPEAKING), We(Ue)), ge.id = re("assistant", ye, {
|
|
574
|
+
thinkMs: Oe,
|
|
575
|
+
...ge.ttsMs != null ? { ttsMs: ge.ttsMs } : {}
|
|
576
|
+
}), L(null), ae.current = [...ae.current, { role: "assistant", content: ye }], await ((E = P.current) == null ? void 0 : E.finished()), o === "webspeech" && ((H = k.current) == null || H.start());
|
|
577
|
+
} catch (se) {
|
|
578
|
+
L(null), se.name !== "AbortError" && W(se.message || "Processing failed.");
|
|
470
579
|
} finally {
|
|
471
|
-
|
|
580
|
+
O(J.current ? $.LISTENING : $.IDLE);
|
|
472
581
|
}
|
|
473
582
|
}
|
|
474
|
-
async function
|
|
475
|
-
var
|
|
476
|
-
|
|
583
|
+
async function Ze() {
|
|
584
|
+
var T, C;
|
|
585
|
+
if (W(null), !navigator.mediaDevices) {
|
|
586
|
+
W("The microphone is unavailable: browsers only allow it on https:// pages or on localhost. You can still type messages; for voice, open this page over HTTPS.");
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
G.current === $.SPEAKING && ((T = P.current) == null || T.cancel(), (C = y.current) == null || C.abort());
|
|
477
590
|
try {
|
|
478
|
-
|
|
591
|
+
O($.LISTENING), D(!0);
|
|
479
592
|
try {
|
|
480
|
-
const
|
|
481
|
-
audio:
|
|
593
|
+
const g = await navigator.mediaDevices.getUserMedia({
|
|
594
|
+
audio: V ? { deviceId: { exact: V } } : !0,
|
|
482
595
|
video: !1
|
|
483
596
|
});
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
} catch (
|
|
490
|
-
console.warn("[TZVoiceChat] waveform analyser unavailable:",
|
|
597
|
+
we.current = g;
|
|
598
|
+
const I = new AudioContext();
|
|
599
|
+
F.current = I;
|
|
600
|
+
const E = I.createAnalyser();
|
|
601
|
+
E.fftSize = 256, I.createMediaStreamSource(g).connect(E), ee(E);
|
|
602
|
+
} catch (g) {
|
|
603
|
+
console.warn("[TZVoiceChat] waveform analyser unavailable:", g);
|
|
491
604
|
}
|
|
492
|
-
|
|
605
|
+
k.current = await mt({
|
|
493
606
|
onSpeechStart: () => {
|
|
494
|
-
var
|
|
495
|
-
|
|
607
|
+
var g, I;
|
|
608
|
+
o === "webspeech" && G.current === $.SPEAKING || (G.current === $.SPEAKING && ((g = P.current) == null || g.cancel(), (I = y.current) == null || I.abort()), O($.LISTENING));
|
|
496
609
|
},
|
|
497
|
-
onSpeechEnd: (
|
|
498
|
-
var
|
|
499
|
-
|
|
610
|
+
onSpeechEnd: (g) => {
|
|
611
|
+
var I;
|
|
612
|
+
o === "webspeech" && G.current === $.SPEAKING || (O($.TRANSCRIBING), ue.current = performance.now(), te.current.provider === "server" ? Ie(g) : (I = M.current) == null || I.postMessage({ type: "transcribe", audio: g }, [g.buffer]));
|
|
500
613
|
},
|
|
501
|
-
onError: (
|
|
502
|
-
|
|
614
|
+
onError: (g) => {
|
|
615
|
+
W(g), O($.IDLE);
|
|
503
616
|
},
|
|
504
|
-
deviceId:
|
|
617
|
+
deviceId: V || void 0
|
|
505
618
|
});
|
|
506
|
-
} catch (
|
|
507
|
-
console.error("[TZVoiceChat] startListening failed:",
|
|
619
|
+
} catch (g) {
|
|
620
|
+
console.error("[TZVoiceChat] startListening failed:", g), W("Microphone access failed. Allow audio permissions and refresh."), O($.IDLE), D(!1);
|
|
508
621
|
}
|
|
509
622
|
}
|
|
510
|
-
function
|
|
511
|
-
var
|
|
512
|
-
|
|
623
|
+
function Xe() {
|
|
624
|
+
var T, C, g, I, E;
|
|
625
|
+
D(!1), (T = k.current) == null || T.destroy(), k.current = null, (C = we.current) == null || C.getTracks().forEach((H) => H.stop()), we.current = null, (g = F.current) == null || g.close(), F.current = null, ee(null), (I = P.current) == null || I.cancel(), (E = y.current) == null || E.abort(), O($.IDLE);
|
|
513
626
|
}
|
|
514
|
-
function
|
|
515
|
-
var
|
|
516
|
-
if (!(
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
[...
|
|
520
|
-
var
|
|
521
|
-
return (
|
|
522
|
-
}), (
|
|
523
|
-
|
|
627
|
+
function et(T) {
|
|
628
|
+
var E;
|
|
629
|
+
if (!(T != null && T.trim())) return;
|
|
630
|
+
O($.SPEAKING);
|
|
631
|
+
const C = Ve(), g = C.write(T), I = C.flush();
|
|
632
|
+
[...g, ...I ? [I] : []].forEach((H) => {
|
|
633
|
+
var se;
|
|
634
|
+
return (se = P.current) == null ? void 0 : se.enqueue(H);
|
|
635
|
+
}), (E = P.current) == null || E.finished().then(() => {
|
|
636
|
+
O(J.current ? $.LISTENING : $.IDLE);
|
|
524
637
|
});
|
|
525
638
|
}
|
|
526
639
|
return {
|
|
527
640
|
/** Current pipeline state: 'idle' | 'listening' | 'transcribing' | 'thinking' | 'speaking' */
|
|
528
|
-
status:
|
|
641
|
+
status: K,
|
|
529
642
|
/** True while models (Whisper + TTS) are still loading. */
|
|
530
|
-
loading:
|
|
643
|
+
loading: z,
|
|
531
644
|
/** Per-model load progress: { whisper: 0–1, kokoro: 0–1 } */
|
|
532
|
-
progress:
|
|
645
|
+
progress: q,
|
|
533
646
|
/** Last error string, or null. Cleared on startListening(). */
|
|
534
|
-
error:
|
|
647
|
+
error: B,
|
|
535
648
|
/** Completed conversation turns: [{ id, role, content, time, timings }]. timings (ms): user → transcribeMs; assistant → thinkMs (time to first token), ttsMs (first sentence queued → audio starts). */
|
|
536
|
-
transcript:
|
|
649
|
+
transcript: l,
|
|
537
650
|
/** Partial assistant response being streamed, or null. */
|
|
538
|
-
streamingMessage:
|
|
651
|
+
streamingMessage: b,
|
|
652
|
+
/** False when the browser exposes no microphone API (page is not https:// or localhost). */
|
|
653
|
+
micAvailable: typeof navigator < "u" && !!navigator.mediaDevices,
|
|
539
654
|
/** Whether the microphone is currently open. */
|
|
540
|
-
micEnabled:
|
|
655
|
+
micEnabled: f,
|
|
541
656
|
/** Open the microphone and start the VAD → STT → AI → TTS pipeline. */
|
|
542
|
-
startListening:
|
|
657
|
+
startListening: Ze,
|
|
543
658
|
/** Close the microphone and cancel any in-progress pipeline. */
|
|
544
|
-
stopListening:
|
|
659
|
+
stopListening: Xe,
|
|
545
660
|
/** Directly synthesise and play text via the configured TTS provider. */
|
|
546
|
-
speak:
|
|
661
|
+
speak: et,
|
|
547
662
|
/** Submit text as a user message, triggering the full AI → TTS pipeline (same as voice transcription). */
|
|
548
|
-
submitText:
|
|
663
|
+
submitText: be,
|
|
549
664
|
/** AnalyserNode for real-time waveform rendering, or null when mic is off. */
|
|
550
|
-
liveAnalyser:
|
|
665
|
+
liveAnalyser: oe,
|
|
551
666
|
/** Available audio input devices (updated on permission grant). */
|
|
552
|
-
devices:
|
|
667
|
+
devices: de,
|
|
553
668
|
/** Currently selected device ID ('': system default). */
|
|
554
|
-
selectedMicId:
|
|
669
|
+
selectedMicId: V,
|
|
555
670
|
/** Select an audio input device by its deviceId. */
|
|
556
|
-
setSelectedMicId:
|
|
671
|
+
setSelectedMicId: ne
|
|
557
672
|
};
|
|
558
673
|
}
|
|
559
|
-
function
|
|
560
|
-
const
|
|
674
|
+
function Fe(e) {
|
|
675
|
+
const s = e.replace("#", ""), o = s.length === 3 ? s.split("").map((a) => a + a).join("") : s;
|
|
561
676
|
return [
|
|
562
|
-
parseInt(
|
|
563
|
-
parseInt(
|
|
564
|
-
parseInt(
|
|
677
|
+
parseInt(o.slice(0, 2), 16),
|
|
678
|
+
parseInt(o.slice(2, 4), 16),
|
|
679
|
+
parseInt(o.slice(4, 6), 16)
|
|
565
680
|
];
|
|
566
681
|
}
|
|
567
|
-
function
|
|
568
|
-
e /= 255,
|
|
569
|
-
const
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
let
|
|
573
|
-
switch (
|
|
682
|
+
function wt(e, s, o) {
|
|
683
|
+
e /= 255, s /= 255, o /= 255;
|
|
684
|
+
const a = Math.max(e, s, o), n = Math.min(e, s, o), r = (a + n) / 2;
|
|
685
|
+
if (a === n) return [0, 0, r * 100];
|
|
686
|
+
const t = a - n, i = r > 0.5 ? t / (2 - a - n) : t / (a + n);
|
|
687
|
+
let c;
|
|
688
|
+
switch (a) {
|
|
574
689
|
case e:
|
|
575
|
-
|
|
690
|
+
c = ((s - o) / t + (s < o ? 6 : 0)) / 6;
|
|
576
691
|
break;
|
|
577
|
-
case
|
|
578
|
-
|
|
692
|
+
case s:
|
|
693
|
+
c = ((o - e) / t + 2) / 6;
|
|
579
694
|
break;
|
|
580
695
|
default:
|
|
581
|
-
|
|
696
|
+
c = ((e - s) / t + 4) / 6;
|
|
582
697
|
}
|
|
583
|
-
return [
|
|
698
|
+
return [c * 360, i * 100, r * 100];
|
|
584
699
|
}
|
|
585
|
-
function
|
|
586
|
-
|
|
587
|
-
const
|
|
588
|
-
return [Math.round(
|
|
700
|
+
function bt(e, s, o) {
|
|
701
|
+
s /= 100, o /= 100;
|
|
702
|
+
const a = (t) => (t + e / 30) % 12, n = s * Math.min(o, 1 - o), r = (t) => o - n * Math.max(-1, Math.min(a(t) - 3, Math.min(9 - a(t), 1)));
|
|
703
|
+
return [Math.round(r(0) * 255), Math.round(r(8) * 255), Math.round(r(4) * 255)];
|
|
589
704
|
}
|
|
590
|
-
function
|
|
591
|
-
const [
|
|
592
|
-
return `rgb(${
|
|
705
|
+
function Z(e, s) {
|
|
706
|
+
const [o, a, n] = Fe(e), [r, t, i] = wt(o, a, n), [c, p, u] = bt(r, t, Math.max(0, Math.min(100, i + s)));
|
|
707
|
+
return `rgb(${c}, ${p}, ${u})`;
|
|
593
708
|
}
|
|
594
|
-
function
|
|
595
|
-
const [
|
|
596
|
-
return `rgba(${
|
|
709
|
+
function Y(e, s) {
|
|
710
|
+
const [o, a, n] = Fe(e);
|
|
711
|
+
return `rgba(${o}, ${a}, ${n}, ${s})`;
|
|
597
712
|
}
|
|
598
|
-
function
|
|
599
|
-
return e.replace("rgb(", "rgba(").replace(")", `, ${
|
|
713
|
+
function ke(e, s) {
|
|
714
|
+
return e.replace("rgb(", "rgba(").replace(")", `, ${s})`);
|
|
600
715
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
603
|
-
const
|
|
716
|
+
const Ae = 10;
|
|
717
|
+
function kt({ analyser: e }) {
|
|
718
|
+
const s = U(null), o = U(null);
|
|
604
719
|
return j(() => {
|
|
605
|
-
if (cancelAnimationFrame(
|
|
606
|
-
const
|
|
607
|
-
if (!
|
|
608
|
-
const n =
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
n.clearRect(0, 0,
|
|
612
|
-
const
|
|
613
|
-
for (let
|
|
614
|
-
const
|
|
615
|
-
n.fillStyle = `hsl(${p +
|
|
720
|
+
if (cancelAnimationFrame(o.current), !e) return;
|
|
721
|
+
const a = s.current;
|
|
722
|
+
if (!a) return;
|
|
723
|
+
const n = a.getContext("2d"), r = e.frequencyBinCount, t = new Uint8Array(r), i = Math.max(1, Math.floor(r / Ae)), c = getComputedStyle(a), p = +c.getPropertyValue("--bar-hue"), u = +c.getPropertyValue("--bar-hue-range"), m = +c.getPropertyValue("--bar-sat"), v = +c.getPropertyValue("--bar-lit"), h = +c.getPropertyValue("--bar-lit-range"), w = () => {
|
|
724
|
+
o.current = requestAnimationFrame(w), e.getByteFrequencyData(t);
|
|
725
|
+
const S = a.width, K = a.height;
|
|
726
|
+
n.clearRect(0, 0, S, K);
|
|
727
|
+
const O = (S - (Ae - 1) * 2) / Ae;
|
|
728
|
+
for (let z = 0; z < Ae; z++) {
|
|
729
|
+
const x = t[z * i] / 255, q = Math.max(3, x * K * 0.88);
|
|
730
|
+
n.fillStyle = `hsl(${p + x * u}, ${m}%, ${v + x * h}%)`, n.beginPath(), n.roundRect(z * (O + 2), (K - q) / 2, O, q, [2]), n.fill();
|
|
616
731
|
}
|
|
617
732
|
};
|
|
618
|
-
return w(), () => cancelAnimationFrame(
|
|
619
|
-
}, [e]), /* @__PURE__ */
|
|
733
|
+
return w(), () => cancelAnimationFrame(o.current);
|
|
734
|
+
}, [e]), /* @__PURE__ */ d("canvas", { ref: s, width: 55, height: 35, className: "ai-btn__canvas" });
|
|
620
735
|
}
|
|
621
|
-
function
|
|
736
|
+
function _t({
|
|
622
737
|
status: e = "idle",
|
|
623
|
-
active:
|
|
624
|
-
loading:
|
|
625
|
-
analyser:
|
|
738
|
+
active: s = !1,
|
|
739
|
+
loading: o = !1,
|
|
740
|
+
analyser: a = null,
|
|
626
741
|
onToggle: n,
|
|
627
|
-
devices:
|
|
628
|
-
selectedMicId:
|
|
629
|
-
onDeviceChange:
|
|
742
|
+
devices: r = [],
|
|
743
|
+
selectedMicId: t = "",
|
|
744
|
+
onDeviceChange: i,
|
|
630
745
|
// ── Manual input ───────────────────────────────────────────
|
|
631
|
-
inputData:
|
|
746
|
+
inputData: c = "",
|
|
632
747
|
sendData: p,
|
|
633
748
|
// ── Theming ────────────────────────────────────────────────
|
|
634
|
-
accentColor:
|
|
635
|
-
uiColor:
|
|
636
|
-
size:
|
|
749
|
+
accentColor: u = "#f97316",
|
|
750
|
+
uiColor: m = "#64748b",
|
|
751
|
+
size: v = 70,
|
|
637
752
|
barHue: h = 25,
|
|
638
753
|
barHueRange: w = 20,
|
|
639
|
-
barSat:
|
|
640
|
-
barLit:
|
|
641
|
-
barLitRange:
|
|
754
|
+
barSat: S = 88,
|
|
755
|
+
barLit: K = 65,
|
|
756
|
+
barLitRange: O = 20
|
|
642
757
|
}) {
|
|
643
|
-
var
|
|
644
|
-
const [
|
|
758
|
+
var L;
|
|
759
|
+
const [z, x] = N(!1), q = U(null);
|
|
645
760
|
j(() => {
|
|
646
|
-
if (!
|
|
647
|
-
function
|
|
648
|
-
var
|
|
649
|
-
(
|
|
761
|
+
if (!z) return;
|
|
762
|
+
function f(D) {
|
|
763
|
+
var V;
|
|
764
|
+
(V = q.current) != null && V.contains(D.target) || x(!1);
|
|
650
765
|
}
|
|
651
|
-
return document.addEventListener("pointerdown",
|
|
652
|
-
}, [
|
|
653
|
-
function
|
|
654
|
-
|
|
766
|
+
return document.addEventListener("pointerdown", f), () => document.removeEventListener("pointerdown", f);
|
|
767
|
+
}, [z]);
|
|
768
|
+
function R(f) {
|
|
769
|
+
i == null || i(f), x(!1);
|
|
655
770
|
}
|
|
656
|
-
const
|
|
657
|
-
const
|
|
771
|
+
const B = st(() => {
|
|
772
|
+
const f = Z(u, -8), D = Z(u, -15), V = Z(u, -22), ne = Z(u, -30), de = Z(u, -42), X = Z(u, 8), oe = Z(u, 20), ee = Z(u, 30), G = Z(m, -22), J = Z(m, -30), P = Z(m, 18), k = Z(m, 37);
|
|
658
773
|
return {
|
|
659
|
-
"--tz-size": `${
|
|
774
|
+
"--tz-size": `${v}px`,
|
|
660
775
|
// Accent shades
|
|
661
|
-
"--tz-a":
|
|
662
|
-
"--tz-a-d8":
|
|
663
|
-
"--tz-a-d15":
|
|
664
|
-
"--tz-a-d22":
|
|
665
|
-
"--tz-a-d30":
|
|
666
|
-
"--tz-a-d42":
|
|
667
|
-
"--tz-a-l8":
|
|
668
|
-
"--tz-a-l20":
|
|
669
|
-
"--tz-a-l30":
|
|
776
|
+
"--tz-a": u,
|
|
777
|
+
"--tz-a-d8": f,
|
|
778
|
+
"--tz-a-d15": D,
|
|
779
|
+
"--tz-a-d22": V,
|
|
780
|
+
"--tz-a-d30": ne,
|
|
781
|
+
"--tz-a-d42": de,
|
|
782
|
+
"--tz-a-l8": X,
|
|
783
|
+
"--tz-a-l20": oe,
|
|
784
|
+
"--tz-a-l30": ee,
|
|
670
785
|
// Accent + alpha
|
|
671
|
-
"--tz-a-25":
|
|
672
|
-
"--tz-a-28":
|
|
673
|
-
"--tz-a-30":
|
|
674
|
-
"--tz-a-32":
|
|
675
|
-
"--tz-a-34":
|
|
676
|
-
"--tz-a-35":
|
|
677
|
-
"--tz-a-38":
|
|
678
|
-
"--tz-a-45":
|
|
679
|
-
"--tz-a-50":
|
|
680
|
-
"--tz-a-55":
|
|
681
|
-
"--tz-a-60":
|
|
682
|
-
"--tz-a-65":
|
|
683
|
-
"--tz-a-68":
|
|
786
|
+
"--tz-a-25": Y(u, 0.25),
|
|
787
|
+
"--tz-a-28": Y(u, 0.28),
|
|
788
|
+
"--tz-a-30": Y(u, 0.3),
|
|
789
|
+
"--tz-a-32": Y(u, 0.32),
|
|
790
|
+
"--tz-a-34": Y(u, 0.34),
|
|
791
|
+
"--tz-a-35": Y(u, 0.35),
|
|
792
|
+
"--tz-a-38": Y(u, 0.38),
|
|
793
|
+
"--tz-a-45": Y(u, 0.45),
|
|
794
|
+
"--tz-a-50": Y(u, 0.5),
|
|
795
|
+
"--tz-a-55": Y(u, 0.55),
|
|
796
|
+
"--tz-a-60": Y(u, 0.6),
|
|
797
|
+
"--tz-a-65": Y(u, 0.65),
|
|
798
|
+
"--tz-a-68": Y(u, 0.68),
|
|
684
799
|
// UI shades
|
|
685
|
-
"--tz-u":
|
|
686
|
-
"--tz-u-d22":
|
|
687
|
-
"--tz-u-d30":
|
|
688
|
-
"--tz-u-l18":
|
|
689
|
-
"--tz-u-l37":
|
|
800
|
+
"--tz-u": m,
|
|
801
|
+
"--tz-u-d22": G,
|
|
802
|
+
"--tz-u-d30": J,
|
|
803
|
+
"--tz-u-l18": P,
|
|
804
|
+
"--tz-u-l37": k,
|
|
690
805
|
// UI + alpha
|
|
691
|
-
"--tz-u-30":
|
|
692
|
-
"--tz-u-55":
|
|
693
|
-
"--tz-u-d30-a85":
|
|
694
|
-
"--tz-u-l18-a18":
|
|
695
|
-
"--tz-u-l18-a20":
|
|
696
|
-
"--tz-u-l18-a32":
|
|
697
|
-
"--tz-u-d22-a90":
|
|
806
|
+
"--tz-u-30": Y(m, 0.3),
|
|
807
|
+
"--tz-u-55": Y(m, 0.55),
|
|
808
|
+
"--tz-u-d30-a85": ke(J, 0.85),
|
|
809
|
+
"--tz-u-l18-a18": ke(P, 0.18),
|
|
810
|
+
"--tz-u-l18-a20": ke(P, 0.2),
|
|
811
|
+
"--tz-u-l18-a32": ke(P, 0.32),
|
|
812
|
+
"--tz-u-d22-a90": ke(G, 0.9),
|
|
698
813
|
// Waveform bar colors (cascade to canvas via getComputedStyle)
|
|
699
814
|
"--bar-hue": h,
|
|
700
815
|
"--bar-hue-range": w,
|
|
701
|
-
"--bar-sat":
|
|
702
|
-
"--bar-lit":
|
|
703
|
-
"--bar-lit-range":
|
|
816
|
+
"--bar-sat": S,
|
|
817
|
+
"--bar-lit": K,
|
|
818
|
+
"--bar-lit-range": O
|
|
704
819
|
};
|
|
705
|
-
}, [
|
|
706
|
-
let
|
|
707
|
-
return
|
|
708
|
-
/* @__PURE__ */
|
|
709
|
-
/* @__PURE__ */
|
|
710
|
-
/* @__PURE__ */
|
|
711
|
-
] }) : e === "listening" ?
|
|
712
|
-
/* @__PURE__ */
|
|
713
|
-
/* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
] }) : e === "speaking" && (
|
|
716
|
-
/* @__PURE__ */ _("div", { className: `ai-btn-rings ai-btn-rings--${
|
|
717
|
-
/* @__PURE__ */
|
|
718
|
-
/* @__PURE__ */
|
|
820
|
+
}, [u, m, v, h, w, S, K, O]), W = ((L = r.find((f) => f.deviceId === t)) == null ? void 0 : L.label) || (t ? `Mic ${t.slice(0, 6)}…` : "Default mic"), l = c.trim().length > 0, A = l ? "ready" : s ? e : "off";
|
|
821
|
+
let b;
|
|
822
|
+
return l ? b = /* @__PURE__ */ d("svg", { className: "ai-btn__mic", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ d("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) }) : !s || e === "idle" ? b = /* @__PURE__ */ _("svg", { className: "ai-btn__mic", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: [
|
|
823
|
+
/* @__PURE__ */ d("path", { fillOpacity: "0.52", d: "M12 1a4 4 0 0 1 4 4v6a4 4 0 0 1-8 0V5a4 4 0 0 1 4-4zm6 10a1 1 0 0 1 2 0 8 8 0 0 1-7 7.94V21h2a1 1 0 0 1 0 2H9a1 1 0 0 1 0-2h2v-2.06A8 8 0 0 1 4 11a1 1 0 0 1 2 0 6 6 0 0 0 12 0z" }),
|
|
824
|
+
/* @__PURE__ */ d("path", { fill: "white", fillOpacity: "0.98", d: "M14.5 0L15.65 3.45L19.1 4.6L15.65 5.75L14.5 9.2L13.35 5.75L9.9 4.6L13.35 3.45Z" }),
|
|
825
|
+
/* @__PURE__ */ d("path", { fill: "white", fillOpacity: "0.88", d: "M19 8.62L19.75 10.75L21.88 11.5L19.75 12.25L19 14.38L18.25 12.25L16.12 11.5L18.25 10.75Z" })
|
|
826
|
+
] }) : e === "listening" ? b = /* @__PURE__ */ d(kt, { analyser: a }) : e === "transcribing" ? b = /* @__PURE__ */ d("div", { className: "ai-btn__bars ai-btn__bars--transcribing", children: Array.from({ length: 7 }, (f, D) => /* @__PURE__ */ d("span", { style: { animationDelay: `${D * 0.1}s` } }, D)) }) : e === "thinking" ? b = /* @__PURE__ */ _("div", { className: "ai-btn__dots", children: [
|
|
827
|
+
/* @__PURE__ */ d("span", {}),
|
|
828
|
+
/* @__PURE__ */ d("span", { style: { animationDelay: "0.18s" } }),
|
|
829
|
+
/* @__PURE__ */ d("span", { style: { animationDelay: "0.36s" } })
|
|
830
|
+
] }) : e === "speaking" && (b = /* @__PURE__ */ d("div", { className: "ai-btn__bars ai-btn__bars--speaking", children: Array.from({ length: 7 }, (f, D) => /* @__PURE__ */ d("span", { style: { animationDelay: `${D * 0.11}s` } }, D)) })), /* @__PURE__ */ _("div", { className: "ai-btn-root", style: B, children: [
|
|
831
|
+
/* @__PURE__ */ _("div", { className: `ai-btn-rings ai-btn-rings--${A}`, "aria-hidden": "true", children: [
|
|
832
|
+
/* @__PURE__ */ d("span", { className: "ai-ring ai-ring--1" }),
|
|
833
|
+
/* @__PURE__ */ d("span", { className: "ai-ring ai-ring--2" })
|
|
719
834
|
] }),
|
|
720
835
|
/* @__PURE__ */ _(
|
|
721
836
|
"button",
|
|
722
837
|
{
|
|
723
|
-
className: `ai-btn ai-btn--${
|
|
724
|
-
disabled:
|
|
725
|
-
onClick:
|
|
726
|
-
"aria-label":
|
|
727
|
-
"aria-pressed":
|
|
838
|
+
className: `ai-btn ai-btn--${A}`,
|
|
839
|
+
disabled: o,
|
|
840
|
+
onClick: l ? () => p == null ? void 0 : p(c) : n,
|
|
841
|
+
"aria-label": l ? "Send message" : s ? "Stop assistant" : "Start assistant",
|
|
842
|
+
"aria-pressed": l ? void 0 : s,
|
|
728
843
|
children: [
|
|
729
|
-
|
|
730
|
-
|
|
844
|
+
b,
|
|
845
|
+
s && !l && /* @__PURE__ */ d("span", { className: "ai-btn__hover-stop", "aria-hidden": "true", children: "■" })
|
|
731
846
|
]
|
|
732
847
|
}
|
|
733
848
|
),
|
|
734
|
-
/* @__PURE__ */ _("div", { className: `ai-mic-sel${
|
|
849
|
+
/* @__PURE__ */ _("div", { className: `ai-mic-sel${z ? " open" : ""}`, ref: q, children: [
|
|
735
850
|
/* @__PURE__ */ _(
|
|
736
851
|
"button",
|
|
737
852
|
{
|
|
738
853
|
className: "ai-mic-sel__trigger",
|
|
739
|
-
onClick: () =>
|
|
854
|
+
onClick: () => x((f) => !f),
|
|
740
855
|
title: "Change microphone",
|
|
741
856
|
"aria-label": "Change microphone",
|
|
742
|
-
"aria-expanded":
|
|
857
|
+
"aria-expanded": z,
|
|
743
858
|
children: [
|
|
744
859
|
/* @__PURE__ */ _("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: [
|
|
745
|
-
/* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */
|
|
860
|
+
/* @__PURE__ */ d("path", { d: "M12 1a4 4 0 0 1 4 4v6a4 4 0 0 1-8 0V5a4 4 0 0 1 4-4z" }),
|
|
861
|
+
/* @__PURE__ */ d("path", { d: "M5 11a1 1 0 0 0-2 0 9 9 0 0 0 8 8.94V22H9a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2h-2v-2.06A9 9 0 0 0 21 11a1 1 0 0 0-2 0 7 7 0 0 1-14 0z" })
|
|
747
862
|
] }),
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
863
|
+
/* @__PURE__ */ d("span", { className: "ai-mic-sel__label", children: W }),
|
|
864
|
+
/* @__PURE__ */ d(
|
|
750
865
|
"svg",
|
|
751
866
|
{
|
|
752
|
-
className: `ai-mic-sel__caret${
|
|
867
|
+
className: `ai-mic-sel__caret${z ? " open" : ""}`,
|
|
753
868
|
width: "9",
|
|
754
869
|
height: "9",
|
|
755
870
|
viewBox: "0 0 24 24",
|
|
756
871
|
fill: "currentColor",
|
|
757
872
|
"aria-hidden": "true",
|
|
758
|
-
children: /* @__PURE__ */
|
|
873
|
+
children: /* @__PURE__ */ d("path", { d: "M12 16L4 8h16l-8 8z" })
|
|
759
874
|
}
|
|
760
875
|
)
|
|
761
876
|
]
|
|
762
877
|
}
|
|
763
878
|
),
|
|
764
|
-
|
|
765
|
-
/* @__PURE__ */
|
|
879
|
+
z && /* @__PURE__ */ _("ul", { className: "ai-mic-sel__menu", role: "listbox", "aria-label": "Select microphone", children: [
|
|
880
|
+
/* @__PURE__ */ d(
|
|
766
881
|
"li",
|
|
767
882
|
{
|
|
768
883
|
role: "option",
|
|
769
|
-
className: `ai-mic-sel__option${
|
|
770
|
-
onClick: () =>
|
|
771
|
-
"aria-selected":
|
|
884
|
+
className: `ai-mic-sel__option${t === "" ? " selected" : ""}`,
|
|
885
|
+
onClick: () => R(""),
|
|
886
|
+
"aria-selected": t === "",
|
|
772
887
|
children: "Default microphone"
|
|
773
888
|
}
|
|
774
889
|
),
|
|
775
|
-
|
|
890
|
+
r.map((f) => /* @__PURE__ */ d(
|
|
776
891
|
"li",
|
|
777
892
|
{
|
|
778
893
|
role: "option",
|
|
779
|
-
className: `ai-mic-sel__option${
|
|
780
|
-
onClick: () =>
|
|
781
|
-
"aria-selected":
|
|
782
|
-
children:
|
|
894
|
+
className: `ai-mic-sel__option${t === f.deviceId ? " selected" : ""}`,
|
|
895
|
+
onClick: () => R(f.deviceId),
|
|
896
|
+
"aria-selected": t === f.deviceId,
|
|
897
|
+
children: f.label || `Microphone ${f.deviceId.slice(0, 8)}`
|
|
783
898
|
},
|
|
784
|
-
|
|
899
|
+
f.deviceId
|
|
785
900
|
))
|
|
786
901
|
] })
|
|
787
902
|
] })
|
|
788
903
|
] });
|
|
789
904
|
}
|
|
790
|
-
async function
|
|
791
|
-
var
|
|
792
|
-
const
|
|
905
|
+
async function St(e, s, o = "/api/chat") {
|
|
906
|
+
var i;
|
|
907
|
+
const a = await fetch(o, {
|
|
793
908
|
method: "POST",
|
|
794
909
|
headers: {
|
|
795
910
|
"Content-Type": "application/json"
|
|
796
911
|
},
|
|
797
|
-
signal:
|
|
912
|
+
signal: s,
|
|
798
913
|
body: JSON.stringify({ messages: e })
|
|
799
914
|
});
|
|
800
|
-
if (!
|
|
801
|
-
const
|
|
802
|
-
throw new Error(`Server error: ${
|
|
915
|
+
if (!a.ok) {
|
|
916
|
+
const c = await a.text();
|
|
917
|
+
throw new Error(`Server error: ${a.status} ${c}`);
|
|
803
918
|
}
|
|
804
|
-
const n = (
|
|
919
|
+
const n = (i = a.body) == null ? void 0 : i.getReader();
|
|
805
920
|
if (!n) {
|
|
806
|
-
const
|
|
921
|
+
const c = await a.json();
|
|
807
922
|
return { stream: async function* () {
|
|
808
|
-
yield
|
|
923
|
+
yield c.text;
|
|
809
924
|
} };
|
|
810
925
|
}
|
|
811
|
-
const
|
|
812
|
-
let
|
|
926
|
+
const r = new TextDecoder();
|
|
927
|
+
let t = "";
|
|
813
928
|
return {
|
|
814
929
|
stream: async function* () {
|
|
815
|
-
var p,
|
|
816
|
-
let
|
|
930
|
+
var p, u, m;
|
|
931
|
+
let c = "";
|
|
817
932
|
for (; ; ) {
|
|
818
|
-
const { value:
|
|
933
|
+
const { value: v, done: h } = await n.read();
|
|
819
934
|
if (h) break;
|
|
820
|
-
|
|
821
|
-
const w =
|
|
935
|
+
t += r.decode(v, { stream: !0 });
|
|
936
|
+
const w = t.split(`
|
|
822
937
|
`);
|
|
823
|
-
|
|
824
|
-
for (const
|
|
825
|
-
const
|
|
826
|
-
if (!
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
938
|
+
t = w.pop();
|
|
939
|
+
for (const S of w) {
|
|
940
|
+
const K = S.trim();
|
|
941
|
+
if (!K.startsWith("data:")) continue;
|
|
942
|
+
const O = K.slice(5).trimStart();
|
|
943
|
+
if (O === "[DONE]") return;
|
|
829
944
|
try {
|
|
830
|
-
const
|
|
831
|
-
|
|
945
|
+
const x = (m = (u = (p = JSON.parse(O).choices) == null ? void 0 : p[0]) == null ? void 0 : u.delta) == null ? void 0 : m.content;
|
|
946
|
+
x && (c && /\w/.test(c) && /\w/.test(x[0]) && (yield " "), c = x[x.length - 1], yield x);
|
|
832
947
|
} catch {
|
|
833
948
|
}
|
|
834
949
|
}
|
|
@@ -836,134 +951,218 @@ async function rt(e, a, r = "/api/chat") {
|
|
|
836
951
|
}
|
|
837
952
|
};
|
|
838
953
|
}
|
|
839
|
-
function
|
|
954
|
+
function At(e, s, o) {
|
|
840
955
|
return {
|
|
841
956
|
stream: async function* () {
|
|
842
|
-
const
|
|
843
|
-
let n = null,
|
|
844
|
-
const
|
|
845
|
-
p.type === "token" ? (
|
|
846
|
-
},
|
|
847
|
-
|
|
957
|
+
const a = [];
|
|
958
|
+
let n = null, r = !1, t = "";
|
|
959
|
+
const i = ({ data: p }) => {
|
|
960
|
+
p.type === "token" ? (a.push(p.text), n == null || n(), n = null) : p.type === "done" && (r = !0, n == null || n(), n = null);
|
|
961
|
+
}, c = () => {
|
|
962
|
+
r = !0, n == null || n(), n = null;
|
|
848
963
|
};
|
|
849
|
-
e.addEventListener("message",
|
|
964
|
+
e.addEventListener("message", i), o == null || o.addEventListener("abort", c), e.postMessage({ type: "generate", messages: s });
|
|
850
965
|
try {
|
|
851
|
-
for (; !
|
|
852
|
-
if (
|
|
853
|
-
const p =
|
|
854
|
-
|
|
966
|
+
for (; !r || a.length > 0; )
|
|
967
|
+
if (a.length > 0) {
|
|
968
|
+
const p = a.shift();
|
|
969
|
+
t && /\w/.test(t) && /\w/.test(p[0]) && (yield " "), t = p[p.length - 1], yield p;
|
|
855
970
|
} else
|
|
856
971
|
await new Promise((p) => {
|
|
857
972
|
n = p;
|
|
858
973
|
});
|
|
859
974
|
} finally {
|
|
860
|
-
e.removeEventListener("message",
|
|
975
|
+
e.removeEventListener("message", i), o == null || o.removeEventListener("abort", c);
|
|
861
976
|
}
|
|
862
977
|
}
|
|
863
978
|
};
|
|
864
979
|
}
|
|
865
|
-
|
|
866
|
-
|
|
980
|
+
const Te = "tz-voice-chat:boot", He = "tz-voice-chat:stage", je = "tz-voice-chat:allowLocalLlm", le = {
|
|
981
|
+
get(e) {
|
|
982
|
+
try {
|
|
983
|
+
return JSON.parse(localStorage.getItem(e) || "null");
|
|
984
|
+
} catch {
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
set(e, s) {
|
|
989
|
+
try {
|
|
990
|
+
localStorage.setItem(e, JSON.stringify(s));
|
|
991
|
+
} catch {
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}, ce = (e) => le.set(He, { s: e, at: Date.now() }), Re = () => {
|
|
995
|
+
if (typeof navigator > "u") return !1;
|
|
996
|
+
const e = typeof location < "u" ? new URLSearchParams(location.search).get("phone") : null;
|
|
997
|
+
return e === "1" ? !0 : e === "0" ? !1 : /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
998
|
+
}, Et = () => Re() ? 2 : 3;
|
|
999
|
+
function Pt() {
|
|
1000
|
+
var t;
|
|
1001
|
+
const e = Date.now(), s = le.get(Te), o = s && !s.done && e - s.at < 10 * 60 * 1e3, a = o ? ((t = le.get(He)) == null ? void 0 : t.s) ?? null : null, n = o ? s.attempts + 1 : 1, r = !!(s != null && s.safe) || n >= Et();
|
|
1002
|
+
return le.set(Te, { attempts: s != null && s.safe ? s.attempts : n, at: e, done: !1, safe: r }), ce("page started"), { attempts: n, lastStage: a, safe: r };
|
|
1003
|
+
}
|
|
1004
|
+
const Tt = () => {
|
|
1005
|
+
const e = typeof location < "u" ? new URLSearchParams(location.search).get("stagedLoad") : null;
|
|
1006
|
+
return e === "1" ? !0 : e === "0" ? !1 : Re();
|
|
1007
|
+
};
|
|
1008
|
+
function It({ apiBase: e = "/api", systemPrompt: s } = {}) {
|
|
1009
|
+
const [o, a] = N(!0), [n, r] = N(0), [t, i] = N(""), [c, p] = N({}), [u, m] = N(null), [v, h] = N({}), [w, S] = N(0), [K, O] = N([]), [z, x] = N(null), [q, R] = N("idle"), B = U(null), W = U(null), l = U(null), A = U(null);
|
|
1010
|
+
A.current === null && (A.current = Pt());
|
|
1011
|
+
const b = A.current, L = b.attempts, f = b.safe, [D, V] = N(!1), ne = Ee(() => S((P) => P + 1), []), de = Ee(() => {
|
|
1012
|
+
le.set(je, !0), S((P) => P + 1);
|
|
1013
|
+
}, []);
|
|
867
1014
|
j(() => {
|
|
868
|
-
let
|
|
869
|
-
|
|
870
|
-
async function
|
|
871
|
-
let
|
|
1015
|
+
let P = !1;
|
|
1016
|
+
i(""), r(0);
|
|
1017
|
+
async function k() {
|
|
1018
|
+
let y = null, M = {};
|
|
872
1019
|
try {
|
|
873
|
-
|
|
874
|
-
ttsProvider:
|
|
875
|
-
ttsVoice:
|
|
876
|
-
ttsSpeed:
|
|
1020
|
+
y = await (await fetch(`${e}/config`)).json(), m(y), M = {
|
|
1021
|
+
ttsProvider: y.ttsProvider || "kokoro",
|
|
1022
|
+
ttsVoice: y.ttsProvider === "openai" ? y.openaiTtsVoice || "alloy" : y.ttsProvider === "openai-compatible" ? y.ttsCompatVoice || "alloy" : y.ttsProvider === "elevenlabs" ? y.elevenlabsVoiceId : y.ttsProvider === "webspeech" ? y.webSpeechVoice || "" : y.kokoroVoice || "af_bella",
|
|
1023
|
+
ttsSpeed: y.kokoroSpeed ?? 1,
|
|
877
1024
|
ttsServerUrl: `${e}/tts`,
|
|
878
|
-
ttsSpeechRate:
|
|
879
|
-
ttsSpeechPitch:
|
|
880
|
-
sttProvider:
|
|
1025
|
+
ttsSpeechRate: y.webSpeechRate ?? 1,
|
|
1026
|
+
ttsSpeechPitch: y.webSpeechPitch ?? 1,
|
|
1027
|
+
sttProvider: y.sttProvider === "elevenlabs" || y.sttProvider === "openai" ? "server" : "whisper",
|
|
881
1028
|
sttServerUrl: `${e}/stt`,
|
|
882
|
-
whisperModel:
|
|
883
|
-
whisperDtype:
|
|
884
|
-
whisperDevice:
|
|
885
|
-
kokoroDtype:
|
|
886
|
-
kokoroBrowserDevice:
|
|
1029
|
+
whisperModel: y.whisperModel || "onnx-community/whisper-tiny.en",
|
|
1030
|
+
whisperDtype: y.whisperDtype || "q8",
|
|
1031
|
+
whisperDevice: y.whisperDevice || "wasm",
|
|
1032
|
+
kokoroDtype: y.kokoroDtype || "q8",
|
|
1033
|
+
kokoroBrowserDevice: y.kokoroBrowserDevice || "wasm",
|
|
887
1034
|
modelProxyUrl: `${e}/models/`,
|
|
888
|
-
...
|
|
1035
|
+
...y.systemPrompt ? { systemPrompt: y.systemPrompt } : {}
|
|
889
1036
|
};
|
|
890
1037
|
} catch {
|
|
891
|
-
|
|
1038
|
+
M = { ttsProvider: "kokoro", ttsServerUrl: `${e}/tts`, modelProxyUrl: `${e}/models/` };
|
|
1039
|
+
}
|
|
1040
|
+
if (P) return;
|
|
1041
|
+
ce("config loaded");
|
|
1042
|
+
const F = [], we = typeof window < "u" && window.isSecureContext === !1, ae = typeof navigator < "u" && !navigator.gpu;
|
|
1043
|
+
we && F.push('This page is not served over HTTPS (or localhost), so the browser blocks the microphone and WebGPU. Typed chat still works; for voice open it over https:// (see "Use it from a phone" in the README).');
|
|
1044
|
+
const ve = typeof navigator > "u" || !navigator.mediaDevices;
|
|
1045
|
+
if (ve && (M = { ...M, sttProvider: "none" }, F.push("Speech recognition is not loaded because this page has no microphone. Typed messages and spoken replies still work.")), ae) {
|
|
1046
|
+
const Q = [];
|
|
1047
|
+
!ve && M.whisperDevice === "webgpu" && (M = { ...M, whisperDevice: "wasm", whisperDtype: "q8" }, Q.push("speech recognition runs on the CPU (Whisper, q8)")), M.ttsProvider === "kokoro" && M.kokoroBrowserDevice === "webgpu" && (M = { ...M, ttsProvider: "webspeech", ttsVoice: "" }, Q.push("replies are spoken with the browser's built-in voice instead of Kokoro")), Q.length && F.push(`WebGPU is not available here, so ${Q.join(" and ")}.`);
|
|
892
1048
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1049
|
+
f ? (M.sttProvider === "whisper" && (M = { ...M, whisperModel: "onnx-community/whisper-tiny.en", whisperDtype: "q8", whisperDevice: "wasm" }), M.ttsProvider === "kokoro" && (M = { ...M, ttsProvider: "webspeech", ttsVoice: "" }), F.push(`This page restarted ${L} times before it finished loading — usually the device ran out of memory. ` + (b.lastStage ? `It had reached: ${b.lastStage}. ` : "") + "Heavy models are switched off for now: the smallest speech model and the browser voice are used, and the in-browser chat model is not loaded. Pick a cloud chat provider in Settings, or retry the full load.")) : b.attempts >= 2 && b.lastStage && F.push(`The page restarted before it finished loading (attempt ${b.attempts}); it had reached: ${b.lastStage}.`);
|
|
1050
|
+
const ue = (y == null ? void 0 : y.chatProvider) === "local" && Re() && !f && !le.get(je);
|
|
1051
|
+
if (V(ue), ue && F.push("The in-browser chat model needs a lot of memory and often makes phone browsers restart the page, so it is not loaded automatically here. Pick a cloud chat provider in Settings (recommended), or load it anyway."), O(F), ue) {
|
|
1052
|
+
B.current = async function* () {
|
|
1053
|
+
throw new Error('The in-browser chat model is not loaded on phones by default. Choose a cloud chat provider in Settings, or press "Load it anyway".');
|
|
1054
|
+
}, p(M), R("off"), a(!1);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
if ((y == null ? void 0 : y.chatProvider) === "local" && f) {
|
|
1058
|
+
B.current = async function* () {
|
|
1059
|
+
throw new Error('The in-browser chat model is switched off because this page kept restarting while loading. Choose a cloud chat provider in Settings, or use "Retry full load".');
|
|
1060
|
+
}, p(M), a(!1);
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
if ((y == null ? void 0 : y.chatProvider) === "local") {
|
|
1064
|
+
a(!0), i("Using SmolLM2-360M-Instruct locally in your browser — slow and simple; pick a cloud model in Settings for better answers.");
|
|
1065
|
+
const Q = () => {
|
|
1066
|
+
R("loading"), ce("chat model: downloading");
|
|
1067
|
+
let he = -1;
|
|
1068
|
+
const te = new Worker(new URL(
|
|
897
1069
|
/* @vite-ignore */
|
|
898
|
-
"./assets/llmWorker-
|
|
1070
|
+
"./assets/llmWorker-CmV-b4uq.js",
|
|
899
1071
|
import.meta.url
|
|
900
1072
|
), { type: "module" });
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
1073
|
+
W.current = te, te.onmessage = (re) => {
|
|
1074
|
+
if (re.data.type === "progress") {
|
|
1075
|
+
const pe = re.data.progress ?? 0;
|
|
1076
|
+
r(pe), pe >= 0.98 ? ce("chat model: downloaded, creating the model session (the memory peak)") : Math.floor(pe * 4) !== he && (he = Math.floor(pe * 4), ce(`chat model: downloading (${he * 25}%+)`));
|
|
1077
|
+
} else re.data.type === "ready" ? (ce("chat model: ready"), r(1), B.current = async function* (pe, Ie, be) {
|
|
1078
|
+
const { stream: Le } = At(te, Ie, be);
|
|
1079
|
+
yield* Le();
|
|
1080
|
+
}, R("ready"), a(!1)) : re.data.type === "error" && (R("error"), a(!1));
|
|
1081
|
+
}, te.onerror = () => {
|
|
1082
|
+
R("error"), a(!1);
|
|
1083
|
+
}, te.postMessage({ type: "init", modelProxyUrl: `${e}/models/` });
|
|
1084
|
+
};
|
|
1085
|
+
p(M), Tt() ? (R("waiting"), ce("waiting for the speech models"), l.current = Q) : Q();
|
|
1086
|
+
return;
|
|
915
1087
|
}
|
|
1088
|
+
y != null && y.hasApiKey ? B.current = async function* (Q, he, te) {
|
|
1089
|
+
const { stream: re } = await St(he, te, `${e}/chat`);
|
|
1090
|
+
yield* re();
|
|
1091
|
+
} : B.current = async function* () {
|
|
1092
|
+
throw new Error("The chat model is not configured yet — open Settings and choose a provider.");
|
|
1093
|
+
}, p(M), a(!1);
|
|
916
1094
|
}
|
|
917
|
-
return
|
|
918
|
-
var
|
|
919
|
-
|
|
1095
|
+
return k(), () => {
|
|
1096
|
+
var y;
|
|
1097
|
+
P = !0, l.current = null, (y = W.current) == null || y.terminate(), W.current = null;
|
|
920
1098
|
};
|
|
921
1099
|
}, [e, w]);
|
|
922
|
-
const
|
|
923
|
-
processInput: async function* (
|
|
924
|
-
|
|
1100
|
+
const X = gt({
|
|
1101
|
+
processInput: async function* (P, k, y) {
|
|
1102
|
+
B.current && (yield* B.current(P, k, y));
|
|
925
1103
|
},
|
|
926
|
-
...
|
|
927
|
-
...
|
|
1104
|
+
...s ? { systemPrompt: s } : {},
|
|
1105
|
+
...c
|
|
928
1106
|
});
|
|
929
1107
|
j(() => {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1108
|
+
x(c);
|
|
1109
|
+
}, [c]), j(() => {
|
|
1110
|
+
if (l.current && z === c && !X.loading) {
|
|
1111
|
+
const P = l.current;
|
|
1112
|
+
l.current = null, P();
|
|
1113
|
+
}
|
|
1114
|
+
}, [z, c, X.loading]);
|
|
1115
|
+
const oe = X.loading || o;
|
|
1116
|
+
j(() => {
|
|
1117
|
+
u && !oe && (ce("ready"), le.set(Te, { attempts: f ? b.attempts : 0, at: Date.now(), done: !0, safe: f }));
|
|
1118
|
+
}, [u, oe, f, b.attempts]);
|
|
1119
|
+
const ee = Ee(() => {
|
|
1120
|
+
le.set(Te, { attempts: 0, at: Date.now(), done: !0, safe: !1 }), window.location.reload();
|
|
1121
|
+
}, []);
|
|
1122
|
+
j(() => {
|
|
1123
|
+
let P = !1;
|
|
1124
|
+
async function k() {
|
|
1125
|
+
const M = {};
|
|
1126
|
+
typeof performance < "u" && performance.memory && (M.browser = performance.memory.usedJSHeapSize);
|
|
934
1127
|
try {
|
|
935
|
-
const
|
|
936
|
-
|
|
1128
|
+
const F = await fetch(`${e}/stats`);
|
|
1129
|
+
F.ok && (M.server = (await F.json()).rss);
|
|
937
1130
|
} catch {
|
|
938
1131
|
}
|
|
939
|
-
|
|
1132
|
+
P || h(M);
|
|
940
1133
|
}
|
|
941
|
-
|
|
942
|
-
const
|
|
1134
|
+
k();
|
|
1135
|
+
const y = setInterval(k, 3e3);
|
|
943
1136
|
return () => {
|
|
944
|
-
|
|
1137
|
+
P = !0, clearInterval(y);
|
|
945
1138
|
};
|
|
946
1139
|
}, [e]);
|
|
947
|
-
const { micEnabled:
|
|
1140
|
+
const { micEnabled: G, stopListening: J } = X;
|
|
948
1141
|
return j(() => {
|
|
949
|
-
if (!
|
|
950
|
-
const
|
|
951
|
-
|
|
1142
|
+
if (!G) return;
|
|
1143
|
+
const P = (k) => {
|
|
1144
|
+
k.key === "Escape" && J();
|
|
952
1145
|
};
|
|
953
|
-
return window.addEventListener("keydown",
|
|
954
|
-
}, [
|
|
955
|
-
chat:
|
|
956
|
-
info:
|
|
957
|
-
config:
|
|
958
|
-
memory:
|
|
1146
|
+
return window.addEventListener("keydown", P), () => window.removeEventListener("keydown", P);
|
|
1147
|
+
}, [G, J]), {
|
|
1148
|
+
chat: X,
|
|
1149
|
+
info: u,
|
|
1150
|
+
config: c,
|
|
1151
|
+
memory: v,
|
|
959
1152
|
llmProgress: n,
|
|
960
|
-
note:
|
|
961
|
-
loading:
|
|
962
|
-
missing: (
|
|
963
|
-
|
|
1153
|
+
note: t,
|
|
1154
|
+
loading: oe,
|
|
1155
|
+
missing: (u == null ? void 0 : u.missing) ?? [],
|
|
1156
|
+
warnings: K,
|
|
1157
|
+
llmPhase: q,
|
|
1158
|
+
localLlmBlocked: D,
|
|
1159
|
+
loadLocalModelAnyway: de,
|
|
1160
|
+
safeMode: f,
|
|
1161
|
+
retryFullLoad: ee,
|
|
1162
|
+
reload: ne
|
|
964
1163
|
};
|
|
965
1164
|
}
|
|
966
|
-
const
|
|
1165
|
+
const Lt = ["q8", "q4", "q4f16", "fp16", "fp32"], fe = "Local · free", ie = "Cloud", Ye = [
|
|
967
1166
|
{
|
|
968
1167
|
group: "Chat model",
|
|
969
1168
|
fields: [
|
|
@@ -975,12 +1174,12 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
975
1174
|
default: "local",
|
|
976
1175
|
options: [
|
|
977
1176
|
["", "Not configured"],
|
|
978
|
-
["local", "In-browser model (SmolLM2, no key, ~200 MB) — slow and simple",
|
|
979
|
-
["openai-compatible", "OpenAI-compatible server (Ollama, LM Studio, vLLM, on-premise…)",
|
|
980
|
-
["openrouter", "OpenRouter",
|
|
981
|
-
["openai", "OpenAI",
|
|
982
|
-
["anthropic", "Anthropic (Claude)",
|
|
983
|
-
["huggingface", "Hugging Face",
|
|
1177
|
+
["local", "In-browser model (SmolLM2, no key, ~200 MB) — slow and simple", fe],
|
|
1178
|
+
["openai-compatible", "OpenAI-compatible server (Ollama, LM Studio, vLLM, on-premise…)", fe],
|
|
1179
|
+
["openrouter", "OpenRouter", ie],
|
|
1180
|
+
["openai", "OpenAI", ie],
|
|
1181
|
+
["anthropic", "Anthropic (Claude)", ie],
|
|
1182
|
+
["huggingface", "Hugging Face", ie]
|
|
984
1183
|
]
|
|
985
1184
|
},
|
|
986
1185
|
{
|
|
@@ -1094,9 +1293,9 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
1094
1293
|
env: "STT_PROVIDER",
|
|
1095
1294
|
default: "whisper",
|
|
1096
1295
|
options: [
|
|
1097
|
-
["whisper", "Whisper in the browser",
|
|
1098
|
-
["openai", "OpenAI transcription",
|
|
1099
|
-
["elevenlabs", "ElevenLabs Scribe",
|
|
1296
|
+
["whisper", "Whisper in the browser", fe],
|
|
1297
|
+
["openai", "OpenAI transcription", ie],
|
|
1298
|
+
["elevenlabs", "ElevenLabs Scribe", ie]
|
|
1100
1299
|
]
|
|
1101
1300
|
},
|
|
1102
1301
|
{
|
|
@@ -1191,11 +1390,12 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
1191
1390
|
env: "TTS_PROVIDER",
|
|
1192
1391
|
default: "kokoro",
|
|
1193
1392
|
options: [
|
|
1194
|
-
["kokoro", "Kokoro in the browser",
|
|
1195
|
-
["server-kokoro", "Kokoro on the server (needs: npm install kokoro-js)",
|
|
1196
|
-
["webspeech", "Browser Web Speech API (built-in voices)",
|
|
1197
|
-
["openai", "OpenAI
|
|
1198
|
-
["
|
|
1393
|
+
["kokoro", "Kokoro in the browser", fe],
|
|
1394
|
+
["server-kokoro", "Kokoro on the server (needs: npm install kokoro-js)", fe],
|
|
1395
|
+
["webspeech", "Browser Web Speech API (built-in voices)", fe],
|
|
1396
|
+
["openai-compatible", "OpenAI-compatible server (Piper, LocalAI, Kokoro-FastAPI… any /audio/speech)", fe],
|
|
1397
|
+
["openai", "OpenAI TTS", ie],
|
|
1398
|
+
["elevenlabs", "ElevenLabs", ie]
|
|
1199
1399
|
]
|
|
1200
1400
|
},
|
|
1201
1401
|
{
|
|
@@ -1223,7 +1423,7 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
1223
1423
|
env: "KOKORO_DTYPE",
|
|
1224
1424
|
default: "fp32",
|
|
1225
1425
|
showWhen: { ttsProvider: ["kokoro", "server-kokoro"] },
|
|
1226
|
-
options:
|
|
1426
|
+
options: Lt.map((e) => [e, e]),
|
|
1227
1427
|
hint: "q4/q8 are promoted to fp32 on WebGPU"
|
|
1228
1428
|
},
|
|
1229
1429
|
{
|
|
@@ -1262,6 +1462,52 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
1262
1462
|
showWhen: { ttsProvider: "openai" },
|
|
1263
1463
|
suggestions: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"]
|
|
1264
1464
|
},
|
|
1465
|
+
{
|
|
1466
|
+
key: "ttsCompatBaseUrl",
|
|
1467
|
+
label: "TTS server base URL",
|
|
1468
|
+
type: "text",
|
|
1469
|
+
env: "TTS_COMPAT_BASE_URL",
|
|
1470
|
+
default: "http://localhost:8000/v1",
|
|
1471
|
+
showWhen: { ttsProvider: "openai-compatible" },
|
|
1472
|
+
suggestions: ["http://localhost:8000/v1", "http://localhost:8080/v1", "http://localhost:8880/v1"],
|
|
1473
|
+
hint: "Must serve POST /audio/speech (the OpenAI text-to-speech protocol). From inside Docker use host.docker.internal instead of localhost."
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
key: "ttsCompatModel",
|
|
1477
|
+
label: "TTS model name",
|
|
1478
|
+
type: "text",
|
|
1479
|
+
env: "TTS_COMPAT_MODEL",
|
|
1480
|
+
default: "tts-1",
|
|
1481
|
+
showWhen: { ttsProvider: "openai-compatible" },
|
|
1482
|
+
hint: "Exactly as the server names it — e.g. tts-1, or a Piper voice such as en_US-lessac-medium"
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
key: "ttsCompatVoice",
|
|
1486
|
+
label: "TTS voice",
|
|
1487
|
+
type: "text",
|
|
1488
|
+
env: "TTS_COMPAT_VOICE",
|
|
1489
|
+
default: "alloy",
|
|
1490
|
+
showWhen: { ttsProvider: "openai-compatible" },
|
|
1491
|
+
hint: "Voice name the server understands (alloy, af_bella, a Piper voice…)"
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
key: "ttsCompatFormat",
|
|
1495
|
+
label: "Audio format",
|
|
1496
|
+
type: "select",
|
|
1497
|
+
env: "TTS_COMPAT_FORMAT",
|
|
1498
|
+
default: "",
|
|
1499
|
+
showWhen: { ttsProvider: "openai-compatible" },
|
|
1500
|
+
options: [["", "Server default"], ["mp3", "mp3"], ["wav", "wav (no encoding delay)"]]
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
key: "ttsCompatApiKey",
|
|
1504
|
+
label: "TTS API key (optional)",
|
|
1505
|
+
type: "password",
|
|
1506
|
+
secret: !0,
|
|
1507
|
+
env: "TTS_COMPAT_API_KEY",
|
|
1508
|
+
showWhen: { ttsProvider: "openai-compatible" },
|
|
1509
|
+
hint: "Leave empty if the server needs no key (most local servers)."
|
|
1510
|
+
},
|
|
1265
1511
|
{
|
|
1266
1512
|
key: "elevenlabsVoiceId",
|
|
1267
1513
|
label: "ElevenLabs voice ID",
|
|
@@ -1310,17 +1556,17 @@ const it = ["q8", "q4", "q4f16", "fp16", "fp32"], re = "Local · free", Q = "Clo
|
|
|
1310
1556
|
}
|
|
1311
1557
|
]
|
|
1312
1558
|
}
|
|
1313
|
-
],
|
|
1314
|
-
Object.fromEntries(
|
|
1315
|
-
|
|
1316
|
-
function
|
|
1317
|
-
const
|
|
1318
|
-
return e.showWhenAny ? e.showWhenAny.some(
|
|
1559
|
+
], Je = Ye.flatMap((e) => e.fields);
|
|
1560
|
+
Object.fromEntries(Je.map((e) => [e.key, e]));
|
|
1561
|
+
Je.filter((e) => e.secret).map((e) => e.key);
|
|
1562
|
+
function Mt(e, s) {
|
|
1563
|
+
const o = (a) => Object.entries(a).every(([n, r]) => (Array.isArray(r) ? r : [r]).includes(s[n]));
|
|
1564
|
+
return e.showWhenAny ? e.showWhenAny.some(o) : e.showWhen ? o(e.showWhen) : !0;
|
|
1319
1565
|
}
|
|
1320
|
-
function
|
|
1321
|
-
const
|
|
1322
|
-
n ||
|
|
1323
|
-
const
|
|
1566
|
+
function Ot(e, s = {}) {
|
|
1567
|
+
const o = [], a = (t) => !!s[t], n = e.chatProvider;
|
|
1568
|
+
n || o.push({ key: "chatProvider", message: "No chat model provider is configured.", scope: "chat" }), n === "openai-compatible" && (e.compatBaseUrl || o.push({ key: "compatBaseUrl", message: "The OpenAI-compatible server URL is missing.", scope: "chat" }), e.compatModel || o.push({ key: "compatModel", message: "The model name for the OpenAI-compatible server is missing.", scope: "chat" })), e.ttsProvider === "openai-compatible" && !e.ttsCompatBaseUrl && o.push({ key: "ttsCompatBaseUrl", message: "The OpenAI-compatible text-to-speech server URL is missing.", scope: "tts" });
|
|
1569
|
+
const r = [
|
|
1324
1570
|
{ key: "openrouterApiKey", name: "OpenRouter API key", uses: [n === "openrouter" && ["chat", "chat"]] },
|
|
1325
1571
|
{ key: "anthropicApiKey", name: "Anthropic API key", uses: [n === "anthropic" && ["chat", "chat"]] },
|
|
1326
1572
|
{ key: "huggingfaceApiKey", name: "Hugging Face token", uses: [n === "huggingface" && ["chat", "chat"]] },
|
|
@@ -1334,181 +1580,183 @@ function lt(e, a = {}) {
|
|
|
1334
1580
|
e.ttsProvider === "elevenlabs" && ["text-to-speech", "tts"]
|
|
1335
1581
|
] }
|
|
1336
1582
|
];
|
|
1337
|
-
for (const { key:
|
|
1338
|
-
const p =
|
|
1339
|
-
if (!p.length ||
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1583
|
+
for (const { key: t, name: i, uses: c } of r) {
|
|
1584
|
+
const p = c.filter(Boolean);
|
|
1585
|
+
if (!p.length || a(t)) continue;
|
|
1586
|
+
const u = p.some((v) => v[1] === "chat") ? "chat" : p[0][1], m = p.length === 1 && p[0][0] === "chat" ? `${i} is missing.` : `${i} (for ${p.map((v) => v[0]).join(", ").replace(/, ([^,]*)$/, " and $1")}) is missing.`;
|
|
1587
|
+
o.push({ key: t, message: m, scope: u });
|
|
1342
1588
|
}
|
|
1343
|
-
return
|
|
1589
|
+
return o;
|
|
1344
1590
|
}
|
|
1345
|
-
function
|
|
1346
|
-
const [
|
|
1591
|
+
function Nt({ apiBase: e = "/api", onSaved: s, onClose: o }) {
|
|
1592
|
+
const [a, n] = N(null), [r, t] = N({}), [i, c] = N(null), [p, u] = N(!1), m = U(null), v = Ee(async () => {
|
|
1347
1593
|
try {
|
|
1348
|
-
const
|
|
1349
|
-
if (!
|
|
1350
|
-
n(await
|
|
1351
|
-
} catch (
|
|
1352
|
-
|
|
1594
|
+
const l = await fetch(`${e}/settings`);
|
|
1595
|
+
if (!l.ok) throw new Error(await l.text());
|
|
1596
|
+
n(await l.json());
|
|
1597
|
+
} catch (l) {
|
|
1598
|
+
c({ kind: "error", text: `Could not load settings: ${l.message}` });
|
|
1353
1599
|
}
|
|
1354
1600
|
}, [e]);
|
|
1355
1601
|
if (j(() => {
|
|
1356
|
-
|
|
1357
|
-
}, [
|
|
1358
|
-
const h = { ...
|
|
1359
|
-
for (const [
|
|
1360
|
-
const
|
|
1361
|
-
async function
|
|
1362
|
-
var
|
|
1363
|
-
|
|
1602
|
+
v();
|
|
1603
|
+
}, [v]), !a) return /* @__PURE__ */ d("section", { className: "tz-va__card", children: i ? i.text : "Loading settings…" });
|
|
1604
|
+
const h = { ...a.values, ...Object.fromEntries(Object.entries(r).filter(([, l]) => l !== null)) }, w = { ...a.secretsSet };
|
|
1605
|
+
for (const [l, A] of Object.entries(r)) l in w && (w[l] = A === null ? !1 : A ? !0 : w[l]);
|
|
1606
|
+
const S = Ot(h, w), K = new Set(S.map((l) => l.key)), O = Object.keys(r).length > 0, z = (l, A) => t((b) => ({ ...b, [l]: A }));
|
|
1607
|
+
async function x(l, A) {
|
|
1608
|
+
var b;
|
|
1609
|
+
u(!0);
|
|
1364
1610
|
try {
|
|
1365
|
-
const
|
|
1611
|
+
const L = await fetch(`${e}/settings`, {
|
|
1366
1612
|
method: "PUT",
|
|
1367
1613
|
headers: { "Content-Type": "application/json" },
|
|
1368
|
-
body: JSON.stringify(
|
|
1614
|
+
body: JSON.stringify(l)
|
|
1369
1615
|
});
|
|
1370
|
-
if (!
|
|
1371
|
-
const
|
|
1372
|
-
n(
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1375
|
-
} catch (
|
|
1376
|
-
|
|
1616
|
+
if (!L.ok) throw new Error(await L.text());
|
|
1617
|
+
const f = await L.json();
|
|
1618
|
+
n(f), t({});
|
|
1619
|
+
const D = (b = f.ignored) != null && b.length ? ` Ignored unknown/invalid keys: ${f.ignored.join(", ")}.` : "";
|
|
1620
|
+
c({ kind: "ok", text: A + D }), s == null || s(f);
|
|
1621
|
+
} catch (L) {
|
|
1622
|
+
c({ kind: "error", text: L.message });
|
|
1377
1623
|
} finally {
|
|
1378
|
-
|
|
1624
|
+
u(!1);
|
|
1379
1625
|
}
|
|
1380
1626
|
}
|
|
1381
|
-
async function
|
|
1627
|
+
async function q() {
|
|
1382
1628
|
try {
|
|
1383
|
-
const
|
|
1384
|
-
if (!
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
} catch (
|
|
1388
|
-
|
|
1629
|
+
const l = await fetch(`${e}/settings/export`);
|
|
1630
|
+
if (!l.ok) throw new Error(await l.text());
|
|
1631
|
+
const A = new Blob([JSON.stringify(await l.json(), null, 2)], { type: "application/json" }), b = document.createElement("a");
|
|
1632
|
+
b.href = URL.createObjectURL(A), b.download = "tz-voice-chat-settings.json", b.click(), URL.revokeObjectURL(b.href), c({ kind: "ok", text: "Exported. The file contains your API keys — keep it private." });
|
|
1633
|
+
} catch (l) {
|
|
1634
|
+
c({ kind: "error", text: `Export failed: ${l.message}` });
|
|
1389
1635
|
}
|
|
1390
1636
|
}
|
|
1391
|
-
async function
|
|
1392
|
-
var
|
|
1393
|
-
const
|
|
1394
|
-
if (
|
|
1637
|
+
async function R(l) {
|
|
1638
|
+
var b;
|
|
1639
|
+
const A = (b = l.target.files) == null ? void 0 : b[0];
|
|
1640
|
+
if (l.target.value = "", !!A)
|
|
1395
1641
|
try {
|
|
1396
|
-
const
|
|
1397
|
-
if (!
|
|
1398
|
-
await
|
|
1399
|
-
} catch (
|
|
1400
|
-
|
|
1642
|
+
const L = JSON.parse(await A.text()), f = L && typeof L.settings == "object" ? L.settings : L;
|
|
1643
|
+
if (!f || typeof f != "object" || Array.isArray(f)) throw new Error("not a settings object");
|
|
1644
|
+
await x({ settings: f }, `Imported ${A.name} and applied it.`);
|
|
1645
|
+
} catch (L) {
|
|
1646
|
+
c({ kind: "error", text: `Import failed: ${L.message}` });
|
|
1401
1647
|
}
|
|
1402
1648
|
}
|
|
1403
|
-
function
|
|
1404
|
-
const
|
|
1405
|
-
for (const [
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1649
|
+
function B(l) {
|
|
1650
|
+
const A = [];
|
|
1651
|
+
for (const [b, L, f] of l) {
|
|
1652
|
+
const D = A[A.length - 1], V = /* @__PURE__ */ d("option", { value: b, children: L }, b);
|
|
1653
|
+
f ? D && D.group === f ? D.items.push(V) : A.push({ group: f, items: [V] }) : A.push(V);
|
|
1408
1654
|
}
|
|
1409
|
-
return
|
|
1655
|
+
return A.map((b) => b.group ? /* @__PURE__ */ d("optgroup", { label: b.group, children: b.items }, b.group) : b);
|
|
1410
1656
|
}
|
|
1411
|
-
function
|
|
1412
|
-
const
|
|
1413
|
-
let
|
|
1414
|
-
if (
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
h[
|
|
1657
|
+
function W(l) {
|
|
1658
|
+
const A = `tz-va-set-${l.key}`, b = K.has(l.key);
|
|
1659
|
+
let L;
|
|
1660
|
+
if (l.type === "select")
|
|
1661
|
+
L = /* @__PURE__ */ _("select", { id: A, value: h[l.key] ?? "", onChange: (f) => z(l.key, f.target.value), children: [
|
|
1662
|
+
B(l.options),
|
|
1663
|
+
l.allowCustom && h[l.key] && !l.options.some(([f]) => f === h[l.key]) && /* @__PURE__ */ _("option", { value: h[l.key], children: [
|
|
1664
|
+
h[l.key],
|
|
1419
1665
|
" (custom)"
|
|
1420
1666
|
] })
|
|
1421
1667
|
] });
|
|
1422
|
-
else if (
|
|
1423
|
-
|
|
1424
|
-
else if (
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
/* @__PURE__ */
|
|
1668
|
+
else if (l.type === "textarea")
|
|
1669
|
+
L = /* @__PURE__ */ d("textarea", { id: A, rows: 4, value: h[l.key] ?? "", onChange: (f) => z(l.key, f.target.value) });
|
|
1670
|
+
else if (l.type === "password") {
|
|
1671
|
+
const f = l.key in r, D = r[l.key] === null ? "Will be cleared on save" : a.secretsSet[l.key] ? "Saved — type to replace" : "Not set";
|
|
1672
|
+
L = /* @__PURE__ */ _("span", { className: "tz-va__secret", children: [
|
|
1673
|
+
/* @__PURE__ */ d(
|
|
1428
1674
|
"input",
|
|
1429
1675
|
{
|
|
1430
|
-
id:
|
|
1676
|
+
id: A,
|
|
1431
1677
|
type: "password",
|
|
1432
1678
|
autoComplete: "off",
|
|
1433
|
-
value:
|
|
1434
|
-
placeholder:
|
|
1435
|
-
onChange: (
|
|
1679
|
+
value: r[l.key] ?? "",
|
|
1680
|
+
placeholder: D,
|
|
1681
|
+
onChange: (V) => z(l.key, V.target.value)
|
|
1436
1682
|
}
|
|
1437
1683
|
),
|
|
1438
|
-
(
|
|
1684
|
+
(a.secretsSet[l.key] || f) && /* @__PURE__ */ d(
|
|
1439
1685
|
"button",
|
|
1440
1686
|
{
|
|
1441
1687
|
type: "button",
|
|
1442
1688
|
className: "tz-va__link",
|
|
1443
|
-
onClick: () =>
|
|
1444
|
-
const
|
|
1445
|
-
return delete
|
|
1446
|
-
}) :
|
|
1447
|
-
children:
|
|
1689
|
+
onClick: () => f ? t((V) => {
|
|
1690
|
+
const ne = { ...V };
|
|
1691
|
+
return delete ne[l.key], ne;
|
|
1692
|
+
}) : z(l.key, null),
|
|
1693
|
+
children: f ? "Undo" : "Clear"
|
|
1448
1694
|
}
|
|
1449
1695
|
)
|
|
1450
1696
|
] });
|
|
1451
1697
|
} else
|
|
1452
|
-
|
|
1453
|
-
/* @__PURE__ */
|
|
1698
|
+
L = /* @__PURE__ */ _(Ce, { children: [
|
|
1699
|
+
/* @__PURE__ */ d(
|
|
1454
1700
|
"input",
|
|
1455
1701
|
{
|
|
1456
|
-
id:
|
|
1457
|
-
type:
|
|
1458
|
-
step:
|
|
1459
|
-
list:
|
|
1460
|
-
value: h[
|
|
1461
|
-
onChange: (
|
|
1702
|
+
id: A,
|
|
1703
|
+
type: l.type === "number" ? "number" : "text",
|
|
1704
|
+
step: l.type === "number" ? "any" : void 0,
|
|
1705
|
+
list: l.suggestions ? `${A}-list` : void 0,
|
|
1706
|
+
value: h[l.key] ?? "",
|
|
1707
|
+
onChange: (f) => z(l.key, f.target.value)
|
|
1462
1708
|
}
|
|
1463
1709
|
),
|
|
1464
|
-
|
|
1710
|
+
l.suggestions && /* @__PURE__ */ d("datalist", { id: `${A}-list`, children: l.suggestions.map((f) => /* @__PURE__ */ d("option", { value: f }, f)) })
|
|
1465
1711
|
] });
|
|
1466
|
-
return /* @__PURE__ */ _("div", { className: `tz-va__field${
|
|
1467
|
-
/* @__PURE__ */ _("label", { htmlFor:
|
|
1468
|
-
|
|
1469
|
-
|
|
1712
|
+
return /* @__PURE__ */ _("div", { className: `tz-va__field${b ? " tz-va__field--missing" : ""}`, children: [
|
|
1713
|
+
/* @__PURE__ */ _("label", { htmlFor: A, children: [
|
|
1714
|
+
l.label,
|
|
1715
|
+
b && /* @__PURE__ */ d("em", { children: " — required" })
|
|
1470
1716
|
] }),
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
] },
|
|
1717
|
+
L,
|
|
1718
|
+
l.hint && /* @__PURE__ */ d("small", { children: l.hint })
|
|
1719
|
+
] }, l.key);
|
|
1474
1720
|
}
|
|
1475
|
-
return /* @__PURE__ */ _(
|
|
1721
|
+
return /* @__PURE__ */ _(Ce, { children: [
|
|
1476
1722
|
/* @__PURE__ */ _("section", { className: "tz-va__card tz-va__settings", children: [
|
|
1477
|
-
|
|
1478
|
-
/* @__PURE__ */
|
|
1723
|
+
S.length > 0 && /* @__PURE__ */ _("div", { className: "tz-va__notice", role: "alert", children: [
|
|
1724
|
+
/* @__PURE__ */ d("strong", { children: "Setup incomplete:" }),
|
|
1479
1725
|
" ",
|
|
1480
|
-
|
|
1726
|
+
S.map((l) => l.message).join(" ")
|
|
1481
1727
|
] }),
|
|
1482
|
-
|
|
1483
|
-
/* @__PURE__ */
|
|
1484
|
-
|
|
1485
|
-
] },
|
|
1728
|
+
Ye.map((l) => /* @__PURE__ */ _("fieldset", { children: [
|
|
1729
|
+
/* @__PURE__ */ d("legend", { children: l.group }),
|
|
1730
|
+
l.fields.filter((A) => Mt(A, h)).map(W)
|
|
1731
|
+
] }, l.group)),
|
|
1486
1732
|
/* @__PURE__ */ _("p", { className: "tz-va__note", children: [
|
|
1487
1733
|
"Saved to ",
|
|
1488
|
-
/* @__PURE__ */
|
|
1734
|
+
/* @__PURE__ */ d("code", { children: a.file }),
|
|
1489
1735
|
" and applied immediately. Environment variables provide the initial values."
|
|
1490
1736
|
] }),
|
|
1491
1737
|
/* @__PURE__ */ _("div", { className: "tz-va__actions", children: [
|
|
1492
|
-
/* @__PURE__ */
|
|
1493
|
-
/* @__PURE__ */
|
|
1494
|
-
/* @__PURE__ */
|
|
1495
|
-
/* @__PURE__ */
|
|
1496
|
-
var
|
|
1497
|
-
return (
|
|
1738
|
+
/* @__PURE__ */ d("button", { type: "button", disabled: p || !O, onClick: () => x(r, "Settings saved and applied."), children: "Save" }),
|
|
1739
|
+
/* @__PURE__ */ d("button", { type: "button", className: "tz-va__secondary", disabled: !O, onClick: () => t({}), children: "Discard" }),
|
|
1740
|
+
/* @__PURE__ */ d("span", { className: "tz-va__spacer" }),
|
|
1741
|
+
/* @__PURE__ */ d("button", { type: "button", className: "tz-va__secondary", onClick: () => {
|
|
1742
|
+
var l;
|
|
1743
|
+
return (l = m.current) == null ? void 0 : l.click();
|
|
1498
1744
|
}, children: "Import…" }),
|
|
1499
|
-
/* @__PURE__ */
|
|
1500
|
-
/* @__PURE__ */
|
|
1745
|
+
/* @__PURE__ */ d("button", { type: "button", className: "tz-va__secondary", onClick: q, children: "Export" }),
|
|
1746
|
+
/* @__PURE__ */ d("input", { ref: m, type: "file", accept: "application/json,.json", hidden: !0, onChange: R })
|
|
1501
1747
|
] }),
|
|
1502
|
-
|
|
1748
|
+
i && /* @__PURE__ */ d("p", { className: `tz-va__status tz-va__status--${i.kind}`, children: i.text })
|
|
1503
1749
|
] }),
|
|
1504
|
-
|
|
1750
|
+
o && /* @__PURE__ */ d("div", { className: "tz-va__actions", children: /* @__PURE__ */ d("button", { type: "button", className: "tz-va__secondary", onClick: o, children: "← Back to chat" }) })
|
|
1505
1751
|
] });
|
|
1506
1752
|
}
|
|
1507
|
-
const
|
|
1508
|
-
function
|
|
1753
|
+
const Qe = (e, s) => e === "webgpu" && (s === "q4" || s === "q8") ? "fp32" : s, De = (e) => e >= 1e3 ? `${(e / 1e3).toFixed(1)} s` : `${e} ms`, Ge = (e) => `${(e / 1048576).toFixed(0)} MB`;
|
|
1754
|
+
function xt(e) {
|
|
1509
1755
|
switch (e.ttsProvider) {
|
|
1510
1756
|
case "openai":
|
|
1511
1757
|
return `OpenAI · ${e.openaiTtsModel} · ${e.ttsVoice}`;
|
|
1758
|
+
case "openai-compatible":
|
|
1759
|
+
return `OpenAI-compatible server · ${e.ttsCompatModel} · ${e.ttsVoice}`;
|
|
1512
1760
|
case "elevenlabs":
|
|
1513
1761
|
return `ElevenLabs · ${e.elevenlabsTtsModel} · ${e.ttsVoice}`;
|
|
1514
1762
|
case "webspeech":
|
|
@@ -1516,172 +1764,202 @@ function dt(e) {
|
|
|
1516
1764
|
case "server-kokoro":
|
|
1517
1765
|
return `Kokoro (server) · ${e.ttsVoice} · ${e.kokoroDtype}/${e.kokoroDevice}`;
|
|
1518
1766
|
default:
|
|
1519
|
-
return `Kokoro (browser) · ${e.ttsVoice} · ${
|
|
1767
|
+
return `Kokoro (browser) · ${e.ttsVoice} · ${Qe(e.kokoroBrowserDevice, e.kokoroDtype)}/${e.kokoroBrowserDevice}`;
|
|
1520
1768
|
}
|
|
1521
1769
|
}
|
|
1522
|
-
const
|
|
1523
|
-
function
|
|
1770
|
+
const zt = (e) => e.replace(/\b\w/g, (s) => s.toUpperCase());
|
|
1771
|
+
function Dt({
|
|
1524
1772
|
apiBase: e = "/api",
|
|
1525
|
-
title:
|
|
1526
|
-
showInfo:
|
|
1527
|
-
systemPrompt:
|
|
1773
|
+
title: s = "Voice Assistant",
|
|
1774
|
+
showInfo: o = !0,
|
|
1775
|
+
systemPrompt: a,
|
|
1528
1776
|
className: n = ""
|
|
1529
1777
|
} = {}) {
|
|
1530
|
-
const { chat:
|
|
1531
|
-
status:
|
|
1532
|
-
progress:
|
|
1533
|
-
error:
|
|
1534
|
-
transcript:
|
|
1535
|
-
streamingMessage:
|
|
1536
|
-
micEnabled:
|
|
1537
|
-
startListening:
|
|
1538
|
-
stopListening:
|
|
1539
|
-
submitText:
|
|
1540
|
-
liveAnalyser:
|
|
1541
|
-
devices:
|
|
1542
|
-
selectedMicId:
|
|
1543
|
-
setSelectedMicId:
|
|
1544
|
-
} =
|
|
1778
|
+
const { chat: r, info: t, config: i, memory: c, llmProgress: p, llmPhase: u, localLlmBlocked: m, loadLocalModelAnyway: v, note: h, loading: w, missing: S, warnings: K, safeMode: O, retryFullLoad: z, reload: x } = It({ apiBase: e, systemPrompt: a }), [q, R] = N("chat"), {
|
|
1779
|
+
status: B,
|
|
1780
|
+
progress: W,
|
|
1781
|
+
error: l,
|
|
1782
|
+
transcript: A,
|
|
1783
|
+
streamingMessage: b,
|
|
1784
|
+
micEnabled: L,
|
|
1785
|
+
startListening: f,
|
|
1786
|
+
stopListening: D,
|
|
1787
|
+
submitText: V,
|
|
1788
|
+
liveAnalyser: ne,
|
|
1789
|
+
devices: de,
|
|
1790
|
+
selectedMicId: X,
|
|
1791
|
+
setSelectedMicId: oe
|
|
1792
|
+
} = r, [ee, G] = N(""), J = U(null);
|
|
1545
1793
|
j(() => {
|
|
1546
|
-
var
|
|
1547
|
-
(
|
|
1548
|
-
}, [
|
|
1549
|
-
const
|
|
1550
|
-
["STT",
|
|
1551
|
-
["TTS",
|
|
1552
|
-
["Chat",
|
|
1794
|
+
var k;
|
|
1795
|
+
(k = J.current) == null || k.scrollIntoView({ behavior: b !== null ? "auto" : "smooth" });
|
|
1796
|
+
}, [A, b]);
|
|
1797
|
+
const P = t && i.whisperDevice && [
|
|
1798
|
+
["STT", i.sttProvider === "none" || !r.micAvailable ? "off — no microphone on this page" : t.sttProvider === "elevenlabs" ? `ElevenLabs · ${t.elevenlabsSttModel}` : t.sttProvider === "openai" ? `OpenAI · ${t.openaiSttModel}` : `Whisper · ${(i.whisperModel || t.whisperModel).split("/").pop()} · ${Qe(i.whisperDevice, i.whisperDtype)}/${i.whisperDevice}`],
|
|
1799
|
+
["TTS", xt({ ...t, ...i })],
|
|
1800
|
+
["Chat", t.chatProvider === "local" && m ? "in-browser model not loaded on phones" : t.chatProvider === "local" && O ? "in-browser model switched off (safe mode)" : t.chatProvider === "local" ? "SmolLM2-360M-Instruct (in-browser) — slow and simple" : t.chatReady ? `${t.chatProvider} · ${t.chatModel}` : "not configured"],
|
|
1553
1801
|
["Memory", [
|
|
1554
|
-
|
|
1555
|
-
|
|
1802
|
+
c.browser != null ? `browser heap ${Ge(c.browser)}` : "browser heap n/a",
|
|
1803
|
+
c.server != null ? `server ${Ge(c.server)}` : null
|
|
1556
1804
|
].filter(Boolean).join(" · ")]
|
|
1557
1805
|
];
|
|
1558
1806
|
return /* @__PURE__ */ _("div", { className: `tz-va ${n}`.trim(), children: [
|
|
1559
1807
|
/* @__PURE__ */ _("section", { className: "tz-va__card tz-va__header", children: [
|
|
1560
|
-
/* @__PURE__ */
|
|
1808
|
+
/* @__PURE__ */ d("h1", { children: s }),
|
|
1561
1809
|
/* @__PURE__ */ _("span", { className: "tz-va__header-right", children: [
|
|
1562
|
-
/* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1810
|
+
/* @__PURE__ */ d("span", { className: `tz-va__chip tz-va__chip--${B}`, children: zt(B) }),
|
|
1811
|
+
/* @__PURE__ */ d(
|
|
1564
1812
|
"button",
|
|
1565
1813
|
{
|
|
1566
1814
|
type: "button",
|
|
1567
|
-
className: `tz-va__gear${
|
|
1815
|
+
className: `tz-va__gear${q === "settings" ? " tz-va__gear--on" : ""}`,
|
|
1568
1816
|
"aria-label": "Settings",
|
|
1569
1817
|
title: "Settings",
|
|
1570
|
-
onClick: () =>
|
|
1818
|
+
onClick: () => R((k) => k === "settings" ? "chat" : "settings"),
|
|
1571
1819
|
children: /* @__PURE__ */ _("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1572
|
-
/* @__PURE__ */
|
|
1573
|
-
/* @__PURE__ */
|
|
1820
|
+
/* @__PURE__ */ d("circle", { cx: "12", cy: "12", r: "3" }),
|
|
1821
|
+
/* @__PURE__ */ d("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h0a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h0a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v0a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })
|
|
1574
1822
|
] })
|
|
1575
1823
|
}
|
|
1576
1824
|
)
|
|
1577
1825
|
] })
|
|
1578
1826
|
] }),
|
|
1579
|
-
|
|
1827
|
+
K.length > 0 && q !== "settings" && /* @__PURE__ */ _("section", { className: "tz-va__card tz-va__notice tz-va__notice--info", role: "status", children: [
|
|
1828
|
+
/* @__PURE__ */ d("div", { children: K.map((k, y) => /* @__PURE__ */ d("p", { children: k }, y)) }),
|
|
1829
|
+
O && /* @__PURE__ */ d("button", { type: "button", onClick: z, children: "Retry full load" }),
|
|
1830
|
+
m && /* @__PURE__ */ d("button", { type: "button", onClick: v, children: "Load it anyway" })
|
|
1831
|
+
] }),
|
|
1832
|
+
S.length > 0 && q !== "settings" && /* @__PURE__ */ _("section", { className: "tz-va__card tz-va__notice", role: "alert", children: [
|
|
1580
1833
|
/* @__PURE__ */ _("div", { children: [
|
|
1581
|
-
/* @__PURE__ */
|
|
1834
|
+
/* @__PURE__ */ d("strong", { children: "Setup incomplete." }),
|
|
1582
1835
|
" ",
|
|
1583
|
-
|
|
1836
|
+
S.map((k) => k.message).join(" ")
|
|
1584
1837
|
] }),
|
|
1585
|
-
/* @__PURE__ */
|
|
1838
|
+
/* @__PURE__ */ d("button", { type: "button", onClick: () => R("settings"), children: "Open Settings" })
|
|
1586
1839
|
] }),
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
/* @__PURE__ */
|
|
1591
|
-
] },
|
|
1840
|
+
q === "settings" ? /* @__PURE__ */ d(Nt, { apiBase: e, onSaved: x, onClose: () => R("chat") }) : /* @__PURE__ */ _(Ce, { children: [
|
|
1841
|
+
o && P && /* @__PURE__ */ d("section", { className: "tz-va__card tz-va__info", children: P.map(([k, y]) => /* @__PURE__ */ _("div", { className: "tz-va__info-row", children: [
|
|
1842
|
+
/* @__PURE__ */ d("span", { className: "tz-va__info-label", children: k }),
|
|
1843
|
+
/* @__PURE__ */ d("span", { className: "tz-va__info-value", children: y })
|
|
1844
|
+
] }, k)) }),
|
|
1592
1845
|
/* @__PURE__ */ _("section", { className: "tz-va__card", children: [
|
|
1593
|
-
|
|
1594
|
-
|
|
1846
|
+
w && /* @__PURE__ */ _("div", { className: "tz-va__progress", children: [
|
|
1847
|
+
i.sttProvider === "whisper" && r.micAvailable && /* @__PURE__ */ _("label", { children: [
|
|
1595
1848
|
"Whisper STT",
|
|
1596
|
-
/* @__PURE__ */
|
|
1849
|
+
/* @__PURE__ */ d("div", { className: "tz-va__bar", children: /* @__PURE__ */ d("span", { style: { width: `${W.whisper * 100}%` } }) })
|
|
1597
1850
|
] }),
|
|
1598
1851
|
/* @__PURE__ */ _("label", { children: [
|
|
1599
1852
|
"Kokoro TTS",
|
|
1600
|
-
/* @__PURE__ */
|
|
1853
|
+
/* @__PURE__ */ d("div", { className: "tz-va__bar", children: /* @__PURE__ */ d("span", { style: { width: `${W.kokoro * 100}%` } }) })
|
|
1601
1854
|
] }),
|
|
1602
|
-
p > 0 && /* @__PURE__ */ _("label", { children: [
|
|
1855
|
+
(p > 0 || u === "waiting" || u === "loading") && /* @__PURE__ */ _("label", { children: [
|
|
1603
1856
|
"Local LLM",
|
|
1604
|
-
/* @__PURE__ */
|
|
1857
|
+
/* @__PURE__ */ d("div", { className: "tz-va__bar", children: /* @__PURE__ */ d("span", { style: { width: `${p * 100}%` } }) })
|
|
1605
1858
|
] })
|
|
1606
1859
|
] }),
|
|
1607
|
-
/* @__PURE__ */
|
|
1608
|
-
|
|
1860
|
+
/* @__PURE__ */ d("div", { className: "tz-va__button", children: /* @__PURE__ */ d(
|
|
1861
|
+
_t,
|
|
1609
1862
|
{
|
|
1610
|
-
status:
|
|
1611
|
-
active:
|
|
1612
|
-
loading:
|
|
1613
|
-
analyser:
|
|
1614
|
-
onToggle:
|
|
1615
|
-
devices:
|
|
1616
|
-
selectedMicId:
|
|
1617
|
-
onDeviceChange:
|
|
1618
|
-
inputData:
|
|
1619
|
-
sendData: (
|
|
1620
|
-
|
|
1863
|
+
status: B,
|
|
1864
|
+
active: L,
|
|
1865
|
+
loading: w,
|
|
1866
|
+
analyser: ne,
|
|
1867
|
+
onToggle: L ? D : f,
|
|
1868
|
+
devices: de,
|
|
1869
|
+
selectedMicId: X,
|
|
1870
|
+
onDeviceChange: oe,
|
|
1871
|
+
inputData: ee,
|
|
1872
|
+
sendData: (k) => {
|
|
1873
|
+
G(""), V(k);
|
|
1621
1874
|
}
|
|
1622
1875
|
}
|
|
1623
1876
|
) }),
|
|
1624
|
-
/* @__PURE__ */
|
|
1877
|
+
/* @__PURE__ */ d("div", { className: "tz-va__input-row", children: /* @__PURE__ */ d(
|
|
1625
1878
|
"input",
|
|
1626
1879
|
{
|
|
1627
1880
|
type: "text",
|
|
1628
1881
|
className: "tz-va__input",
|
|
1629
|
-
value:
|
|
1630
|
-
onChange: (
|
|
1631
|
-
onKeyDown: (
|
|
1632
|
-
|
|
1882
|
+
value: ee,
|
|
1883
|
+
onChange: (k) => G(k.target.value),
|
|
1884
|
+
onKeyDown: (k) => {
|
|
1885
|
+
k.key === "Enter" && ee.trim() && (G(""), V(ee));
|
|
1633
1886
|
},
|
|
1634
1887
|
placeholder: "Type a message…",
|
|
1635
|
-
disabled:
|
|
1888
|
+
disabled: w
|
|
1636
1889
|
}
|
|
1637
1890
|
) }),
|
|
1638
|
-
/* @__PURE__ */
|
|
1639
|
-
|
|
1891
|
+
/* @__PURE__ */ d("p", { className: "tz-va__note", children: w ? W.kokoro < 1 ? "Loading Kokoro TTS…" : W.whisper < 1 ? "Loading Whisper STT…" : p > 0 && p < 1 ? "Loading local LLM (SmolLM2-360M, ~200 MB)…" : u === "waiting" ? "Speech is ready — starting the in-browser chat model next…" : u === "loading" ? "Starting the in-browser chat model…" : "Finishing up…" : "Ready." }),
|
|
1892
|
+
h && /* @__PURE__ */ d("p", { className: "tz-va__note", children: h })
|
|
1640
1893
|
] }),
|
|
1641
1894
|
/* @__PURE__ */ _("section", { className: "tz-va__card tz-va__transcript", children: [
|
|
1642
|
-
|
|
1643
|
-
/* @__PURE__ */
|
|
1644
|
-
/* @__PURE__ */
|
|
1645
|
-
|
|
1646
|
-
|
|
1895
|
+
A.map((k) => /* @__PURE__ */ _("div", { className: `tz-va__message tz-va__message--${k.role}`, children: [
|
|
1896
|
+
/* @__PURE__ */ d("small", { children: k.role === "user" ? "You" : "Assistant" }),
|
|
1897
|
+
/* @__PURE__ */ d("p", { children: k.content }),
|
|
1898
|
+
k.timings && /* @__PURE__ */ _("div", { className: "tz-va__timings", children: [
|
|
1899
|
+
k.timings.transcribeMs != null && /* @__PURE__ */ _("span", { children: [
|
|
1647
1900
|
"transcribe ",
|
|
1648
|
-
|
|
1901
|
+
De(k.timings.transcribeMs)
|
|
1649
1902
|
] }),
|
|
1650
|
-
|
|
1903
|
+
k.timings.thinkMs != null && /* @__PURE__ */ _("span", { children: [
|
|
1651
1904
|
"think ",
|
|
1652
|
-
|
|
1905
|
+
De(k.timings.thinkMs)
|
|
1653
1906
|
] }),
|
|
1654
|
-
|
|
1907
|
+
k.timings.ttsMs != null && /* @__PURE__ */ _("span", { children: [
|
|
1655
1908
|
"tts ",
|
|
1656
|
-
|
|
1909
|
+
De(k.timings.ttsMs)
|
|
1657
1910
|
] })
|
|
1658
1911
|
] })
|
|
1659
|
-
] },
|
|
1660
|
-
|
|
1661
|
-
/* @__PURE__ */
|
|
1912
|
+
] }, k.id)),
|
|
1913
|
+
b !== null && /* @__PURE__ */ _("div", { className: "tz-va__message tz-va__message--assistant tz-va__message--streaming", children: [
|
|
1914
|
+
/* @__PURE__ */ d("small", { children: "Assistant" }),
|
|
1662
1915
|
/* @__PURE__ */ _("p", { children: [
|
|
1663
|
-
|
|
1664
|
-
/* @__PURE__ */
|
|
1916
|
+
b,
|
|
1917
|
+
/* @__PURE__ */ d("span", { className: "tz-va__cursor" })
|
|
1665
1918
|
] })
|
|
1666
1919
|
] }),
|
|
1667
|
-
/* @__PURE__ */
|
|
1920
|
+
/* @__PURE__ */ d("div", { ref: J })
|
|
1668
1921
|
] }),
|
|
1669
|
-
|
|
1670
|
-
/* @__PURE__ */
|
|
1671
|
-
/* @__PURE__ */
|
|
1922
|
+
l ? /* @__PURE__ */ _("section", { className: "tz-va__card", children: [
|
|
1923
|
+
/* @__PURE__ */ d("strong", { children: "Error:" }),
|
|
1924
|
+
/* @__PURE__ */ d("p", { children: l })
|
|
1672
1925
|
] }) : null
|
|
1673
1926
|
] })
|
|
1674
1927
|
] });
|
|
1675
1928
|
}
|
|
1929
|
+
class Ct extends ot {
|
|
1930
|
+
constructor(s) {
|
|
1931
|
+
super(s), this.state = { error: null };
|
|
1932
|
+
}
|
|
1933
|
+
static getDerivedStateFromError(s) {
|
|
1934
|
+
return { error: s };
|
|
1935
|
+
}
|
|
1936
|
+
componentDidCatch(s, o) {
|
|
1937
|
+
console.error("[tz-voice-chat]", s, o == null ? void 0 : o.componentStack);
|
|
1938
|
+
}
|
|
1939
|
+
render() {
|
|
1940
|
+
var s;
|
|
1941
|
+
return this.state.error ? /* @__PURE__ */ d("div", { className: `tz-va ${this.props.className || ""}`.trim(), children: /* @__PURE__ */ _("section", { className: "tz-va__card tz-va__notice", role: "alert", children: [
|
|
1942
|
+
/* @__PURE__ */ _("div", { children: [
|
|
1943
|
+
/* @__PURE__ */ d("strong", { children: "Something went wrong." }),
|
|
1944
|
+
" ",
|
|
1945
|
+
String(((s = this.state.error) == null ? void 0 : s.message) || this.state.error)
|
|
1946
|
+
] }),
|
|
1947
|
+
/* @__PURE__ */ d("button", { type: "button", onClick: () => window.location.reload(), children: "Reload" })
|
|
1948
|
+
] }) }) : this.props.children;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
function Wt(e) {
|
|
1952
|
+
return /* @__PURE__ */ d(Ct, { className: e == null ? void 0 : e.className, children: /* @__PURE__ */ d(Dt, { ...e }) });
|
|
1953
|
+
}
|
|
1676
1954
|
export {
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1955
|
+
_t as AIAssistantButton,
|
|
1956
|
+
Ye as SETTINGS_SCHEMA,
|
|
1957
|
+
$ as STATES,
|
|
1958
|
+
Nt as SettingsPanel,
|
|
1959
|
+
gt as TZVoiceChat,
|
|
1960
|
+
Wt as VoiceAssistant,
|
|
1961
|
+
Ot as computeMissing,
|
|
1962
|
+
At as createLocalChatStream,
|
|
1963
|
+
St as sendChatRequest,
|
|
1964
|
+
It as useVoiceAssistant
|
|
1687
1965
|
};
|