Zebra Translate
Python API
API Reference for the Zebra Python SDK (PyPI).
pvzebra.create()
Factory method for Zebra Translate engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.model_pathOptional[str] : Absolute path to the file containing model parameters (.pv). Sets the source and target translation languages.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.library_pathOptional[str] : Absolute path to Zebra's dynamic library.
Returns
Zebra: An instance of Zebra Translate engine.
Throws
pvzebra.available_devices()
Lists all available devices that Zebra can use for inference. Each entry in the list can be the device argument
of create() factory method or Zebra constructor.
Parameters
library_pathOptional[str] : Absolute path to Zebra's dynamic library. If not set it will be set to the default location.
Returns
- Sequence[str]: List of all available devices that Zebra can use for inference.
Throws
pvzebra.Zebra
Class for the Zebra Translate engine.
Zebra can be initialized either using the module level create() function
or directly using the class __init__() method.
Resources should be cleaned when you are done using the delete() method.
pvzebra.Zebra.version
The version string of the Zebra library.
pvzebra.Zebra.max_character_limit
The maximum number of characters allowed in a single translate request.
pvzebra.Zebra.__init__()
__init__ method for Zebra Translate engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.model_pathstr : Absolute path to the file containing model parameters (.pv). Sets the source and target translation languages.devicestr : 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.library_pathstr : Absolute path to Zebra's dynamic library.
Returns
Zebra: An instance of Zebra Translate engine.
Throws
pvzebra.Zebra.delete()
Releases resources acquired by Zebra.
pvzebra.Zebra.translate()
Translates text. The maximum number of characters that can be translated at once
is given by .maxCharacterLimit.
Parameters
textstr : Text to translate.
Returns
- str : Translated text.
Throws
pvzebra.list_hardware_devices()
Lists all available devices that Zebra can use for inference. Each entry in the list can be the device argument
of create() factory method or Zebra constructor.
Internal method. The higher level pvzebra.available_devices() should be used instead.
Parameters
library_pathstr : Absolute path to Zebra's dynamic library.
Returns
- Sequence[str]: List of all available devices that Zebra can use for inference.
Throws
pvzebra.ZebraError
Error thrown if an error occurs within Zebra Translate engine.
Exceptions