nodejsPicovoice - NodeJS API

  • Speech-to-Intent Engine
  • Domain Specific NLU
  • Offline NLU
  • Local Voice Recognition
  • Raspberry Pi
  • Linux
  • macOS
  • NodeJS
  • NPM

This document outlines how to integrate the Picovoice SDK within a NodeJS application.


  • NodeJS 10+
  • yarn (or npm)


  • Linux (x86_64)
  • macOS (x86_64)
  • Raspberry Pi (2,3,4)

Web Browsers

Looking to run Picovoice in-browser? See the Web, Angular, React, or Vue docs instead.


The Picovoice SDK for NodeJS is available from NPM:

yarn add @picovoice/picovoice-node


npm install @picovoice/picovoice-node


The SDK provides the Picovoice class. Create an instance of this class using a Porcupine keyword and Rhino context file, as well as callback functions that will be invoked on wake word detection and speech command inference events, respectively:

const Picovoice = require("@picovoice/picovoice-node")
let keywordCallback = function (keyword) {
console.log(`Wake word detected`)
let inferenceCallback = function (inference) {
console.log(JSON.stringify(inference, null, 4))
let handle = new Picovoice(

The keywordArgument can either be a path to a Porcupine keyword file (.ppn), or one of the built-in keywords (integer enums). The contextPath is the path to the Rhino context file (.rhn).

Upon constructing the Picovoice class, send it frames of audio via its process method. Internally, Picovoice will switch between wake word detection and inference. The Picovoice class includes frameLength and sampleRate properties for the format of audio required.

// process audio frames that match the Picovoice requirements (16-bit linear pcm audio, single-channel)
while (true) {

As the audio is processed through the Picovoice engines, the callbacks will fire:

Picovoice, make me a large coffee

Wake word detected
"isUnderstood": true,
"intent": "orderDrink",
"slots": {
"size": "large",
"coffeeDrink": "coffee"

Porcupine and Rhino engines

The Picovoice SDK for NodeJS is built on top of the Porcupine and Rhino NodeJS bindings. If you wish to use these engines individually for wake word or inference, see the Porcupine and Rhino.

Custom Wake Word and Context

You can create custom Porcupine wake word and Rhino context models using Picovoice Console.

Issue with this doc? Please let us know.