1.3.0 • Published 5 years ago

@picovoice/porcupine_manager v1.3.0

Weekly downloads
15
License
Apache-2.0
Repository
github
Last release
5 years ago

PorcupineManager

This is a library to recognize wake words and voice commands in the browser.

  • Private, as it runs locally within the browser and the voice data does not leave the device.
  • Real-time with minimal latency, as it does not depend on network calls.
  • Optimized using WebAssembly for algorithm performance.

Compatibility

PorcupineManager uses the Web Audio API and WebAssembly, which are supported on all modern browsers (excluding Internet Explorer).

Installation

npm install porcupine-manager

Usage

Add the following to your HTML:

<script src="{PATH_TO_WEB_VOICE_PROCESSOR_JS}"></script>
<script src="{PATH_TO_PORCUPINE_MANAGER_JS}"></script>

Replace {PATH_TO_WEB_VOICE_PROCESSOR_JS} with path to src/web_voice_processor.js, which is a dependency of porcupine_manager and replace {PATH_TO_PORCUPINE_MANAGER_JS} with the path to src/porcupine_manager.js.

Instantiation

The library adds a class to the global scope that can be used to instantiate an instance:

let porcupineWorkerScript = ... // Path to porcupine_worker.js within the package
let downsamplingWorkerScript = ... // Path to downsampling_worker.js script within web-voice-processor package

porcupineManager = PorcupineManager(porcupineWorkerScript, downsamplingWorkerScript);

Start Processing

Start the detection process:

porcupineManager.start(keywordIDs, sensitivities, detectionCallback, errorCallback)

keywordIDs is an array of keyword signatures to be detected. Each signature is an array of 8-bit unsigned integers (i.e. UInt8Array). A number of signatures are available for free under the resource folder and also within the demo file.

sensitivities is an array of 32-bit floating point numbers (i.e. Float32Array); each value corresponds to the detection sensitivity for each keyword. A higher sensitivity results in a lower miss rate, at the cost of a higher false positive rate. Sensitivity values are within [0, 1]. For more details, you can refer to the comments in the C library's header file.

detectionCallback is called after processing each frame.

let detectionCallback = function (keyword) {
    // do something ...
};

If no keyword is detected, the input argument will be null; otherwise, it corresponds to detected keyword.

errorCallback is executed when there is an error in the audio capture or processing logic.

Stop Processing

porcupineManager.stop()
1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago