JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 392
  • Score
    100M100P100Q103735F
  • License Apache-2.0

Picovoice Cobra Node.js binding

Package Exports

  • @picovoice/cobra-node
  • @picovoice/cobra-node/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@picovoice/cobra-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Cobra Binding for Node.js

Cobra Voice Activity Detection Engine

Made in Vancouver, Canada by Picovoice

Cobra is an on-device streaming voice activity detection engine. Cobra is:

  • Private; All voice processing runs locally.
  • Accurate [1]
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (3, 4, 5)

Compatibility

  • Node.js 18+
  • Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).

Installation

npm install @picovoice/cobra-node

AccessKey

Cobra requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cobra 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

Create an instance of the engine and detect voice activity in the audio:

Replace ${AccessKey} with your AccessKey obtained from Picovoice Console. cobra is an instance of Cobra.

const { Cobra } = require("@picovoice/cobra-node");

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

Once initialized, the valid sample rate is given by cobra.sampleRate. The expected frame length (number of audio samples in an input array) is cobra.frameLength. The engine accepts 16-bit linearly-encoded PCM and operates on single-channel audio.

function getNextAudioFrame() {
  // ...
  return audioFrame;
}

while (true) {
  const audioFrame = getNextAudioFrame();
  const voiceProbability = cobra.process(audioFrame);
  console.log(voiceProbability);
}

Finally, when done be sure to explicitly release the resources using cobra.release().

Demos

The Cobra Node.js demo package provides command-line utilities for processing audio using Cobra.