UNPKG

@picovoice/porcupine-react-native

Version:

Picovoice Porcupine React Native binding

66 lines (65 loc) 3.21 kB
import type BuiltInKeywords from './builtin_keywords'; declare class Porcupine { private _handle; private _frameLength; private _sampleRate; private _version; /** * Static creator for initializing Porcupine from one of the built-in keywords * @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/. * @param keywords List of keywords (phrases) for detection. The list of available (default) keywords can be retrieved * using `Porcupine.KEYWORDS`. If `keyword_paths` is set then this argument will be ignored. * @param modelPath Path to the file containing model parameters. If not set it will be set to the default location. * @param sensitivities sensitivities for each keywords model. A higher sensitivity reduces miss rate * at the cost of potentially higher false alarm rate. Sensitivity should be a floating-point number within * [0, 1]. * @returns An instance of the engine. */ static fromBuiltInKeywords(accessKey: string, keywords: BuiltInKeywords[], modelPath?: string, sensitivities?: number[]): Promise<Porcupine>; /** * Static creator for initializing Porcupine from a list of paths to custom keyword files * @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/). * @param keywordPaths Absolute paths to keyword model files. * @param modelPath Path to the file containing model parameters. If not set it will be set to the default location. * @param sensitivities sensitivities for each keywords model. A higher sensitivity reduces miss rate * at the cost of potentially higher false alarm rate. Sensitivity should be a floating-point number within * [0, 1]. * @returns An instance of the engine. */ static fromKeywordPaths(accessKey: string, keywordsPaths: string[], modelPath?: string, sensitivities?: number[]): Promise<Porcupine>; private constructor(); /** * Process a frame of audio with the wake word engine. * @param frame A frame of audio samples to be assessed by Porcupine. The required audio format is found by * calling `.sampleRate` to get the required sample rate and `.frameLength` to get the required frame size. * Audio must be single-channel and 16-bit linearly-encoded. * @returns {Promise} Index of the detected keyword, or -1 if no detection occurred */ process(frame: number[]): Promise<any>; /** * Frees memory that was allocated for Porcupine */ delete(): Promise<any>; /** * Gets the required number of audio samples per frame. * @returns Required frame length. */ get frameLength(): number; /** * Get the audio sample rate required by Porcupine. * @returns Required sample rate. */ get sampleRate(): number; /** * Gets the version number of the Porcupine library. * @returns Version of Porcupine */ get version(): string; /** * Gets the Error type given a code. * @param code Code name of native Error. * @param message Detailed message of the error. */ private static codeToError; } export default Porcupine;