Eagle Speaker Recognition
Android API
API Reference for the Android Eagle SDK (eagle-android)
package: ai.picovoice.eagle
Eagle
Class for the Eagle speaker recognition engine.
Eagle must be initialized using the Eagle.Builder Class. Resources should be cleaned when you are done using the delete() function.
Eagle.delete()
Releases resources acquired by Eagle.
Eagle.getAvailableDevices()
Lists all available devices that Eagle can use for inference.
Each entry in the list can be used as the device argument when initializing Eagle.
Returns
String[]: Array of all available devices thatEaglecan be used for inference.
Throws
EagleException: If an error occurs while getting available devices.
Eagle.getMinProcessSamples()
Getter for minimum length of the input pcm required by .process().
Returns
int: minimum length of the input pcm.
Eagle.getSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int: Required audio sample rate for PCM data.
Eagle.getVersion()
Getter for version.
Returns
String: CurrentEagleversion.
Eagle.process()
Processes a frame of audio and returns a list of similarity scores for each speaker profile.
Parameters
pcmshort[] : A frame of audio samples. The minimum number of samples per frame can be attained by calling.getMinProcessSamples(). The incoming audio needs to have a sample rate equal to.getSmapleRateand be 16-bit linearly-encoded. Eagle operates on single-channel audio.'speakerProfilesEagleProfile[] : Array of speaker profiles created withEagleProfiler.
Returns
float[] | 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.
Throws
EagleException: If there is an error while processing the audio frame.
Eagle.Builder
Builder for creating an instance of Eagle with a mixture of default arguments.
Eagle.Builder.build()
Creates an instance of Eagle speaker recognition engine.
Parameters
contextContext : The Android app context.
Returns
Eagle: An instance of Eagle speaker recognition engine.
Throws
EagleException: If an error occurs while creating an instance of Eagle speaker recognition engine.
Eagle.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKeyString : AccessKey obtained from Picovoice Console.
Returns
Eagle.Builder: Modified Eagle.Builder object.
Eagle.Builder.setModelPath()
Sets the model path of the builder.
Parameters
modelPathString : Path to the file containing model parameters (.pv). Can be either a path that is relative to the project'sassetsfolder or an absolute path to the file on device.
Returns
Eagle.Builder: Modified Eagle.Builder object.
Eagle.Builder.setDevice()
Sets the device of the builder. If not set it will be set to the default device best.
Parameters
deviceString : String representation of the device (e.g., CPU or GPU) to use for inference. 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.
Returns
Eagle.Builder: Modified Eagle.Builder object.
Eagle.Builder.setVoiceThreshold()
Sets the voice threshold of the builder.
Parameters
voiceThresholdfloat : 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.Builder: Modified Eagle.Builder object.
EagleException
Exception thrown if an error occurs within Eagle speaker recognition engine.
Exceptions:
EagleProfile
Type which represents a speaker profile. The object can be serialized (via .getBytes()) and deserialized (via constructor) for reuse. Resources must explicitly be released by calling .delete().
Parameters
metadataBytesbyte[] : A byte array previously obtained via.getBytes().
EagleProfile.getBytes()
Gets the metadata in the form of a byte array.
Returns
byte[]: The metadata in the form of a byte array.
EagleProfile.delete()
Releases resources acquired by EagleProfile.
EagleProfiler
Class for the profiler component of the Eagle speaker recognition engine.
EagleProfiler.delete()
Releases resources acquired by EagleProfiler.
EagleProfiler.getAvailableDevices()
Lists all available devices that EagleProfiler can use for inference.
Each entry in the list can be used as the device argument when initializing EagleProfiler.
Returns
String[]: Array of all available devices thatEagleProfilercan be used for inference.
Throws
EagleException: If an error occurs while getting available devices.
EagleProfiler.getFrameLength()
Getter for number of audio samples per frame.
Returns
int: Number of audio samples per frame.
EagleProfiler.getSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int: Required audio sample rate for PCM data.
EagleProfiler.getVersion()
Getter for version.
Returns
String: CurrentEagleversion.
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 .getFrameLength().
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.getSampleRate()and be 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
Returns
float: The percentage of enrollment completed.
Throws
EagleException: If an error occurs while enrolling speaker.
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
EagleException: If an error occurs while enrolling speaker.
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
EagleException: If an error occurs while exporting speaker.
EagleProfiler.reset()
Resets the internal state of Eagle Profiler. It should be called before starting a new enrollment session.
Throws
EagleException: If an error occurs while resetting speaker.
EagleProfiler.Builder
Builder for creating an instance of the EagleProfiler with a mixture of default arguments.
EagleProfiler.Builder.build()
Creates an instance of the EagleProfiler.
Parameters
contextContext : The Android app context.
Returns
EagleProfiler: An instance of the EagleProfiler.
Throws
EagleException: If an error occurs while creating an instance of the EagleProfiler.
EagleProfiler.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKeyString : AccessKey obtained from Picovoice Console.
Returns
EagleProfiler.Builder: Modified EagleProfiler.Builder object.
EagleProfiler.Builder.setModelPath()
Sets the model path of the builder.
Parameters
modelPathString : Path to the file containing model parameters (.pv). Can be either a path that is relative to the project'sassetsfolder or an absolute path to the file on device.
Returns
EagleProfiler.Builder: Modified EagleProfiler.Builder object.
EagleProfiler.Builder.setDevice()
Sets the device of the builder. If not set it will be set to the default device best.
Parameters
deviceString : String representation of the device (e.g., CPU or GPU) to use for inference. 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.
Returns
EagleProfiler.Builder: Modified EagleProfiler.Builder object.
EagleProfiler.Builder.setMinEnrollmentChunks()
Sets the min enrollment chunks of the builder.
Parameters
minEnrollmentChunksint : 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.
Returns
EagleProfiler.Builder: Modified EagleProfiler.Builder object.
EagleProfiler.Builder.setVoiceThreshold()
Sets the voice threshold of the builder.
Parameters
voiceThresholdfloat : 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.Builder: Modified EagleProfiler.Builder object.