nodejsPorcupine - Node.js API

API Reference for the Node.js Porcupine SDK (npmjs).


Porcupine

class Porcupine

Class for the Porcupine wake word engine. Porcupine can be initialized using the class constructor(). Resources should be cleaned when you are done using the release() method.


Porcupine.constructor()

Porcupine.constructor(
accessKey,
keywords,
sensitivities,
manualModelPath,
manualLibraryPath
)

constructor method for Porcupine wake word engine.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<string> : Absolute paths to keyword model files.
  • sensitivities Array<number> : Sensitivities for detecting keywords. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
  • manualModelPath string : Absolute path to the file containing model parameters.
  • manualLibraryPath string : Absolute path to Porcupine's dynamic library.

Returns

  • Porcupine: An instance of Porcupine wake word engine.

Porcupine.process()

Porcupine.process(frame)

Processes a frame of the incoming audio stream and emits the detection result. The number of samples per frame can be attained by calling .frameLength. The incoming audio needs to have a sample rate equal to .sampleRate and be 16-bit linearly-encoded. Porcupine operates on single-channel audio.

Parameters

  • frame Array<number> : A frame of audio samples.

Returns

  • number : Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keyword models provided to the constructor. If no keyword is detected then it returns -1.

Porcupine.frameLength

Porcupine.frameLength

The number of audio samples per frame.


Porcupine.sampleRate

Porcupine.sampleRate

The audio sample rate accepted by the Porcupine engine.


Porcupine.version

Porcupine.version

The version of the Porcupine engine.


Porcupine.release()

Porcupine.release()

Releases resources acquired by Porcupine


Issue with this doc? Please let us know.