Eagle Speaker Recognition
C API
API Reference for the Eagle C SDK.
pv_eagle_profiler_t
Struct representing the profiler component of the Eagle Speaker Recognition engine.
pv_eagle_profiler_init()
Creates an instance of the profiler component of the Eagle Speaker Recognition engine. Resources should be cleaned when you are done using the pv_eagle_profiler_delete() function.
Parameters
access_key
const char * : AccessKey obtained from Picovoice Console.model_path
const char * : Absolute path to the file containing model parameters (.pv
).object
pv_eagle_profiler_t * * : Constructed instance of the Eagle profiler.
Returns
- pv_status_t : Status code.
pv_eagle_profiler_delete()
Releases resources acquired by the Eagle profiler.
Parameters
object
pv_eagle_profiler_t * : Eagle profiler object.
pv_eagle_profiler_enroll()
Enrolls a speaker. This function should be called multiple times with different utterances of the same speaker
until 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 pv_eagle_profiler_enroll_min_audio_length_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 (i.e. not whispering or shouting)
- 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
object
pv_eagle_profiler_t * : Eagle profiler object.pcm
int16_t : Audio data. The required sample rate can be attained by calling pv_sample_rate(). The required audio format is 16-bit linearly-encoded single-channel PCM. The minimum audio length required for enrollment can be attained by callingpv_eagle_profiler_enroll_min_audio_length_samples()
.num_samples
int32_t : Number of audio samples inpcm
.feedback
pv_eagle_profiler_enroll_feedback_t * : Feedback code. If any problems arise with the provided input audio, it will be assigned a suitable feedback code to indicate the potential issue:PV_EAGLE_PROFILER_ENROLL_FEEDBACK_AUDIO_TOO_SHORT
: The audio is too short, i.e. it contains less than the minimum number of required samples,PV_EAGLE_PROFILER_ENROLL_FEEDBACK_UNKNOWN_SPEAKER
: The speaker is unknown, i.e. the speaker is not the same as the one enrolled in the previous enrollment,PV_EAGLE_PROFILER_ENROLL_FEEDBACK_NO_VOICE_FOUND
: The audio does not contain any speech,PV_EAGLE_PROFILER_ENROLL_FEEDBACK_QUALITY_ISSUE
: The audio is too noisy or the speaker is speaking in a low voice.
otherwise, it will be set to
PV_EAGLE_PROFILER_ENROLL_FEEDBACK_AUDIO_OK
.percentage
float : Percentage of enrollment progress. When this value reaches100.0
, the enrollment process is complete.
Returns
- pv_status_t : Status code.
pv_eagle_profiler_enroll_min_audio_length_samples()
Gets the minimum length of the input pcm required by pv_eagle_profiler_enroll()
.
Parameters
object
pv_eagle_profiler_t * : Eagle profiler object.
Returns
- pv_status_t : Status code.
pv_eagle_profiler_export()
Exports the speaker profile to a buffer. The exported profile can be used in pv_eagle_init()
or stored for later use.
Parameters
object
pv_eagle_profiler_t * : Eagle profiler object.speaker_profile
void * : Buffer where the speaker profile will be stored. Must be pre-allocated with a size obtained by callingpv_eagle_profiler_export_size()
.
Returns
- pv_status_t : Status code.
pv_eagle_profiler_reset()
Resets the EagleProfiler object and removes all enrollment data. It must be called before enrolling a new speaker.
Parameters
object
pv_eagle_profiler_t * : Eagle profiler object.
Returns
- pv_status_t : Status code.
pv_eagle_profiler_enroll_feedback_t
Enrollment feedback enum.
pv_eagle_profiler_enroll_feedback_to_string()
Parameters
status
int32_t : Feedback code.
Returns
- const char * : String representation of feedback code.
pv_eagle_t
Struct representing the recognizer component of the Eagle Speaker Recognition engine.
pv_eagle_init()
Creates an instance of the recognizer component of the Eagle Speaker Recognition engine. Resources should be cleaned when you are done using the pv_eagle_delete() function.
Parameters
access_key
const char * : AccessKey obtained from Picovoice Console.model_path
const char * : Absolute path to the file containing model parameters (.pv
).num_speakers
int32_t : Number of speakers to enroll.speaker_profiles
const void * const * : Speaker profiles. This can be created using the EagleProfiler object and its related functions.object
pv_eagle_t * : Constructed instance of the Eagle engine.
Returns
- pv_status_t : Status code.
pv_eagle_delete()
Releases the resources acquired by the Eagle engine.
Parameters
object
pv_eagle_t * : Eagle object.
Returns
- pv_status_t : Status code.
pv_eagle_process()
Processes a frame of the incoming audio stream. The incoming audio needs to have a sample rate equal
to pv_sample_rate()
.
Parameters
object
pv_eagle_t * : Eagle object.pcm
const int16_t * : A frame of audio samples. The number of samples per frame can be attained by callingpv_eagle_frame_length()
. The incoming audio needs to have a sample rate equal topv_sample_rate()
and be 16-bit linearly-encoded. Eagle operates on single-channel audio.scores
float * : Similarity scores for each enrolled speaker. Must be pre-allocated with a size equal to the number of enrolled speakers. The scores are in the range [0, 1] with 1 being a perfect match.
Returns
- pv_status_t : Status code.
pv_eagle_reset()
Resets the internal state of the Eagle 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.
Parameters
object
pv_eagle_t * : Eagle object.
Returns
- pv_status_t : Status code.
pv_eagle_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_eagle_version()
Getter for version.
Returns
- const char * : Eagle version.
pv_sample_rate()
Audio sample rate accepted by Eagle.
Returns
- int32_t : Sample rate.
pv_status_t
Status code enum.
pv_status_to_string()
Parameters
status
int32_t : Status code.
Returns
- const char * : String representation of status code.
pv_get_error_stack()
If a function returns a failure (any pv_status_t other than PV_STATUS_SUCCESS
), this function can be
called to get a series of error messages related to the failure. This function can only be called only once per
failure status on another function. The memory for message_stack
must be freed using pv_free_error_stack
.
Regardless of the return status of this function, if message_stack
is not NULL
, then message_stack
contains valid memory. However, a failure status on this function indicates that future error messages
may not be reported.
Parameters
message_stack
const char * * * : Array of messages relating to the failure. Messages are NULL terminated strings. The array and messages must be freed usingpv_free_error_stack()
.message_stack_depth
int32_t * : The number of messages in themessage_stack
array.
Returns
- pv_status_t : Returned status code.
pv_free_error_stack()
This function frees the memory used by error messages allocated by pv_get_error_stack()
.
Parameters
message_stack
const char * * * : Array of messages relating to the failure.