UNPKG

@picovoice/porcupine-node

Version:

Picovoice Porcupine Node.js binding

51 lines 2.33 kB
export default class Porcupine { private _pvPorcupine; private _handle; private readonly _version; private readonly _sampleRate; private readonly _frameLength; /** * Creates an instance of Porcupine. * @param {string} accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/). * @param {Array} keywords Absolute paths to keyword model files (`.ppn`). * @param {Array} sensitivities Sensitivity values 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. * @param {string} manualModelPath Absolute path to the file containing model parameters (`.pv`). * @param {string} manualLibraryPath Absolute path to Porcupine's dynamic library (platform-dependent extension). */ constructor(accessKey: string, keywords: string[], sensitivities: number[], manualModelPath?: string, manualLibraryPath?: string); /** * @returns number of audio samples per frame (i.e. the length of the array provided to the process function) * @see {@link process} */ get frameLength(): number; /** * @returns the audio sampling rate accepted by Porcupine */ get sampleRate(): number; /** * @returns the version of the Porcupine engine */ get version(): string; /** * Process a frame of pcm audio. * * @param {Array} frame of mono, 16-bit, linear-encoded PCM audio. * The specific array length 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. * @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. */ process(frame: Int16Array): number; /** * Releases the resources acquired by Porcupine. * * Be sure to call this when finished with the instance * to reclaim the memory that was allocated by the C library. */ release(): void; private handlePvStatus; } //# sourceMappingURL=porcupine.d.ts.map