Nothing Particularly Magnificent
    Wondering what’s next for npm?Check out our public roadmap! »

    @picovoice/picovoice-node

    1.1.2 • Public • Published

    Picovoice

    Made in Vancouver, Canada by Picovoice

    Picovoice is an end-to-end platform for building voice products on your terms. It enables creating voice experiences similar to Alexa and Google. But it entirely runs 100% on-device. Picovoice is

    • Private: Everything is processed offline. Intrinsically HIPAA and GDPR compliant.
    • Reliable: Runs without needing constant connectivity.
    • Zero Latency: Edge-first architecture eliminates unpredictable network delay.
    • Accurate: Resilient to noise and reverberation. It outperforms cloud-based alternatives by wide margins *.
    • Cross-Platform: Design once, deploy anywhere. Build using familiar languages and frameworks.

    See the Picovoice Docs for additional details.

    Compatibility

    This binding is for running Porcupine on NodeJS 10+ on the following platforms:

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

    Web Browsers

    This binding is for NodeJS and does not work in a browser. Looking to run Porcupine in-browser? Use the JavaScript WebAssembly binding instead.

    Usage

    The Picovoice SDK for NodeJS is available from NPM:

    yarn add @picovoice/picovoice-node

    (or)

    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 and inference events, respectively:

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

    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) {
      handle.process(frame_of_audio);
    }

    As the audio is processed through the Picovoice engines, the callbacks will fire. This is the output when we provide the built-in "picovoice" keyword and sample "coffee maker" context to the Picovoice class, and then provide it a test WAV file that contains the following utterance:

    Picovoice, make me a large coffee

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

    Porcupine and Rhino

    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 NPM packages, respectively.

    Install

    npm i @picovoice/picovoice-node

    DownloadsWeekly Downloads

    19

    Version

    1.1.2

    License

    Apache-2.0

    Unpacked Size

    23.2 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar