npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hotwordwrapper

v1.0.3

Published

Hotword detector for Node.js using Snowboy by Kitt.ai.

Downloads

3

Readme

hotwordwrap

Hotword detector wrapper

Now you can use sox or arecord in linux based systems Written in Node.js using latest Snowboy version 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 hotwordwrapper

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('hotwordwrapper');

// 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.
/*
options - JSON containing command line options. Following are valid options:
endian: big OR little, default: little
bitwidth: 8 OR 16 OR 24 OR anything valid supported by arecord OR sox, default: 16
encoding: signed-integer OR unsinged-integer (none of the other encoding formats are supported), default:signed-integer
rate: 8000 OR 16000 OR 44100 OR anything valid supported by arecord OR sox, default: 16000
channels: 1 OR 2 OR anything valid supported by arecord OR sox, default: 1 (mono)
device: hw:0,0 OR plughw:1, 0 OR anything valid supported by arecord. Ignored for sox on macOS.
debug: true OR false - can be used to aide in debugging
fileType: string defaults to 'raw', allows you to set a valid file type such as 'wav' (for sox only) to avoid the no header issue mentioned above, see a list of types here
*/
const recorderData = {
  rate: '16000',
    channels: '1',
    debug: true,
};
// 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 mic.

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);
});