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

@picovoice/porcupine-node

v3.0.2

Published

Picovoice Porcupine Node.js binding

Downloads

582

Readme

Porcupine Binding for Node.js

Porcupine

Porcupine is a highly accurate and lightweight wake word engine. It enables building always-listening voice-enabled applications using cutting edge voice AI.

Porcupine is:

  • private and offline
  • accurate
  • resource efficient (runs even on microcontrollers)
  • data efficient (wake words can be easily generated by simply typing them, without needing thousands of hours of bespoke audio training data and manual effort)
  • scalable to many simultaneous wake-words / always-on voice commands
  • cross-platform

To learn more about Porcupine, see the product, documentation, and GitHub pages.

Custom wake words

Porcupine includes several built-in keywords, which are stored as .ppn files. To train custom PPN files, see the Picovoice Console.

Unlike the built-in keywords, custom PPN files generated with the Picovoice Console carry restrictions including (but not limited to): training allowance, time limits, available platforms, and commercial usage.

Compatibility

This binding is for running Porcupine on Node.js 16+ on the following platforms:

  • Windows (x86_64)
  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Raspberry Pi (2, 3, 4, 5)
  • NVIDIA Jetson (Nano)
  • BeagleBone

Web Browsers

This npm package is for Node.js and does not work in a browser. Looking to run Porcupine in-browser? There are npm packages available for Web, and dedicated packages for Angular, React, and Vue.

AccessKey

Porcupine requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Porcupine SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Usage

The binding provides the Porcupine class. Create instances of the Porcupine class to detect specific keywords.

Quick Start: Built-in keywords

The built-in keywords give a quick way to get started. Here we can specify that we want to listen for the wake words "grasshopper" and "bumblebee" with sensitivities of 0.5 and 0.65, respectively. Since Porcupine can listen to multiple keywords simultaneously, they are provided as an array argument.

const {
  Porcupine,
  BuiltinKeyword,
}= require("@picovoice/porcupine-node");

const accessKey = "${ACCESS_KEY}" // Obtained from the Picovoice Console (https://console.picovoice.ai/)

const handle = new Porcupine(
    accessKey,
    [BuiltinKeyword.GRASSHOPPER, BuiltinKeyword.BUMBLEBEE],
    [0.5, 0.65]);

// process a single frame of audio
// the keywordIndex provides the index of the keyword detected, or -1 if no keyword was detected
const keywordIndex = handle.process(frame);

List of built-in keywords

  • ALEXA
  • AMERICANO
  • BLUEBERRY
  • BUMBLEBEE
  • COMPUTER
  • GRAPEFRUIT
  • GRASSHOPPER
  • HEY_GOOGLE
  • HEY_SIRI
  • JARVIS
  • OK_GOOGLE
  • PICOVOICE
  • PORCUPINE
  • TERMINATOR

Custom keywords

Providing an array of strings instead of the built-in enums allows you to specify an absolute path to a keyword .ppn file:

const accessKey = "${ACCESS_KEY}" // Obtained from the Picovoice Console (https://console.picovoice.ai/)

const handle = new Porcupine(
    accessKey,
    ["/absolute/path/to/your/keyword.ppn"],
    [0.5]);

Override model and library paths

The Porcupine constructor accepts two optional positional parameters for the absolute paths to the model and dynamic library, should you need to override them (typically, you will not).

const accessKey = "${ACCESS_KEY}" // Obtained from the Picovoice Console (https://console.picovoice.ai/)

const handle = new Porcupine(
  accessKey,
  keywordPaths,
  sensitivities,
  modelFilePath,
  libraryFilePath
);

Using the bindings from source

Unit Tests

Run yarn (ornpm install) from the binding/nodejs directory to install project dependencies. This will also run a script to copy all the necessary shared resources from the Porcupine repository into the package directory.

Run yarn test (or npm run test) from the binding/nodejs directory to execute the test suite.