///
import { InferenceCallback, RhinoContext, RhinoModel, RhinoOptions } from './types';
type pv_rhino_process_type = (object: number, pcm: number, isFinalized: number) => number;
type pv_rhino_reset_type = (object: number) => number;
type pv_rhino_context_info_type = (object: number, contextInfo: number) => number;
type pv_rhino_delete_type = (object: number) => void;
type pv_rhino_frame_length_type = () => number;
type pv_rhino_free_slots_and_values_type = (object: number, slots: number, values: number) => number;
type pv_rhino_get_intent_type = (object: number, intent: number, numSlots: number, slots: number, values: number) => number;
type pv_rhino_is_understood_type = (object: number, isUnderstood: number) => number;
type pv_rhino_version_type = () => number;
type pv_sample_rate_type = () => number;
type pv_rhino_list_hardware_devices_type = (hardwareDevices: number, numHardwareDevices: number) => number;
type pv_rhino_free_hardware_devices_type = (hardwareDevices: number, numHardwareDevices: number) => number;
type pv_set_sdk_type = (sdk: number) => void;
type pv_get_error_stack_type = (messageStack: number, messageStackDepth: number) => number;
type pv_free_error_stack_type = (messageStack: number) => void;
/**
* JavaScript/WebAssembly Binding for the Picovoice Rhino Speech-to-Intent engine.
*
* The instances have JavaScript bindings that wrap the calls to the C library and
* do some rudimentary type checking and parameter validation.
*/
type RhinoModule = EmscriptenModule & {
_pv_free: (address: number) => void;
_pv_rhino_delete: pv_rhino_delete_type;
_pv_rhino_process: pv_rhino_process_type;
_pv_rhino_reset: pv_rhino_reset_type;
_pv_rhino_context_info: pv_rhino_context_info_type;
_pv_rhino_free_slots_and_values: pv_rhino_free_slots_and_values_type;
_pv_rhino_get_intent: pv_rhino_get_intent_type;
_pv_rhino_is_understood: pv_rhino_is_understood_type;
_pv_rhino_frame_length: pv_rhino_frame_length_type;
_pv_rhino_version: pv_rhino_version_type;
_pv_rhino_list_hardware_devices: pv_rhino_list_hardware_devices_type;
_pv_rhino_free_hardware_devices: pv_rhino_free_hardware_devices_type;
_pv_sample_rate: pv_sample_rate_type;
_pv_set_sdk: pv_set_sdk_type;
_pv_get_error_stack: pv_get_error_stack_type;
_pv_free_error_stack: pv_free_error_stack_type;
addFunction: typeof addFunction;
ccall: typeof ccall;
cwrap: typeof cwrap;
};
export declare class Rhino {
private _module?;
private readonly _contextInfo;
private readonly _frameLength;
private readonly _sampleRate;
private readonly _version;
private readonly _processMutex;
private readonly _contextAddress;
private readonly _inputBufferAddress;
private readonly _intentAddressAddress;
private readonly _isFinalizedAddress;
private readonly _isUnderstoodAddress;
private readonly _numSlotsAddress;
private readonly _objectAddress;
private readonly _slotsAddressAddressAddress;
private readonly _valuesAddressAddressAddress;
private readonly _messageStackAddressAddressAddress;
private readonly _messageStackDepthAddress;
private static _wasmSimd;
private static _wasmSimdLib;
private static _wasmPThread;
private static _wasmPThreadLib;
private static _sdk;
private static _rhinoMutex;
private readonly _inferenceCallback;
private readonly _processErrorCallback;
private constructor();
/**
* Get Rhino engine version.
*/
get version(): string;
/**
* Get frame length.
*/
get frameLength(): number;
/**
* Get sample rate.
*/
get sampleRate(): number;
/**
* Get context info.
*/
get contextInfo(): string;
/**
* Set base64 wasm file with SIMD feature.
* @param wasmSimd Base64'd wasm file to use to initialize wasm.
*/
static setWasmSimd(wasmSimd: string): void;
/**
* Set base64 SIMD wasm file in text format.
* @param wasmSimdLib Base64'd wasm file in text format.
*/
static setWasmSimdLib(wasmSimdLib: string): void;
/**
* Set base64 wasm file with SIMD and pthread feature.
* @param wasmPThread Base64'd wasm file to use to initialize wasm.
*/
static setWasmPThread(wasmPThread: string): void;
/**
* Set base64 SIMD and thread wasm file in text format.
* @param wasmPThreadLib Base64'd wasm file in text format.
*/
static setWasmPThreadLib(wasmPThreadLib: string): void;
static setSdk(sdk: string): void;
/**
* Trains a model from an existing Rhino context (.rhn) and new sets of slot values.
*
* @param accessKey AccessKey generated by Picovoice Console.
* @param writePath Absolute path where the trained model will be saved in IndexedDB.
* @param language Two character language code for the model (e.g. 'en', 'fr').
* Check https://picovoice.ai/docs/model-api/rhino/ for supported languages.
* @param rhinoContext RhinoContext object containing a base64 representation of or path to a
* public binary Rhino context model.
* @param model RhinoModel configuration to be used for training.
* @param slots Object mapping existing slot names to the set of values that will replace
* the corresponding entries in the YAML's `context.slots` section. Each value must be a non-empty
* set of strings.
* @returns A new RhinoContext object containing the trained context. Pass this to `.create()`.
* Object must have 'forceWrite: false' or be empty for Rhino to initialize.
*/
static trainContextFromDynamicSlots(accessKey: string, writePath: string, language: string, rhinoContext: RhinoContext, model: RhinoModel, slots: Record>): Promise;
/**
* Trains a model using a YAML configuration file.
*
* @param accessKey AccessKey obtained from Picovoice Console.
* @param writePath Absolute path where the trained model will be saved in IndexedDB.
* @param language Two character language code for the model (e.g. 'en', 'fr').
* Check https://picovoice.ai/docs/model-api/rhino/ for supported languages.
* @param yamlContent YAML configuration in string to be used for training.
* @returns A new RhinoContext object containing the trained context. Pass this to `.create()`.
* Object must have 'forceWrite: false' or be empty for Rhino to initialize.
*/
static trainContextFromYaml(accessKey: string, writePath: string, language: string, yamlContent: string): Promise;
/**
* Creates an instance of the Rhino Speech-to-Intent engine.
* The model size is large, hence it will try to use the existing one if it exists,
* otherwise saves the model in storage.
* Behind the scenes, it requires the WebAssembly code to load and initialize before
* it can create an instance.
*
* @param accessKey AccessKey generated by Picovoice Console.
* @param context RhinoContext object containing a base64
* representation of or path to public binary of a Rhino context model .
* @param inferenceCallback User-defined callback invoked upon processing a frame of audio.
* The only input argument is an object of type RhinoInference.
* @param model RhinoModel object containing a base64 string
* representation of or path to public binary of a Rhino parameter model used to initialize Rhino.
* @param options Optional configuration arguments.
* @param 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}`, 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 options.endpointDurationSec Endpoint duration in seconds.
* An endpoint is a chunk of silence at the end of an utterance that marks
* the end of spoken command. It should be a positive number within [0.5, 5].
* A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration
* assures Rhino doesn't return inference preemptively in case the user pauses before finishing the request.
* @param options.requireEndpoint If set to `true`, Rhino requires an endpoint (a chunk of silence)
* after the spoken command. If set to `false`, Rhino tries to detect silence, but if it cannot,
* it still will provide inference regardless. Set to `false` only if operating in an
* environment with overlapping speech (e.g. people talking in the background).
* @param options.processErrorCallback User-defined callback invoked if any error happens
* while processing the audio stream. Its only input argument is the error message.
*
* @returns An instance of the Rhino engine.
*/
static create(accessKey: string, context: RhinoContext, inferenceCallback: InferenceCallback, model: RhinoModel, options?: RhinoOptions): Promise;
static _init(accessKey: string, contextPath: string, sensitivity: number, inferenceCallback: InferenceCallback, modelPath: string, options?: RhinoOptions): Promise;
/**
* Processes a frame of audio. The required sample rate can be retrieved from '.sampleRate' and the length
* of frame (number of audio samples per frame) can be retrieved from '.frameLength' The audio needs to be
* 16-bit linearly-encoded. Furthermore, the engine operates on single-channel audio.
*
* @param pcm A frame of audio with properties described above.
*/
process(pcm: Int16Array): Promise;
private _getSlot;
private _getSlotValue;
/**
* Resets the internal Rhino state.
*/
reset(): Promise;
/**
* Releases resources acquired by WebAssembly module.
*/
release(): Promise;
onmessage(e: MessageEvent): Promise;
private static initWasm;
/**
* Lists all available devices that Rhino can use for inference.
* Each entry in the list can be the used as the `device` argument for the `.create` method.
*
* @returns List of all available devices that Rhino can use for inference.
*/
static listAvailableDevices(): Promise;
private static getMessageStack;
protected static wrapAsyncFunction(module: RhinoModule, functionName: string, numArgs: number): (...args: any[]) => any;
}
export {};
//# sourceMappingURL=rhino.d.ts.map