Learn how to build a working AI translator app in Python using a text translation engine that runs entirely on-device. With Zebra Translate, text stays on the machine, translation works offline, and there are no per-character API fees. The same code runs on Linux, macOS, Windows, and Raspberry Pi, and separate SDKs cover Android, iOS, and Web.
Install the Python Translation SDK
With Python 3.7 or newer, install the pvzebra Python package using PIP:
pvzebracontains the text translation engine- Translation models come as separate files, one per language pair.
Get Your AccessKey
Sign up for a Picovoice Console account. Once your account is ready, copy your AccessKey from the Console home page.
Choose a Translation Model and Language Pair
Each Zebra model file translates one language pair in one direction; filenames follow zebra_params_${SOURCE}_${TARGET}.pv. Models cover English, French, German, Italian, Japanese, Korean, Portuguese, and Spanish, and the Zebra GitHub repository lists every available pair. This tutorial translates English to Spanish, so download zebra_params_en_es.pv into your project folder:
For any other pair, swap the language codes in the filename.
Translate Text with Three Lines of Python
Three lines of Python get the first translation out:
The pvzebrademo package ships a ready-made zebra_demo command, a quick way to confirm your AccessKey and model file before building the app.
Build the Interactive Translator App
Now turn it into an app. The program below reads the language pair from the model filename, then loops: type a sentence, get the translation, press Enter on an empty line to quit.
Save it as translator.py and run it:
Each call to .translate() accepts up to zebra.max_character_limit characters. For longer text, split the input into sentences or lines, like the file translator in the next section.
Translate an Entire Text File
The same engine batch-translates a document line by line. The complete script, translate_file.py, takes the same two arguments as the translator app:
On-Device Translation: Accuracy, Speed, and Memory
In an open-source benchmark on the Tatoeba-Challenge dataset, Zebra Translate matches the BLEU (Bilingual Evaluation Understudy) scores of Helsinki-NLP/opus-mt while translating at 90+ words per second, 2.4x faster than Helsinki's 35–45, and using 82% less memory on a consumer-grade CPU.
The open-source translation models comparison covers Opus-MT, NLLB, and other models built for mobile and embedded deployments.
Add Speech: From Text Translation to Voice
The speech-to-speech translation recipe chains language detection, streaming speech-to-text, Zebra Translate, and streaming text-to-speech into a live interpreter. The live conversation translation recipe extends that to two speakers conversing, each in their own language, and the live captioning and translation recipe turns spoken audio into translated subtitles. If the source language is unknown ahead of time, the companion tutorial on detecting language in speech with Python shows how to identify it first.
Start Building






