Eagle Speaker Recognition
Python API
API Reference for the Python Eagle SDK (PyPI).
pveagle.available_devices()
Lists all available devices that Eagle can use for inference. Each entry in the list can be the device argument of create_profiler() factory method or create_recognizer constructor.
Parameters
library_pathOptional[str] : Absolute path to Eagle's dynamic library. If not set it will be set to the default location.
Returns
- Sequence[str]: List of all available devices that Eagle can use for inference.
Throws
pveagle.create_profiler()
Factory method for the profiler component of the Eagle speaker recognition engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.model_pathOptional[str] : Absolute path to the file containing model parameters.deviceOptional[str] : 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.min_enrollment_chunksint : 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.voice_thresholdfloat : 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.library_pathOptional[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_keystr : AccessKey obtained from Picovoice Console.speaker_profilesUnion[Sequence[EagleProfile], EagleProfile] : An instance of EagleProfiler or a list of EagleProfiler instances. Each profile corresponds to a speaker enrolled in the system.model_pathOptional[str] : Absolute path to the file containing model parameters.deviceOptional[str] : 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.voice_thresholdfloat : 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.library_pathOptional[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_keystr : AccessKey obtained from Picovoice Console.model_pathstr : Absolute path to the file containing model parameters.deviceOptional[str] : 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.min_enrollment_chunksint : 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.voice_thresholdfloat : 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.library_pathstr : 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 number of required samples can be obtained by
calling .frame_length.
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
pcmSequence[int] : Audio data. The audio needs to have a sample rate equal to.sample_rateand be 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
Returns
- float : The percentage of enrollment completed.
Throws
pveagle.EagleProfiler.flush()
Marks the end of the audio stream, flushes internal state of the object, and returns the percentage of enrollment completed.
Returns
- float : The percentage of enrollment completed.
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.frame_length
Number of audio samples per frame expected by EagleProfiler, i.e. length of the array passed
into .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
profilebytes : 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.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_keystr : AccessKey obtained from Picovoice Console.model_pathstr : Absolute path to the file containing model parameters.deviceOptional[str] : 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.voice_thresholdfloat : 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.library_pathstr : Absolute path to Eagle's dynamic library.
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
pcmSequence[int] : A frame of audio samples. The minimum number of samples per frame can be attained by calling.frame_length. The incoming audio needs to have a sample rate equal to.sample_rateand be 16-bit linearly-encoded. Eagle operates on single-channel audio.speaker_profilesSequence[EagleProfile] : A list of EagleProfile objects. This can be constructed usingEagleProfiler.
Returns
- Optional[Sequence[float]] : A list of similarity scores for each speaker profile or None. 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 None indicates that there was not enough voice in the audio to recognize any speakers.
Throws
pveagle.Eagle.delete()
Releases resources acquired by Eagle.
Throws
pveagle.Eagle.sample_rate
Audio sample rate accepted by Eagle.
pveagle.Eagle.min_process_samples
The minimum length of the input pcm required by .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