Zebra Translate
C API
API Reference for the Zebra C SDK.
pv_zebra_t
Container representing the Zebra Translate object.
pv_zebra_init()
Creates a Zebra instance. Resources should be cleaned when you are done using the pv_zebra_delete() function.
Parameters
access_keyconst char * : AccessKey obtained from Picovoice Console.model_pathconst char * : Absolute path to the file containing model parameters (.pv). Sets the source and target translation languages.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.objectpv_zebra_t * * : Constructed instance of Zebra.
Returns
- pv_status_t : Status code.
pv_zebra_delete()
Releases resources acquired by Zebra.
Parameters
objectpv_zebra_t * : Zebra object.
pv_zebra_translate()
Translates text. The maximum number of characters that can be translated at once
is given by pv_zebra_max_character_limit.
Parameters
objectpv_zebra_t * : Zebra object.textchar * : Text to translate.translationchar ** : Translated text.
Returns
- pv_status_t : Status code.
pv_zebra_translation_delete()
Deletes translation returned from pv_zebra_translate().
Parameters
translationchar * : Translation string returned frompv_zebra_translate().
pv_zebra_version()
Getter for version.
Returns
- const char * : Zebra version.
pv_zebra_max_character_limit()
Getter for the maximum number of characters that can be translated at once.
Parameters
objectpv_zebra_t * : Zebra object.max_character_limitint32_t * : Maximum number of characters.
Returns
- pv_status_t : Status code.
pv_zebra_list_hardware_devices()
Gets a list of hardware devices that can be specified when calling pv_zebra_init().
Parameters
hardware_devicesconst char * * * : Array of available hardware devices. Devices are NULL terminated strings. The array must be freed usingpv_zebra_free_hardware_devices().num_hardware_devicesint32_t * : The number of devices in thehardware_devicesarray.
Returns
- pv_status_t : Returned status code.
pv_zebra_free_hardware_devices()
This function frees the memory allocated by pv_zebra_list_hardware_devices().
Parameters
hardware_devicesconst char * * * : Array of available hardware devices allocated bypv_zebra_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.