@lumiastream/wakeword 1.0.1-alpha.7 → 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/bin/wakeword +1 -1
- package/lib/record.js +5 -5
- package/lib/recorders/arecord.js +1 -1
- package/lib/recorders/index.js +19 -14
- package/lib/recorders/rec.js +1 -1
- package/lib/recorders/sox.js +1 -1
- package/lib/{voice.mjs → voice.js} +20 -6
- package/package.json +3 -3
package/bin/wakeword
CHANGED
package/lib/record.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import assert from "assert";
|
|
4
|
+
import debug from "debug";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import recorders from "./recorders/index.js";
|
|
7
7
|
|
|
8
8
|
class Recording {
|
|
9
9
|
constructor(options = {}) {
|
|
@@ -114,6 +114,6 @@ Enable debugging with the environment variable DEBUG=record.`
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
export default {
|
|
118
118
|
record: (...args) => new Recording(...args),
|
|
119
119
|
};
|
package/lib/recorders/arecord.js
CHANGED
package/lib/recorders/index.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// import { fileURLToPath } from "node:url";
|
|
2
|
+
// import path from "node:path";
|
|
3
|
+
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
import rec from "./sox.js";
|
|
2
5
|
|
|
3
|
-
function load
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function load(recorderName) {
|
|
7
|
+
try {
|
|
8
|
+
// const recoderPath = path.resolve(__dirname, recorderName);
|
|
9
|
+
// const module = await import(recoderPath);
|
|
10
|
+
// return module.default;
|
|
11
|
+
return rec;
|
|
12
|
+
} catch (err) {
|
|
13
|
+
if (err.code === "MODULE_NOT_FOUND") {
|
|
14
|
+
throw new Error(`No such recorder found: ${recorderName}`);
|
|
15
|
+
}
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
21
|
+
export default {
|
|
22
|
+
load,
|
|
23
|
+
};
|
package/lib/recorders/rec.js
CHANGED
package/lib/recorders/sox.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Model, Recognizer, setLogLevel } from "vosk";
|
|
2
|
-
import record from "./record";
|
|
3
|
-
import { join } from "node:path";
|
|
1
|
+
import { Model, Recognizer, setLogLevel } from "vosk-koffi";
|
|
2
|
+
import record from "./record.js";
|
|
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,9 +15,8 @@ const binPath = join(
|
|
|
11
15
|
: "soxlinux"
|
|
12
16
|
);
|
|
13
17
|
|
|
14
|
-
console.log(binPath);
|
|
15
|
-
|
|
16
18
|
let COMMANDS = [
|
|
19
|
+
"blue",
|
|
17
20
|
"[unk]", // always keep an [unk] fallback!
|
|
18
21
|
];
|
|
19
22
|
|
|
@@ -21,7 +24,18 @@ const SAMPLE_RATE = 16_000;
|
|
|
21
24
|
setLogLevel(0);
|
|
22
25
|
|
|
23
26
|
// 1. load model once
|
|
24
|
-
|
|
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);
|
|
25
39
|
|
|
26
40
|
// 2. build a grammar recognizer
|
|
27
41
|
let rec = new Recognizer({
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumiastream/wakeword",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "lib/voice.
|
|
5
|
+
"main": "lib/voice.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"wakeword": "bin/wakeword"
|
|
8
8
|
},
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"postinstall": "chmod +x binaries/soxmac binaries/soxlinux binaries/sox.exe || true"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"vosk": "^
|
|
19
|
+
"vosk-koffi": "^1.1.1"
|
|
20
20
|
}
|
|
21
21
|
}
|