Bat Spoken Language Identification
C API
API Reference for the Bat C SDK.
pv_bat_t
Container representing the Bat Spoken Language Identification object.
pv_bat_init()
Creates a Bat instance. Resources should be cleaned when you are done using the pv_bat_delete() function.
Parameters
access_keyconst char * : AccessKey obtained from Picovoice Console.model_pathconst char * : Absolute path to the file containing model parameters (.pv).devicechar * : 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 at the cost of potentially missing frames of voice.objectpv_bat_t * * : Constructed instance of Bat.
Returns
- pv_status_t : Status code.
pv_bat_delete()
Releases resources acquired by Bat.
Parameters
objectpv_bat_t * : Bat object.
pv_bat_process()
Processes a frame of the incoming audio.
Parameters
objectpv_bat_t * : Bat object.pcmint16_t : A frame of audio samples.scoresfloat ** : Detection score for each supported language. The scores are in the range [0, 1] with 1 being maximum confidence in a detection. The index of each scores corresponds to thepv_bat_language_tenum value, and the length of the array isPV_BAT_LANGUAGE_NUM_LANGUAGESelements long. IfNULLis returned forscoresand the return statusPV_STATUS_SUCCESS, Bat did not detect usable voice in the frame.scoresmust be freed usingpv_bat_scores_delete().
Returns
- pv_status_t : Status code.
pv_bat_scores_delete()
Deletes scores returned from pv_bat_process().
Parameters
scoresfloat * : Scores array returned frompv_bat_process().
pv_bat_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_bat_version()
Getter for version.
Returns
- const char * : Bat version.
pv_bat_language_t
Bat language enum.
pv_bat_language_to_string()
Parameters
languagepv_bat_language_t :pv_bat_language_tenum value.
Returns
- const char * : String representation of language.
pv_sample_rate()
Audio sample rate accepted by Bat.
Returns
- int32_t : Sample rate.
pv_bat_list_hardware_devices()
Gets a list of hardware devices that can be specified when calling pv_bat_init().
Parameters
hardware_devicesconst char * * * : Array of available hardware devices. Devices are NULL terminated strings. The array must be freed usingpv_bat_free_hardware_devices().num_hardware_devicesint32_t * : The number of devices in thehardware_devicesarray.
Returns
- pv_status_t : Returned status code.
pv_bat_free_hardware_devices()
This function frees the memory allocated by pv_bat_list_hardware_devices().
Parameters
hardware_devicesconst char * * * : Array of available hardware devices allocated bypv_bat_list_hardware_devices().num_hardware_devicesint32_t * : The number of devices in thehardware_devicesarray
pv_status_t
Status code enum.
pv_status_to_string()
Parameters
statusint32_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_stackconst 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_depthint32_t * : The number of messages in themessage_stackarray.
pv_free_error_stack()
This function frees the memory used by error messages allocated by pv_get_error_stack().
Parameters
message_stackconst char * * : Array of messages relating to the failure.