@picovoice/porcupine-react-native
Version:
Picovoice Porcupine React Native binding
85 lines (84 loc) • 4.77 kB
TypeScript
import type BuiltInKeywords from './builtin_keywords';
declare class Porcupine {
private _handle;
private _frameLength;
private _sampleRate;
private _version;
/**
* Gets all available devices that Porcupine can use for inference. Each entry in the list can be the `device` argument
* of the constructor.
*
* @returns Array of all available devices that Porcupine can use for inference.
*/
static getAvailableDevices(): Promise<any>;
/**
* 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 device String representation of the device (e.g., CPU or GPU) to use for inference.
* 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}`, where
* `${GPU_INDEX}` is the index of the target GPU. 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}`,
* where `${NUM_THREADS}` is the desired number of threads.
* @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, device?: 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 device String representation of the device (e.g., CPU or GPU) to use for inference.
* 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}`, where
* `${GPU_INDEX}` is the index of the target GPU. 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}`,
* where `${NUM_THREADS}` is the desired number of threads.
* @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, keywordPaths: string[], modelPath?: string, device?: 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;