Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Hotword detector wrapper of Snowboy by Kitt.ai with microphone functionality build-in.

License

Notifications You must be signed in to change notification settings

RedKenrok/node-hotworddetector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UNMAINTAINED: This project will not be updated in the future. I do not have a device set up to test and run the program on as well as the need for it to exist now or in the future.

Hotword detector

Hotword detector for Node.js using Snowboy by Kitt.ai. Snowboy is an offline neural network driven hotword detection library, with compatibility only on MacOS (darwin) and most Linux distro's. This module aims to simplify and improve the standard snowboy module by turning it into one single interface with build-in microphone recording and by adding start, stop, pause, and resume functionality.

Installation

npm i --save node-hotworddetector

Dependencies

This module uses snowboy, therefore it requires a some resources before hand please see the official website for these resources.

The module also uses the node-audiorecorder module. It requires you to have SoX installed and it must be available in your $PATH. For more information see the node-audiorecorder module.

Usage

Constructor

// Import module.
const HotwordDetector = require('node-hotworddetector');

// Detector data.
// See the 'snowboy' module for more information.
const detectorData = {
  resource: './node_modules/snowboy/resources/common.res'
};
// Array of data for each hotword model.
// See the 'snowboy' module for more information.
const modelData = [
  {
    file: './node_modules/snowboy/resources/snowboy.umdl',
    hotwords : 'snowboy',
    sensitivity: '0.5'
  }
];
// Optional parameter to select the recording options.
// See the 'node-audiorecorder' module for more information.
const recorderData = {
  audioGain: 2;
};
// Optional parameter intended for debugging.
// The object has to implement a log and warn function.
const logger = console;

// Create an instance.
let hotwordDetector = new HotwordDetector(detectorData, modelData, recorderData, logger);

More information about audio recorder options.

Methods

// Creates the detector and starts the recording process.
hotwordDetector.Start();
// Stops the detection process and removes the recording process.
hotwordDetector.Stop();

Events

// Triggered when an error is encountered.
hotwordDetector.on('error', function(error) {
  console.error('hotwordDetector: ' + error);
});
// Triggered when a hotword has been detected.
hotwordDetector.on('hotword', function(index, hotword, buffer) {
  // Index is the associated index of the detected hotword.
  // Hotword is a string of which word has been detected.
  // Buffer is the most recent section from the audio buffer.
  console.log('hotwordDetector: Hotword detected: ' + hotword);
});
// Triggered when there is no audible sound being recorded.
hotwordDetector.on('silence', function() {
  console.log('hotwordDetector: silence');
});
// Triggered when there is audible sound being recorded.
hotwordDetector.on('sound', function(buffer) {
  // Buffer is the most recent section from the audio buffer.
  console.log('hotwordDetector: sound: ' + buffer);
});

Examples

See the examples directory. If you want to use that code directly in your project DO update the require(../library) to require(node-hotworddetector).

For another example see the Electron-VoiceInterfaceBoilerplate's input.js.

About

Hotword detector wrapper of Snowboy by Kitt.ai with microphone functionality build-in.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published