Made in Vancouver, Canada by Picovoice
Zebra is a lightweight, on-device neural machine translation engine.
Install the demo package:
pip3 install pvzebrademoRun the following in the terminal:
zebra_demo --access_key ${ACCESS_KEY} --model_path ${MODEL_PATH} --text ${TEXT}Replace ${ACCESS_KEY} with yours obtained from Picovoice Console, ${MODEL_PATH} with
a supported translation model located here and ${TEXT} with the text to translate.
For more information about Python demos go to demo/python.
Build the demo:
cmake -S demo/c/ -B demo/c/build && cmake --build demo/c/buildRun the demo:
./demo/c/build/zebra_demo -a ${ACCESS_KEY} -l ${LIBRARY_PATH} -m ${MODEL_PATH} -t ${TEXT}Replace ${LIBRARY_PATH} with path to appropriate library available under lib,
${ACCESS_KEY} with yours obtained from Picovoice Console,
${MODEL_PATH} with a supported translation model located here and
${TEXT} with the text to translate.
For more information about C demos go to demo/c.
Using Android Studio, open demo/android/ZebraDemo as an Android project.
Replace "${YOUR_ACCESS_KEY_HERE}" in the
file MainActivity.java
with your AccessKey.
Go to Build > Select Build Variant... and select the language you would like to run the demo in (e.g. enfrDebug -> English to French translation demo)
Build and run on an installed simulator or a connected Android device.
For more information about Android demos go to demo/android.
- Open ZebraDemo.xcodeproj in XCode.
- Replace
${YOUR_ACCESS_KEY_HERE}in the fileViewModel.swiftwith yourAccessKey. - Go to
Product > Schemeand select the scheme for the language you would like to run the demo in (e.g.enfrDemo-> English to French translation demo). - Run the demo with a simulator or connected iOS device.
- Once the demo app has started, enter the text you wish to translate in the text box area, and press the
Translatebutton to translate the text.
For more information about iOS demos go to demo/ios.
From demo/web run the following in the terminal:
yarn
yarn start [${SOURCE}] [${TARGET}](or)
npm install
npm run start [${SOURCE}] [${TARGET}]Replace ${SOURCE} and ${TARGET} with the source/target language you would like to run the demo in.
Open http://localhost:5000 in your browser to try the demo.
For more information about Web demos go to demo/web.
Install the Python SDK:
pip3 install pvzebraCreate an instance of the engine and perform text translation:
import pvzebra
zebra = pvzebra.create(access_key='${ACCESS_KEY}', model_path='${MODEL_PATH}')
print(zebra.translate('${TEXT}'))Replace ${ACCESS_KEY} with yours obtained from Picovoice Console, ${MODEL_PATH} with
a supported translation model located here and ${TEXT} with the text to translate.
Finally, when done be sure to explicitly release the resources:
zebra.delete()To include the Zebra package in your Android project, ensure you have included mavenCentral() in your
top-level build.gradle file and then add the following to your app's build.gradle:
dependencies {
implementation 'ai.picovoice:zebra-android:${LATEST_VERSION}'
}Create an instance of the engine and translate text:
import ai.picovoice.zebra.*;
final String accessKey = "${ACCESS_KEY}"; // AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
final String modelPath = "${MODEL_FILE_PATH}";
try {
Zebra zebra = new Zebra.Builder()
.setAccessKey(accessKey)
.setModelPath(modelPath)
.build(appContext);
String translation = zebra.translate("${TEXT}");
} catch (ZebraException e) { }Replace ${ACCESS_KEY} with yours obtained from Picovoice Console, ${MODEL_FILE_PATH} with a
Zebra model file and ${TEXT} with the text to be translated.
Create an instance of the engine:
import Zebra
let modelPath = Bundle(for: type(of: self)).path(
forResource: "${MODEL_FILE}", // Name of the model file name for Zebra
ofType: "pv")!
do {
let zebra = try Zebra(accessKey: "${ACCESS_KEY}", modelPath: modelPath)
} catch {}Replace ${ACCESS_KEY} with yours obtained from Picovoice Console and ${MODEL_FILE}
with the model file name for Zebra.
do {
let translation = try zebra.translate(text: "${TEXT}")
} catch {}Replace ${TEXT} with the text to be translated.
When done be sure to explicitly release the resources using zebra.delete().
For more details, see the iOS SDK.
Install the web SDK using yarn:
yarn add @picovoice/zebra-webor using npm:
npm install --save @picovoice/zebra-webCreate an instance of the engine using ZebraWorker and translate text:
import { ZebraWorker } from "@picovoice/zebra-web";
import zebraParams from "${PATH_TO_BASE64_ZEBRA_PARAMS}";
const zebra = await ZebraWorker.create(
"${ACCESS_KEY}",
{ base64: zebraParams },
);
const translation = await zebra.translate("${TEXT}");
console.log(translation);Replace ${ACCESS_KEY} with yours obtained from Picovoice Console. Finally, when done release the resources using zebra.release().
For more details, see the Web SDK.