Eagle Speaker Recognition
Node.js API
API Reference for the Eagle Node.js SDK (npm).
Eagle
Class for using the recognizer component of the Eagle Speaker Recognition engine. The recognizer processes incoming audio in consecutive frames and emits a similarity score for each enrolled speaker.
Eagle can be initialized using the class constructor().
Resources should be cleaned when you are done using the release() method.
Eagle.constructor()
Eagle constructor.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.speakerProfilesUint8Array[] | Uint8Array : One or more Eagle speaker profiles. These can be constructed usingEagleProfiler.optionsEagleOptions: Optional configuration arguments:modelPathstring : Path to the file containing model parameters (.pv).libraryPathstring : Path to the Eagle dynamic library (.node).
Returns
Eagle: An instance of Eagle platform.
Eagle.release()
Releases resources acquired by Eagle.
Eagle.reset()
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.
Eagle.frameLength
Getter for number of audio samples per frame expected by Eagle (i.e. length of the array passed into .process())
Eagle.sampleRate
Getter for audio sample rate accepted by Eagle.
Eagle.version
Getter for Eagle version.
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 number of samples per frame can be attained by calling.frameLength. The incoming audio needs to have a sample rate equal to.sampleRateand be 16-bit linearly-encoded. Eagle operates on single-channel audio.
Returns
- number[] : 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.
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.constructor()
Creates an instance of the profiler component of the Eagle Speaker Recognition engine.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.optionsEagleOptions: Optional configuration arguments:modelPathstring : Path to the file containing model parameters (.pv).libraryPathstring : Path to the Eagle dynamic library (.node).
Returns
EagleProfiler: An instance of the EagleProfiler.
EagleProfiler.frameLength
Getter for number of audio samples per frame expected by EagleProfiler (i.e. length of the array passed into .enroll())
EagleProfiler.sampleRate
Getter for audio sample rate accepted by EagleProfiler.
EagleProfiler.version
Getter for EagleProfiler version.
EagleProfiler.minEnrollSamples
The minimum length of the input pcm required by .enroll().
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 minimum number of required samples 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
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
- EnrollProgress : The percentage of completeness of the speaker enrollment process along with the feedback code corresponding to the last enrollment attempt.
EagleProfiler.export()
Exports the speaker profile of the current session. Will throw error if the profile is not ready.
Returns
- Uint8Array : 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.
EagleProfilerEnrollFeedback
NONE: 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.
EnrollProgress
Type for storing the results of .enroll().
feedbackEagleProfilerEnrollFeedback : A feedback code corresponding to the last enrollment attempt.percentagenumber : The percentage of completeness of the speaker enrollment process.