import { CobraOptions } from './types'; /** * Node.js binding for Cobra voice activity detection engine * * Performs the calls to the Cobra node library. Does some basic parameter validation to prevent * errors occurring in the library layer. Provides clearer error messages in native JavaScript. */ export default class Cobra { private _pvCobra; private _handle; private readonly _version; private readonly _frameLength; private readonly _sampleRate; /** * Creates an instance of Cobra. * @param {string} accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/). * @param options Optional configuration arguments. * @param {string} options.device String representation of the device (e.g., CPU or GPU) to use. * If set to `best`, the most suitable device is selected automatically. * If set to `gpu`, the engine uses the first available GPU device. * To select a specific GPU device, set this argument to `gpu:${GPU_INDEX}`. * If set to `cpu`, the engine will run on the CPU with the default number of threads. * To specify the number of threads, set this argument to `cpu:${NUM_THREADS}`. * @param {string} options.libraryPath the path to the Cobra library (.node extension) */ constructor(accessKey: string, options?: CobraOptions); /** * @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 the process function * @see {@link process} */ get sampleRate(): number; /** * @returns the version of the Cobra engine */ get version(): string; /** * Processes a frame of audio and returns the voice probability result. * * @param {Int16Array} pcm Audio data. The audio needs to have a sample rate equal to `Cobra.sampleRate` and be 16-bit linearly-encoded. * The specific array length can be attained by calling `Cobra.frameLength`. This function operates on single-channel audio. * @returns {number} Probability of voice activity. It is a floating-point number within [0, 1]. */ process(pcm: Int16Array): number; /** * Releases the resources acquired by Cobra. * * Be sure to call this when finished with the instance * to reclaim the memory that was allocated by the C library. */ release(): void; /** * Lists all available devices that Cobra can use for inference. * Each entry in the list can be used as the `device` argument when initializing Cobra. * * @returns {string[]} Array of all available devices that Cobra can use for inference. */ static listAvailableDevices(options?: CobraOptions): string[]; private handlePvStatus; } //# sourceMappingURL=cobra.d.ts.map