/// <reference types="emscripten" />
import { Mutex } from 'async-mutex';
import { EagleModel, EagleOptions, EagleProfile, EagleProfilerEnrollResult, EagleProfilerOptions } from './types';
type pv_eagle_profiler_enroll_min_audio_length_samples_type = (object: number, numSamples: number) => number;
type pv_eagle_profiler_export_type = (object: number, speakerProfile: number) => number;
type pv_eagle_profiler_export_size_type = (object: number, speakerProfileSizeBytes: number) => number;
type pv_eagle_frame_length_type = () => number;
type pv_eagle_version_type = () => number;
type pv_eagle_list_hardware_devices_type = (hardwareDevices: number, numHardwareDevices: number) => number;
type pv_eagle_free_hardware_devices_type = (hardwareDevices: number, numHardwareDevices: number) => number;
type pv_sample_rate_type = () => 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;
type EagleModule = EmscriptenModule & {
    _pv_free: (address: number) => void;
    _pv_eagle_profiler_enroll_min_audio_length_samples: pv_eagle_profiler_enroll_min_audio_length_samples_type;
    _pv_eagle_profiler_export: pv_eagle_profiler_export_type;
    _pv_eagle_profiler_export_size: pv_eagle_profiler_export_size_type;
    _pv_eagle_frame_length: pv_eagle_frame_length_type;
    _pv_eagle_version: pv_eagle_version_type;
    _pv_eagle_list_hardware_devices: pv_eagle_list_hardware_devices_type;
    _pv_eagle_free_hardware_devices: pv_eagle_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;
};
type EagleBaseWasmOutput = {
    module: EagleModule;
    sampleRate: number;
    version: string;
    messageStackAddressAddressAddress: number;
    messageStackDepthAddress: number;
};
declare class EagleBase {
    protected _module?: EagleModule;
    protected readonly _functionMutex: Mutex;
    protected readonly _messageStackAddressAddressAddress: number;
    protected readonly _messageStackDepthAddress: number;
    protected readonly _sampleRate: number;
    protected readonly _version: string;
    protected static _wasmSimd: string;
    protected static _wasmSimdLib: string;
    protected static _wasmPThread: string;
    protected static _wasmPThreadLib: string;
    protected static _sdk: string;
    protected static _eagleMutex: Mutex;
    protected constructor(handleWasm: EagleBaseWasmOutput);
    /**
     * Audio sample rate required by Eagle.
     */
    get sampleRate(): number;
    /**
     * Version of Eagle.
     */
    get version(): 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;
    protected static _initBaseWasm(wasmBase64: string, wasmLibBase64: string, createModuleFunc: any): Promise<EagleBaseWasmOutput>;
    /**
     * Releases resources acquired by Eagle
     */
    release(): Promise<void>;
    protected static getMessageStack(pv_get_error_stack: pv_get_error_stack_type, pv_free_error_stack: pv_free_error_stack_type, messageStackAddressAddressAddress: number, messageStackDepthAddress: number, memoryBufferInt32: Int32Array, memoryBufferUint8: Uint8Array): Promise<string[]>;
    protected static wrapAsyncFunction(module: EagleModule, functionName: string, numArgs: number): (...args: any[]) => any;
}
/**
 * JavaScript/WebAssembly binding for the profiler of the Eagle Speaker Recognition engine.
 * It enrolls a speaker given a set of utterances and then constructs a profile for the enrolled speaker.
 */
export declare class EagleProfiler extends EagleBase {
    private readonly _pv_eagle_profiler_enroll;
    private readonly _pv_eagle_profiler_reset;
    private readonly _pv_eagle_profiler_delete;
    private readonly _objectAddress;
    private readonly _feedbackAddress;
    private readonly _percentageAddress;
    private readonly _maxEnrollSamples;
    private readonly _minEnrollSamples;
    private readonly _profileSize;
    private constructor();
    /**
     * The minimum length of the input pcm required by `.enroll()`.
     */
    get minEnrollSamples(): number;
    /**
     * Creates an instance of profiler component of the Eagle Speaker Recognition Engine.
     *
     * @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).
     * @param model Eagle model options.
     * @param model.base64 The model in base64 string to initialize Eagle.
     * @param model.publicPath The model path relative to the public directory.
     * @param model.customWritePath Custom path to save the model in storage.
     * Set to a different name to use multiple models across `eagle` instances.
     * @param model.forceWrite Flag to overwrite the model in storage even if it exists.
     * @param model.version Version of the model file. Increment to update the model file in storage.
     * @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.
     *
     * @return An instance of the Eagle Profiler.
     */
    static create(accessKey: string, model: EagleModel, options?: EagleProfilerOptions): Promise<EagleProfiler>;
    static _init(accessKey: string, modelPath: string, options?: EagleProfilerOptions): Promise<EagleProfiler>;
    /**
     * Enrolls a speaker. This function should be called multiple times with different utterances of the same speaker
     * until `percentage` reaches `100.0`, at which point a speaker voice profile can be exported using `.export()`.
     * Any further enrollment can be used to improve the speaker profile. The minimum length of the input pcm to
     * `.enroll()` can be obtained by calling `.minEnrollSamples`.
     * The audio data used for enrollment should satisfy the following requirements:
     *    - only one speaker should be present in the audio
     *    - the speaker should be speaking in a normal voice
     *    - the audio should contain no speech from other speakers and no other sounds (e.g. music)
     *    - it should be captured in a quiet environment with no background noise
     * @param pcm Audio data for enrollment. The audio needs to have a sample rate equal to `.sampleRate` and be
     * 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
     *
     * @return The percentage of completeness of the speaker enrollment process along with the feedback code
     * corresponding to the last enrollment attempt:
     *    - `AUDIO_OK`: The audio is good for enrollment.
     *    - `AUDIO_TOO_SHORT`: Audio length is insufficient for enrollment,
     *       i.e. it is shorter than`.min_enroll_samples`.
     *    - `UNKNOWN_SPEAKER`: There is another speaker in the audio that is different from the speaker
     *       being enrolled. Too much background noise may cause this error as well.
     *    - `NO_VOICE_FOUND`: The audio does not contain any voice, i.e. it is silent or
     *       has a low signal-to-noise ratio.
     *    - `QUALITY_ISSUE`: The audio quality is too low for enrollment due to a bad microphone
     *       or recording environment.
     */
    enroll(pcm: Int16Array): Promise<EagleProfilerEnrollResult>;
    /**
     * Exports the speaker profile of the current session.
     * Will throw error if the profile is not ready.
     *
     * @return An EagleProfile object.
     */
    export(): Promise<EagleProfile>;
    /**
     * Resets the internal state of Eagle Profiler.
     * It should be called before starting a new enrollment session.
     */
    reset(): Promise<void>;
    /**
     * Releases resources acquired by Eagle Profiler
     */
    release(): Promise<void>;
    private static _initProfilerWasm;
}
/**
 * JavaScript/WebAssembly binding for Eagle Speaker Recognition engine.
 * It processes incoming audio in consecutive frames and emits a similarity score for each enrolled speaker.
 */
export declare class Eagle extends EagleBase {
    private readonly _pv_eagle_process;
    private readonly _pv_eagle_reset;
    private readonly _pv_eagle_delete;
    private readonly _objectAddress;
    private readonly _scoresAddress;
    private readonly _frameLength;
    private readonly _numSpeakers;
    private constructor();
    /**
     * Number of audio samples per frame expected by Eagle (i.e. length of the array passed into `.process()`)
     */
    get frameLength(): number;
    /**
     * Creates an instance of the Picovoice Eagle Speaker Recognition Engine.
     *
     * @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
     * @param model Eagle model options.
     * @param model.base64 The model in base64 string to initialize Eagle.
     * @param model.publicPath The model path relative to the public directory.
     * @param model.customWritePath Custom path to save the model in storage.
     * Set to a different name to use multiple models across `eagle` instances.
     * @param model.forceWrite Flag to overwrite the model in storage even if it exists.
     * @param model.version Version of the model file. Increment to update the model file in storage.
     * @param speakerProfiles One or more Eagle speaker profiles. These can be constructed using `EagleProfiler`.
     * @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.
     *
     * @return An instance of the Eagle engine.
     */
    static create(accessKey: string, model: EagleModel, speakerProfiles: EagleProfile[] | EagleProfile, options?: EagleOptions): Promise<Eagle>;
    static _init(accessKey: string, modelPath: string, speakerProfiles: EagleProfile[], options?: EagleOptions): Promise<Eagle>;
    /**
     * Processes a frame of audio and returns a list of similarity scores for each speaker profile.
     *
     * @param pcm A frame of audio samples. The number of samples per frame can be attained by calling
     * `.frameLength`. The incoming audio needs to have a sample rate equal to `.sampleRate` and be 16-bit
     * linearly-encoded. Eagle operates on single-channel audio.
     *
     * @return A list of similarity scores for each speaker profile. A higher score indicates that the voice
     * belongs to the corresponding speaker. The range is [0, 1] with 1.0 representing a perfect match.
     */
    process(pcm: Int16Array): Promise<number[]>;
    /**
     * Resets the internal state of the engine.
     * It is best to call before processing a new sequence of audio (e.g. a new voice interaction).
     * This ensures that the accuracy of the engine is not affected by a change in audio context.
     */
    reset(): Promise<void>;
    /**
     * Releases resources acquired by Eagle
     */
    release(): Promise<void>;
    /**
     * Lists all available devices that Eagle 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 Eagle can use for inference.
     */
    static listAvailableDevices(): Promise<string[]>;
    private static _initWasm;
}
export {};
//# sourceMappingURL=eagle.d.ts.map