/// import { Mutex } from 'async-mutex'; import { EagleModel, EagleOptions, EagleProfile, EagleProfilerOptions } from './types'; type pv_eagle_profiler_frame_length_type = () => 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_process_min_audio_length_samples_type = (object: number, numSamples: number) => 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_export: pv_eagle_profiler_export_type; _pv_eagle_profiler_export_size: pv_eagle_profiler_export_size_type; _pv_eagle_profiler_frame_length: pv_eagle_profiler_frame_length_type; _pv_eagle_process_min_audio_length_samples: pv_eagle_process_min_audio_length_samples_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; /** * Releases resources acquired by Eagle */ release(): Promise; 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; 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_flush; private readonly _pv_eagle_profiler_reset; private readonly _pv_eagle_profiler_delete; private readonly _objectAddress; private readonly _percentageAddress; private readonly _frameLength; private readonly _profileSize; private constructor(); /** * The length of the input pcm required by `.enroll()`. */ get frameLength(): 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. * @param options.minEnrollmentChunks Minimum number of chunks to be processed before enroll returns 100% * @param options.voiceThreshold Sensitivity threshold for detecting voice. * * @return An instance of the Eagle Profiler. */ static create(accessKey: string, model: EagleModel, options?: EagleProfilerOptions): Promise; static _init(accessKey: string, modelPath: string, options?: EagleProfilerOptions): Promise; /** * 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. */ enroll(pcm: Int16Array): Promise; /** * Marks the end of the audio stream, flushes internal state of the object, and returns the percentage of enrollment * completed. * * @return The percentage of completeness of the speaker enrollment process. */ flush(): Promise; /** * Exports the speaker profile of the current session. * Will throw error if the profile is not ready. * * @return An EagleProfile object. */ export(): Promise; /** * Resets the internal state of Eagle Profiler. * It should be called before starting a new enrollment session. */ reset(): Promise; /** * Releases resources acquired by Eagle Profiler */ release(): Promise; 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_scores_delete; private readonly _pv_eagle_delete; private readonly _objectAddress; private readonly _scoresAddressAddress; private readonly _minProcessSamples; private constructor(); /** * Number of audio samples per frame expected by Eagle (i.e. length of the array passed into `.process()`) */ get minProcessSamples(): 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 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.voiceThreshold Sensitivity threshold for detecting voice. * * @return An instance of the Eagle engine. */ static create(accessKey: string, model: EagleModel, options?: EagleOptions): Promise; static _init(accessKey: string, modelPath: string, options?: EagleOptions): Promise; /** * Processes audio and returns a list of similarity scores for each speaker profile. * * @param pcm Array of audio samples. The minimum number of samples per frame can be attained by calling * `.minProcessSamples`. The incoming audio needs to have a sample rate equal to `.sampleRate` and be 16-bit * linearly-encoded. Eagle operates on single-channel audio. * @param speakerProfiles One or more Eagle speaker profiles. These can be constructed using `EagleProfiler`. * * @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, speakerProfiles: EagleProfile[] | EagleProfile): Promise; /** * Releases resources acquired by Eagle */ release(): Promise; /** * 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; private static _initWasm; } export {}; //# sourceMappingURL=eagle.d.ts.map