Eagle Speaker Recognition
Python API
API Reference for the Python Eagle SDK (PyPI).
pveagle.create_profiler()
Factory method for the profiler component of the Eagle speaker recognition engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.model_path
Optional[str] : Absolute path to the file containing model parameters.library_path
Optional[str] : Absolute path to Eagle's dynamic library.
Returns
EagleProfiler
: An instance of EagleProfiler object.
Throws
pveagle.create_recognizer()
Factory method for the recognizer component of the Eagle speaker recognition engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.speaker_profiles
Union[Sequence[EagleProfile], EagleProfile] : An instance of EagleProfiler or a list of EagleProfiler instances. Each profile corresponds to a speaker enrolled in the system.model_path
Optional[str] : Absolute path to the file containing model parameters.library_path
Optional[str] : Absolute path to Eagle's dynamic library.
Returns
Eagle
: An instance of Eagle object.
Throws
pveagle.EagleProfiler
Class for the profiler component of the Eagle speaker recognition engine.
EagleProfiler can be initialized either using the module
level create_profiler()
function
or directly using the class __init__()
method.
Resources should be cleaned when you are done using the delete()
method.
pveagle.EagleProfiler.__init__()
__init__
method for the profiler component of the Eagle speaker recognition engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.model_path
str : Absolute path to the file containing model parameters.library_path
str : Absolute path to Eagle's dynamic library.
Returns
EagleProfiler
: An instance of EagleProfiler object.
Throws
pveagle.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
. Any further enrollment can be used to improve the speaker voice
profile.
The minimum number of required samples can be obtained by
calling .min_enroll_samples
.
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
pcm
Sequence[int] : Audio data. The audio needs to have a sample rate equal to.sample_rate
and be 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
Returns
- Tuple[float, EagleProfilerEnrollFeedback] : The percentage of completeness of the speaker enrollment process along with the feedback code corresponding to the last enrollment attempt.
Throws
pveagle.EagleProfiler.export()
Exports the speaker profile of the current session. Will raise an exception if the profile is not ready.
Returns
EagleProfile
: An immutable EagleProfile object representing the enrolled speaker.
Throws
pveagle.EagleProfiler.reset()
Resets the internal state of EagleProfiler. It should be called before starting a new enrollment session.
Throws
pveagle.EagleProfiler.delete()
Releases resources acquired by EagleProfiler.
pveagle.EagleProfiler.min_enroll_samples
The minimum length of the input pcm required by .enroll()
.
pveagle.EagleProfiler.sample_rate
Audio sample rate accepted by .enroll()
.
pveagle.EagleProfiler.version
The version string of the Eagle library.
pveagle.EagleProfile
Python representation of an Eagle speaker profile.
pveagle.EagleProfile.from_bytes()
Creates an instance of EagleProfile from a bytes object.
Parameters
profile
bytes : A bytes object containing the profile.
Returns
EagleProfile
: An instance of EagleProfile object.
pveagle.EagleProfile.to_bytes()
Converts the profile to a bytes object.
Returns
- bytes : The profile as a bytes object.
pveagle.EagleProfile.size
The size of the profile in bytes.
pveagle.EagleProfilerEnrollFeedback
Enumeration of possible enrollment feedback codes.
Members
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.
pveagle.Eagle
Class for the recognizer component of the Eagle speaker recognition engine.
Eagle can be initialized either using the module
level create_recognizer()
function
or directly using the class __init__()
method.
Resources should be cleaned when you are done using the delete()
method.
pveagle.Eagle.__init__()
__init__
method for the recognizer component of the Eagle speaker recognition engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.model_path
str : Absolute path to the file containing model parameters.library_path
str : Absolute path to Eagle's dynamic library.speaker_profiles
Sequence[EagleProfile] : A list of EagleProfile objects. This can be constructed usingEagleProfiler
.
Returns
Eagle
: An instance of Eagle object.
Throws
pveagle.Eagle.process()
Processes a frame of audio and returns a list of similarity scores for each speaker profile.
Parameters
pcm
Sequence[int] : A frame of audio samples. The number of samples per frame can be attained by calling.frame_length
. The incoming audio needs to have a sample rate equal to.sample_rate
and be 16-bit linearly-encoded. Eagle operates on single-channel audio.
Returns
- Sequence[float] : 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.
Throws
pveagle.Eagle.reset()
Resets the internal state of the engine. It must be called before processing a new sequence of audio frames.
Throws
pveagle.Eagle.delete()
Releases resources acquired by Eagle.
Throws
pveagle.Eagle.sample_rate
Audio sample rate accepted by Eagle.
pveagle.Eagle.frame_length
Number of audio samples per frame expected by Eagle, i.e. length of the array passed
into .process()
.
pveagle.Eagle.version
The version string of the Eagle library.
pveagle.EagleError
Error thrown if an error occurs within Eagle
Speaker Recognition Engine.
Exceptions