Zebra Translate
Android API
API Reference for the Zebra Android SDK (zebra-android)
package: ai.picovoice.zebra
Zebra
Class for the Zebra Translate engine.
Zebra must be initialized using the Builder() Class. Resources should be cleaned when you are done using the delete() function.
Zebra.getAvailableDevices()
Lists all available devices that Zebra can use for inference.
Each entry in the list can be used as the device argument when initializing Zebra.
Returns
String[]: Array of all available devices thatZebracan be used for inference.
Throws
ZebraException: If an error occurs while getting available devices.
Zebra.delete()
Releases resources acquired by Zebra.
Zebra.getMaxCharacterLimit()
Getter for the maximum number of characters that can be translated at once.
Returns
int: Maximum number of characters that can be translated at once.
Zebra.getVersion()
Getter for version.
Returns
String: CurrentZebraversion.
Zebra.translate()
Translates text. The maximum number of characters that can be translated at once is given
by .getMaxCharacterLimit.
Parameters
textString : Text to translate.
Returns
- String: Translated text.
Throws
ZebraException: If there is an error while translating.
Zebra.Builder
Builder for creating an instance of Zebra.
Zebra.Builder.build()
Creates an instance of Zebra Translate engine.
Parameters
contextContext : The Android app context.
Returns
Zebra: An instance of Zebra Translate engine.
Throws
ZebraException: If an error occurs while creating an instance of Zebra Translate engine.
Zebra.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKeyString : AccessKey obtained from Picovoice Console.
Returns
Zebra.Builder: Modified Zebra.Builder object.
Zebra.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. Sets the source and target translation languages.
Returns
Zebra.Builder: Modified Zebra.Builder object.
Zebra.Builder.setDevice()
Sets the device of the builder. If not set it will be set to the default device.
Parameters
deviceString : 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.
Returns
Zebra.Builder: Modified Zebra.Builder object.
ZebraException
Exception thrown if an error occurs within Zebra Translate engine.
Exceptions: