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

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 CHANGED
@@ -24,7 +24,7 @@ const child = spawn(
24
24
  path.dirname(fileURLToPath(import.meta.url)),
25
25
  "..",
26
26
  "lib",
27
- "voice.mjs"
27
+ "voice.js"
28
28
  ),
29
29
  soxPath,
30
30
  ...process.argv.slice(2),
package/lib/record.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- const assert = require("assert");
4
- const debug = require("debug")("record");
5
- const { spawn } = require("child_process");
6
- const recorders = require("./recorders");
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 = {}) {
@@ -26,6 +26,7 @@ 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);
29
30
  const { cmd, args, spawnOptions = {} } = recorder(this.options);
30
31
 
31
32
  this.cmd = cmd;
@@ -114,6 +115,6 @@ Enable debugging with the environment variable DEBUG=record.`
114
115
  }
115
116
  }
116
117
 
117
- module.exports = {
118
+ export default {
118
119
  record: (...args) => new Recording(...args),
119
120
  };
@@ -1,5 +1,5 @@
1
1
  // On some systems (RasPi), arecord is the prefered recording binary
2
- module.exports = (options) => {
2
+ export default (options) => {
3
3
  let cmd = "arecord";
4
4
 
5
5
  if (options.binPath) {
@@ -1,18 +1,23 @@
1
- const path = require('path')
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 (recorderName) {
4
- try {
5
- const recoderPath = path.resolve(__dirname, recorderName)
6
- return require(recoderPath)
7
- } catch (err) {
8
- if (err.code === 'MODULE_NOT_FOUND') {
9
- throw new Error(`No such recorder found: ${recorderName}`)
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
- throw err
13
- }
17
+ throw err;
18
+ }
14
19
  }
15
20
 
16
- module.exports = {
17
- load
18
- }
21
+ export default {
22
+ load,
23
+ };
@@ -1,4 +1,4 @@
1
- module.exports = (options) => {
1
+ export default (options) => {
2
2
  let cmd = "rec";
3
3
 
4
4
  if (options.binPath) {
@@ -1,4 +1,4 @@
1
- module.exports = (options) => {
1
+ export default (options) => {
2
2
  let cmd = "sox";
3
3
 
4
4
  if (options.binPath) {
@@ -1,5 +1,5 @@
1
- import { Model, Recognizer, setLogLevel } from "vosk";
2
- import record from "./record";
1
+ import { Model, Recognizer, setLogLevel } from "vosk-koffi";
2
+ import record from "./record.js";
3
3
  import { join } from "node:path";
4
4
 
5
5
  const binPath = join(
@@ -14,6 +14,7 @@ const binPath = join(
14
14
  console.log(binPath);
15
15
 
16
16
  let COMMANDS = [
17
+ "blue",
17
18
  "[unk]", // always keep an [unk] fallback!
18
19
  ];
19
20
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@lumiastream/wakeword",
3
- "version": "1.0.1-alpha.7",
3
+ "version": "1.0.1-alpha.8",
4
4
  "type": "module",
5
- "main": "lib/voice.mjs",
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": "^0.3.39"
19
+ "vosk-koffi": "^1.1.1"
20
20
  }
21
21
  }