import { RhinoInference } from '@picovoice/rhino-node'; export type WakeWordCallback = (keyword: number) => void; export type InferenceCallback = (inference: RhinoInference) => void; /** * Wraps the Picovoice Porcupine and Rhino engines. * * Switches input from Porcupine to Rhino upon wake word detection, then back to Rhino upon inference conclusion. * Fires callbacks on wake word and inference events. */ export default class Picovoice { private porcupine; private rhino; private readonly wakeWordCallback; private readonly inferenceCallback; private readonly _frameLength; private readonly _sampleRate; private readonly _version; private readonly _porcupineVersion; private readonly _rhinoVersion; private readonly _contextInfo; private isWakeWordDetected; /** * Creates an instance of Picovoice with a specific keyword and context. * @param {string} accessKey Obtained from the Picovoice Console (https://console.picovoice.ai/) * @param {string} keywordPath, * @param {function} wakeWordCallBack, * @param {string} contextPath, * @param {function} inferenceCallback, * @param {number} porcupineSensitivity = 0.5, * @param {number} rhinoSensitivity = 0.5, * @param {number} endpointDurationSec = 1.0, * @param {boolean} requireEndpoint = true, * @param {string} porcupineModelPath, * @param {string} rhinoModelPath, * @param {string} porcupineLibraryPath, * @param {string} rhinoLibraryPath, */ constructor(accessKey: string, keywordPath: string, wakeWordCallback: WakeWordCallback, contextPath: string, inferenceCallback: InferenceCallback, porcupineSensitivity?: number, rhinoSensitivity?: number, endpointDurationSec?: number, requireEndpoint?: boolean, porcupineModelPath?: string, rhinoModelPath?: string, porcupineLibraryPath?: string, rhinoLibraryPath?: 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 Picovoice */ get sampleRate(): number; /** * @returns the version of the Picovoice SDK */ get version(): string; /** * @returns the version of the Porcupine SDK */ get porcupineVersion(): string; /** * @returns the version of the Rhino SDK */ get rhinoVersion(): string; /** * @returns the Rhino context source YAML */ get contextInfo(): string; /** * Process a frame of pcm audio. * * @param {Array} frame 16-bit integers of 16kHz linear PCM mono audio. * The specific array length is obtained from Rhino via the frameLength field. */ process(frame: Int16Array): void; /** * Resets the internal state of Picovoice. It should be called before processing a new stream of audio * or when Picovoice was stopped while processing a stream of audio. */ reset(): void; /** * Release the resources acquired by Picovoice (via Porcupine and Rhino engines). */ release(): void; private mapToPicovoiceError; } //# sourceMappingURL=picovoice.d.ts.map