Eagle Speaker Recognition
Web API
API Reference for the Eagle Web SDK (npm).
Eagle
Class for using the recognizer component of the Eagle Speaker Recognition engine on the main application thread. The recognizer processes incoming audio in consecutive frames and emits a similarity score for each enrolled speaker.
Eagle.create()
Creates an instance of the recognizer component of the Eagle Speaker Recognition engine.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelEagleModel : Eagle model options.optionsEagleOptions: Optional configuration arguments:devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.voiceThresholdnumber : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence values at the cost of potentially missing frames of voice.
Returns
Eagle: An instance of the Eagle.
Eagle.listAvailableDevices()
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
- string[] : List of all available devices that Eagle can use for inference.
Eagle.process()
Processes a frame of audio and returns a list of similarity scores for each speaker profile.
Parameters
pcmInt16Array : A frame 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.sampleRateand be 16-bit linearly-encoded. Eagle operates on single-channel audio.speakerProfilesEagleProfile[] | EagleProfile : One or more Eagle speaker profiles. These can be constructed usingEagleProfiler.
Returns
- number[] | null : A list of similarity scores for each speaker profile or null. A higher score indicates that the voice belongs to the corresponding speaker. The range is [0, 1] with 1 representing a perfect match. A result of null indicates that there was not enough voice in the audio to recognize any speakers.
Eagle.release()
Releases resources acquired by Eagle.
EagleProfiler.minProcessSamples
The minimum length of the input pcm required by .process().
Eagle.sampleRate
Audio sample rate accepted by Eagle.
Eagle.version
Version of Eagle.
EagleModel
Eagle model type.
base64string: The model file (.pv) in base64 string to initialize Koala.publicPathstring: The model file (.pv) path relative to the public directory.customWritePathstring : Custom path to save the model in storage. Set to a different name to use multiple models across Eagle instances.forceWriteboolean : Flag to overwrite the model in storage even if it exists.versionnumber : Version of the model file. Increment to update the model file in storage.
EagleProfile
Eagle speaker profile. Can be created by calling .export() after a successful speaker enrollment.
bytesUint8Array: Binary array containing the Eagle speaker profile.
EagleProfiler
Class for using the profiler component of the Eagle Speaker Recognition engine on the main thread of your application. The profiler is responsible for enrolling a speaker given a set of utterances and exporting a speaker profile.
EagleProfiler.create()
Creates an instance of the profiler component of the Eagle Speaker Recognition engine.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelEagleModel : Eagle model options.optionsEagleProfilerOptions: Optional configuration arguments:devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.minEnrollmentChunksnumber : Minimum number of chunks to be processed before enroll returns 100%. The value should be a number greater than or equal to 1. A higher number results in more accurate profiles at the cost of needing more data to create the profile.voiceThresholdnumber : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence values at the cost of potentially missing frames of voice.
Returns
EagleProfiler: An instance of the EagleProfiler.
EagleProfiler.enroll()
Enrolls a speaker. This function should be called multiple times with different utterances of the same speaker
until the enrollment 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 voice
profile.
The number of required samples can be obtained by
calling .frameLength.
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
Parameters
pcmInt16Array : Audio data. The audio needs to have a sample rate equal to.sampleRateand be 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
Returns
- number : The percentage of enrollment completed.
EagleProfiler.flush()
Marks the end of the audio stream, flushes internal state of the object, and returns the percentage of enrollment completed.
Returns
- number : The percentage of enrollment completed.
EagleProfiler.export()
Exports the speaker profile of the current session. Will throw error if the profile is not ready.
Returns
- EagleProfile : The Eagle speaker profile.
EagleProfiler.reset()
Resets the internal state of Eagle Profiler. It should be called before starting a new enrollment session.
EagleProfiler.release()
Releases resources acquired by Eagle Profiler.
EagleProfiler.frameLength
Number of audio samples per frame expected by EagleProfiler (i.e. length of the array passed into .enroll())
EagleProfiler.sampleRate
Audio sample rate accepted by Eagle.
EagleProfiler.version
Version of Eagle.
EagleProfilerWorker
Class for using the profiler component of the Eagle Speaker Recognition engine on a worker thread. The profiler is responsible for enrolling a speaker given a set of utterances and exporting a speaker profile.
EagleProfilerWorker.create()
Creates an instance of the profiler component of the Eagle Speaker Recognition engine.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelEagleModel : Eagle model options.optionsEagleProfilerOptions: Optional configuration arguments:devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.minEnrollmentChunksnumber : Minimum number of chunks to be processed before enroll returns 100%. The value should be a number greater than or equal to 1. A higher number results in more accurate profiles at the cost of needing more data to create the profile.voiceThresholdnumber : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence values at the cost of potentially missing frames of voice.
Returns
EagleProfilerWorker: An instance of the EagleProfilerWorker.
EagleProfilerWorker.enroll()
Enrolls a speaker. This function should be called multiple times with different utterances of the same speaker
until the enrollment 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 voice
profile.
The number of required samples can be obtained by
calling .frameLength.
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
Parameters
pcmInt16Array : Audio data. The audio needs to have a sample rate equal to.sampleRateand be 16-bit linearly-encoded. EagleProfilerWorker operates on single-channel audio.
Returns
- number : The percentage of enrollment completed.
EagleProfilerWorker.flush()
Marks the end of the audio stream, flushes internal state of the object, and returns the percentage of enrollment completed.
Returns
- number : The percentage of enrollment completed.
EagleProfilerWorker.export()
Exports the speaker profile of the current session. Will throw error if the profile is not ready.
Returns
- EagleProfile : The Eagle speaker profile.
EagleProfilerWorker.reset()
Resets the internal state of Eagle Profiler. It should be called before starting a new enrollment session.
EagleProfilerWorker.release()
Releases resources acquired by Eagle Profiler.
EagleProfilerWorker.terminate()
Force terminates the instance of EagleProfilerWorker.
EagleProfilerWorker.frameLength
Number of audio samples per frame expected by Eagle (i.e. length of the array passed into .enroll())
EagleProfilerWorker.sampleRate
Audio sample rate accepted by Eagle.
EagleProfilerWorker.version
Version of Eagle.
EagleWorker
Class for using the recognizer component of the Eagle Speaker Recognition engine on a worker thread. The recognizer processes incoming audio in consecutive frames and emits a similarity score for each enrolled speaker.
EagleWorker.create()
Creates an instance of the recognizer component of the Eagle Speaker Recognition engine.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.modelEagleModel : Eagle model options.optionsEagleOptions: Optional configuration arguments:devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.voiceThresholdnumber : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence values at the cost of potentially missing frames of voice.
Returns
EagleWorker: An instance of the EagleWorker.
EagleWorker.process()
Processes a frame of audio and returns a list of similarity scores for each speaker profile.
Parameters
pcmInt16Array : A frame 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.sampleRateand be 16-bit linearly-encoded. Eagle operates on single-channel audio.speakerProfilesEagleProfile[] | EagleProfile : One or more Eagle speaker profiles. These can be constructed usingEagleProfiler.
Returns
- number[] | null : A list of similarity scores for each speaker profile or null. A higher score indicates that the voice belongs to the corresponding speaker. The range is [0, 1] with 1 representing a perfect match. A result of null indicates that there was not enough voice in the audio to recognize any speakers.
EagleWorker.release()
Releases resources acquired by EagleWorker
EagleWorker.terminate()
Force terminates the instance of EagleWorker.
EagleWorker.minProcessSamples
The minimum length of the input pcm required by .process().
EagleWorker.sampleRate
Audio sample rate accepted by Eagle.
EagleWorker.version
Version of Eagle.