jaxcore / bumblebee-hotword-node

BumbleBee Hotword for NodeJS
Apache License 2.0
14 stars 4 forks source link

Bumblebee Hotword for NodeJS

screenshot

Bumblebee Hotword starts recording the system microphone and emits an event when it hears the available hotwords.

This is a stripped down and repackaged version of the excellent Porcupine wake word (hotword) system. This requires no cloud services and is freely available to use under the Apache 2.0 license (GPLv3 compatible).

This is the NodeJS version of Bumblebee Hotword. If you need hotword detection in the browser or ElectronJS see here.

Hotword detection is just one part of the larger Bumblebee voice application framework, for more information see:

Install

Using npm:

npm install bumblebee-hotword-node

Quick Start

const Bumblebee = require('bumblebee-hotword-node');
const bumblebee = new Bumblebee();

bumblebee.addHotword('bumblebee');

bumblebee.on('hotword', function (hotword) {
    console.log('Hotword Detected:', hotword);
});

bumblebee.start();

Hotwords

The hotwords available by default are:

These hotwords are build into the NPM package but must be added to Bumblebee individually. For performance it is recommended to only add the hotwords that are needed:

bumblebee.addHotword('alexa');
bumblebee.addHotword('computer');
bumblebee.addHotword('bumblebee');
bumblebee.addHotword('grasshopper');
bumblebee.addHotword('hey_edison');
bumblebee.addHotword('hey_google');
bumblebee.addHotword('hey_siri');
bumblebee.addHotword('jarvis');
bumblebee.addHotword('ok_google');
bumblebee.addHotword('porcupine');
bumblebee.addHotword('terminator');

The hotword that is detected can be retreived in the .on('hotword') event:

bumblebee.on('hotword', function(hotword) {
    console.log('hotword detected:', hotword);
});

To only receive a hotword event for one of the hotwords, use the setHotword() method:

bumblebee.setHotword('hey_edison');

The Picovoice hotwords open source hotwords are freely usable under the Apache 2.0 license. Custom hotwords can be licensed from https://picovoice.ai.

Add New Hotwords

The default hotwords were open sourced and supplied by Picovoice.

To convert a PPN hotword file to the formate used by Bumblebee, use the xdd command:

xxd -i -g 1 white\ smoke_wasm.ppn output.hex

Then take byte array contents of output.hex:

unsigned char americano_wasm_ppn[] = {
    /* COPY THE CONTENTS HERE */
};
unsigned int americano_wasm_ppn_len = 3008;

And create a new hotword JavaScript file with the format:

module.exports = new Uint8Array([
    /* PASTE THE CONTENTS HERE */
]);

Add the hotword file to Bumblebee Hotword using;

bumblebee.addHotword('white_smoke', require('./white_smoke.js'));

See the full example

Sensitivity

Hotword detection sensitivity (0.0 to 1.0) is configurable only before the first call to bumblebee.start()

bumblebee.setSensitivity(0.8);

Disable Bumblebee

Use the stop() method to disable the microphone and all processing:

bumblebee.stop();

Audio Data

Bumblebee Hotword records audio from the microphone in 16bit/16khz PCM format and emits a stream of "data" events so the audio can be processed by other systems (such as DeepSpeech):

bumblebee.on('data', function(data) {
    console.log('data', data);
});

Audio Stream

Instead of using the system microphone, an audio stream can be supplied. The audio format must be a Float32Array (32 bit signed floating point values) at 16Khz sample rate. Refer to the wav-example example.

// some audioInputStream object (eg. ffmpeg)

bumblebee.start({stream: audioInputStream});

Run Examples Locally

Clone this repo, then...

For the basic example:

cd examples/basic-example
node start.js

For the full example:

cd examples/full-example
npm install --mpg123-backend=openal
node start.js

For the wav file stream example:

cd examples/wav-example
npm install fluent-ffmpeg
node start.js

License

This repository is licensed under Apache 2.0. See Porcupine for more details.

Change Log