@lumiastream/wakeword 1.0.1-alpha.8 → 1.0.1-alpha.9

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/lib/record.js CHANGED
@@ -26,7 +26,6 @@ class Recording {
26
26
  this.options = Object.assign(defaults, options);
27
27
 
28
28
  const recorder = recorders.load(this.options.recorder);
29
- console.log(recorder);
30
29
  const { cmd, args, spawnOptions = {} } = recorder(this.options);
31
30
 
32
31
  this.cmd = cmd;
package/lib/voice.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { Model, Recognizer, setLogLevel } from "vosk-koffi";
2
2
  import record from "./record.js";
3
- import { join } from "node:path";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { existsSync } from "node:fs";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
4
8
 
5
9
  const binPath = join(
6
10
  "binaries",
@@ -11,8 +15,6 @@ const binPath = join(
11
15
  : "soxlinux"
12
16
  );
13
17
 
14
- console.log(binPath);
15
-
16
18
  let COMMANDS = [
17
19
  "blue",
18
20
  "[unk]", // always keep an [unk] fallback!
@@ -22,7 +24,18 @@ const SAMPLE_RATE = 16_000;
22
24
  setLogLevel(0);
23
25
 
24
26
  // 1. load model once
25
- const model = new Model("./models/vosk-model-small-en-us-0.15");
27
+ let modelPath = join(__dirname, "..", "models", "vosk-model-small-en-us-0.15");
28
+
29
+ /* If the file is running from inside app.asar we need the unpacked copy */
30
+ if (modelPath.includes("app.asar")) {
31
+ modelPath = modelPath.replace("app.asar", "app.asar.unpacked");
32
+ }
33
+
34
+ if (!existsSync(modelPath)) {
35
+ throw new Error(`Vosk model not found at ${modelPath}`);
36
+ }
37
+
38
+ const model = new Model(modelPath);
26
39
 
27
40
  // 2. build a grammar recognizer
28
41
  let rec = new Recognizer({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiastream/wakeword",
3
- "version": "1.0.1-alpha.8",
3
+ "version": "1.0.1-alpha.9",
4
4
  "type": "module",
5
5
  "main": "lib/voice.js",
6
6
  "bin": {