openwakeword-js 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,13 +98,19 @@ if (scores["my_custom_model"] > 0.5) {
98
98
 
99
99
  ## Local Development & Demo
100
100
 
101
- We have included a full working example in the `example/` folder.
102
-
103
- 1. Clone the repo and run `npm install`.
104
- 2. Run `npm run download-models`.
105
- 3. Serve the root directory using a static server (e.g., `npx serve .`).
106
- 4. Navigate to `http://localhost:3000/example/index.html`.
107
- 5. Allow Microphone access and watch the real-time scores.
101
+ ### Option A: The Fast Start (Automated)
102
+ If you just want to see it working:
103
+ 1. `npm install openwakeword-js onnxruntime-web`
104
+ 2. `npx openwakeword-js-setup`
105
+ 3. `npx serve .`
106
+ 4. Open `http://localhost:3000`
107
+
108
+ ### Option B: Manual Development
109
+ If you are developing inside this repository:
110
+ 1. Clone the repo and run `npm install`.
111
+ 2. Run `npm run download-models`.
112
+ 3. Serve the root directory using a static server (e.g., `npx serve .`).
113
+ 4. Navigate to `http://localhost:3000/example/index.html`.
108
114
 
109
115
  ---
110
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openwakeword-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Port of openWakeWord to JavaScript/TypeScript using ONNX Runtime",
5
5
  "bin": {
6
6
  "openwakeword-js-setup": "scripts/download_models.js"
@@ -2,7 +2,10 @@
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import https from 'https';
5
+ import { fileURLToPath } from 'url';
5
6
 
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const packageRoot = path.join(__dirname, '..');
6
9
  const MODELS_DIR = path.join(process.cwd(), 'models');
7
10
 
8
11
  const MODELS = {
@@ -31,6 +34,15 @@ async function downloadFile(url, dest) {
31
34
  });
32
35
  }
33
36
 
37
+ function copyIfExists(src, dest, label) {
38
+ if (fs.existsSync(src)) {
39
+ fs.copyFileSync(src, dest);
40
+ console.log(`- ${label}: ${path.basename(dest)}`);
41
+ return true;
42
+ }
43
+ return false;
44
+ }
45
+
34
46
  async function main() {
35
47
  if (!fs.existsSync(MODELS_DIR)) {
36
48
  fs.mkdirSync(MODELS_DIR);
@@ -52,26 +64,40 @@ async function main() {
52
64
  console.log(`Failed: ${err.message}`);
53
65
  }
54
66
  }
55
- console.log('\nBase models are ready in the ./models folder.');
67
+ console.log('\nDeploying sample wake word models...');
68
+ const packageModelsDir = path.join(packageRoot, 'models');
69
+ ['hello_deepa.onnx', 'namaste_deepa.onnx'].forEach(m => {
70
+ const src = path.join(packageModelsDir, m);
71
+ const dest = path.join(MODELS_DIR, m);
72
+ copyIfExists(src, dest, 'Model');
73
+ });
56
74
 
57
- // Automate WASM copying for browser users
58
- console.log('Locating ONNX Runtime WebAssembly files...');
75
+ console.log('\nLocating ONNX Runtime WebAssembly files...');
59
76
  const nodeModulesPath = path.join(process.cwd(), 'node_modules', 'onnxruntime-web', 'dist');
60
77
 
61
78
  if (fs.existsSync(nodeModulesPath)) {
62
79
  const wasmFiles = fs.readdirSync(nodeModulesPath).filter(f => f.endsWith('.wasm'));
63
80
  for (const file of wasmFiles) {
64
- const src = path.join(nodeModulesPath, file);
65
- const dest = path.join(MODELS_DIR, file);
66
- fs.copyFileSync(src, dest);
67
- console.log(`- Copied ${file} to ./models/`);
81
+ copyIfExists(path.join(nodeModulesPath, file), path.join(MODELS_DIR, file), 'WASM');
68
82
  }
69
- console.log('WebAssembly files are ready for browser deployment.');
70
83
  } else {
71
- console.log('Warning: onnxruntime-web not found in node_modules. Run "npm install" first.');
84
+ console.log('Warning: onnxruntime-web not found. Ensuring high-speed browser execution requires "npm install".');
72
85
  }
73
86
 
74
- console.log('\nCustom wake word models should be added to the same folder.');
87
+ console.log('\nDeploying AI Listening Interface...');
88
+ const exampleHtml = path.join(packageRoot, 'example', 'index.html');
89
+ const destHtml = path.join(process.cwd(), 'index.html');
90
+ copyIfExists(exampleHtml, destHtml, 'UI');
91
+
92
+ console.log('\n----------------------------------------------------');
93
+ console.log('SETUP COMPLETE');
94
+ console.log('----------------------------------------------------');
95
+ console.log('Your precision AI wake word interface is ready.');
96
+ console.log('\nTo start the demo:');
97
+ console.log('1. Run: npx serve .');
98
+ console.log('2. Open: http://localhost:3000');
99
+ console.log('\nHappy coding!');
100
+ console.log('----------------------------------------------------\n');
75
101
  }
76
102
 
77
103
  main().catch(console.error);