tz-voice-chat 1.2.0 → 1.2.1
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 +47 -6
- 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 +1014 -785
- package/dist/style.css +1 -1
- package/dist-app/assets/{index-BDMCgrF_.css → index-Bcmhe9G_.css} +1 -1
- package/dist-app/assets/index-Wcfqx97N.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/run.js +17 -3
- 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-app/index.html
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
</script>
|
|
21
|
-
<script type="module" crossorigin src="/assets/index-
|
|
22
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
21
|
+
<script type="module" crossorigin src="/assets/index-Wcfqx97N.js"></script>
|
|
22
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bcmhe9G_.css">
|
|
23
23
|
</head>
|
|
24
24
|
<body>
|
|
25
25
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tz-voice-chat",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Voice assistant: React hook + UI and a ready-to-run server/CLI. VAD → Whisper STT → LLM → Kokoro/OpenAI/WebSpeech TTS, configurable from a Settings page.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
package/server/run.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
+
import https from 'node:https';
|
|
9
|
+
import os from 'node:os';
|
|
8
10
|
import { fileURLToPath } from 'node:url';
|
|
9
11
|
import { createVoiceAssistantRouter } from './index.js';
|
|
10
12
|
import { createVendorRouter } from './vendor.js';
|
|
@@ -18,9 +20,11 @@ const appDir = path.resolve(here, '../dist-app');
|
|
|
18
20
|
* @param {string} [opts.host='127.0.0.1'] Loopback by default: the Settings endpoints can read and
|
|
19
21
|
* write API keys, so only expose them on a network you trust.
|
|
20
22
|
* @param {string} [opts.settingsFile]
|
|
23
|
+
* @param {string} [opts.cert] PEM certificate file — with `key`, serves HTTPS (needed for the microphone on phones)
|
|
24
|
+
* @param {string} [opts.key] PEM private key file
|
|
21
25
|
* @returns {Promise<{ url: string, server: import('node:http').Server, settings: object }>}
|
|
22
26
|
*/
|
|
23
|
-
export async function startServer({ port = 3000, host = '127.0.0.1', settingsFile } = {}) {
|
|
27
|
+
export async function startServer({ port = 3000, host = '127.0.0.1', settingsFile, cert, key } = {}) {
|
|
24
28
|
if (!fs.existsSync(path.join(appDir, 'index.html'))) {
|
|
25
29
|
throw new Error(`Client app not found at ${appDir}. Run "npm run build" in the tz-voice-chat package first.`);
|
|
26
30
|
}
|
|
@@ -33,10 +37,20 @@ export async function startServer({ port = 3000, host = '127.0.0.1', settingsFil
|
|
|
33
37
|
app.get('*', (req, res) => res.sendFile(path.join(appDir, 'index.html')));
|
|
34
38
|
|
|
35
39
|
await ready();
|
|
40
|
+
const secure = Boolean(cert && key);
|
|
36
41
|
const server = await new Promise((resolve, reject) => {
|
|
37
|
-
const s =
|
|
42
|
+
const s = secure
|
|
43
|
+
? https.createServer({ cert: fs.readFileSync(cert), key: fs.readFileSync(key) }, app).listen(port, host, () => resolve(s))
|
|
44
|
+
: app.listen(port, host, () => resolve(s));
|
|
38
45
|
s.on('error', reject);
|
|
39
46
|
});
|
|
47
|
+
const scheme = secure ? 'https' : 'http';
|
|
48
|
+
const actualPort = server.address().port;
|
|
40
49
|
const shown = host === '0.0.0.0' || host === '::' ? 'localhost' : host;
|
|
41
|
-
|
|
50
|
+
// When listening on every interface, also list the addresses other devices can use.
|
|
51
|
+
const network = host === '0.0.0.0' || host === '::'
|
|
52
|
+
? Object.values(os.networkInterfaces()).flat().filter(a => a && a.family === 'IPv4' && !a.internal)
|
|
53
|
+
.map(a => `${scheme}://${a.address}:${actualPort}`)
|
|
54
|
+
: [];
|
|
55
|
+
return { url: `${scheme}://${shown}:${actualPort}`, network, secure, server, settings, host };
|
|
42
56
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";let t=null,r=null;self.onmessage=async l=>{var n,p;const{type:o,messages:i,modelProxyUrl:g}=l.data;if(o==="init"){try{const{pipeline:e,TextStreamer:a,env:s}=await import("/vendor/transformers/transformers.min.js");s.remoteHost=g||"/api/models/",(p=(n=s==null?void 0:s.backends)==null?void 0:n.onnx)!=null&&p.wasm&&(s.backends.onnx.wasm.wasmPaths="/vendor/transformers/"),r=a,t=await e("text-generation","HuggingFaceTB/SmolLM2-360M-Instruct",{dtype:"q4",progress_callback:({status:c,progress:m}={})=>{self.postMessage({type:"progress",status:c,progress:(m??0)/100})}}),self.postMessage({type:"ready"})}catch(e){self.postMessage({type:"error",message:String((e==null?void 0:e.message)??e)})}return}if(o==="generate"){if(!t||!r){self.postMessage({type:"done"});return}try{const e=new r(t.tokenizer,{skip_prompt:!0,skip_special_tokens:!0,callback_function:a=>{self.postMessage({type:"token",text:a})}});await t(i,{max_new_tokens:150,do_sample:!1,streamer:e}),self.postMessage({type:"done"})}catch(e){console.error("[LLM worker] generate error:",e),self.postMessage({type:"done"})}}}})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";let i=null,c=Promise.resolve();self.onmessage=async t=>{var m,d;const{type:l,audio:a}=t.data;if(l==="init"){const n=t.data.model||"onnx-community/whisper-tiny.en",e=t.data.device||"wasm",p=e==="cpu"?"wasm":e,g=t.data.modelProxyUrl||"/api/models/";let r=t.data.dtype||"q8";p==="webgpu"&&(r==="q4"||r==="q8")&&(console.warn(`[Whisper worker] dtype "${r}" not supported on WebGPU — using "fp32".`),r="fp32");try{const{pipeline:s,env:o}=await import("/vendor/transformers/transformers.min.js");o.remoteHost=g,(d=(m=o==null?void 0:o.backends)==null?void 0:m.onnx)!=null&&d.wasm&&(o.backends.onnx.wasm.wasmPaths="/vendor/transformers/"),i=await s("automatic-speech-recognition",n,{dtype:r,device:p,progress_callback:({status:y,progress:w}={})=>{self.postMessage({type:"progress",status:y,progress:(w??0)/100})}}),self.postMessage({type:"ready"})}catch(s){self.postMessage({type:"error",message:String((s==null?void 0:s.message)??s)})}return}l==="transcribe"&&(console.log("[Whisper worker] transcribe — samples:",a==null?void 0:a.length),c=c.then(async()=>{var n;try{if(!i){console.warn("[Whisper worker] pipeline not ready, dropping segment"),self.postMessage({type:"transcript",text:""});return}const e=await i(a),p=(e==null?void 0:e.text)??((n=e==null?void 0:e[0])==null?void 0:n.text)??"";self.postMessage({type:"transcript",text:p})}catch(e){console.error("[Whisper worker] transcription error:",e),self.postMessage({type:"transcript",text:""})}}))}})();
|