A full-stack Android translation project for Hindi, English and Marathi using a FastAPI backend, IndicTrans2 ONNX models and SQLite result caching.
- Hindi → English
- Hindi → Marathi
- English → Hindi
- English → Marathi
- Marathi → Hindi
- Marathi → English
The Android app includes source and target language selectors plus a one-tap swap button.
Android app
│
│ POST /translate
│ text + source_language + target_language
▼
FastAPI backend
│
├── SQLite translation cache
│
└── IndicTrans2 INT8 ONNX
├── English → Indic
├── Indic → English
└── Indic → Indic
Language codes used by the models:
| Language | API code | IndicTrans2 code |
|---|---|---|
| Hindi | hi |
hin_Deva |
| English | en |
eng_Latn |
| Marathi | mr |
mar_Deva |
- Kotlin + Jetpack Compose
- Hindi, English and Marathi selectors
- Six translation directions
- One-tap language swap
- Retrofit API client
- ViewModel-based UI state
- Loading and error states
- Latency display
- Cache-hit indicator
- Configurable backend URL
- FastAPI REST API
- IndicTrans2 CPU inference through ONNX Runtime
- Automatic model selection by translation direction
- Lazy model loading to reduce memory usage
- SQLite translation cache
- Health endpoint
- Input and language validation
- Docker support
The backend uses three INT8 ONNX model families:
hari31416/indictrans2-en-indic-dist-200M-ONNX-int8hari31416/indictrans2-indic-en-dist-200M-ONNX-int8hari31416/indictrans2-indic-indic-dist-320M-ONNX-int8
Only the model needed for the current direction is kept active in memory.
cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000Then check:
curl http://127.0.0.1:8000/healthExample translation:
curl -X POST http://127.0.0.1:8000/translate \
-H "Content-Type: application/json" \
-d '{"text":"नमस्ते","source_language":"hi","target_language":"en"}'See backend/README.md for backend details.
The debug build defaults to:
http://10.0.2.2:8000/
To use another backend URL:
gradle :app:assembleDebug \
-PTRANSLATION_API_BASE_URL=http://192.168.1.10:8000/For production, use HTTPS.
- The first request for a model direction must download and initialize that model.
- Switching between English→Indic, Indic→English and Indic→Indic can require loading a different model.
- Translation quality should be reviewed before high-stakes or production use.
- The Android app requires a reachable backend.
- Models are not yet running directly on-device.
- Hindi ↔ English translation
- Hindi ↔ Marathi translation
- English ↔ Marathi translation
- FastAPI backend
- IndicTrans2 ONNX inference
- SQLite caching
- Loading and error states
- Android CI
- Add translation history
- Add speech-to-text
- Add text-to-speech
- Explore direct on-device inference
Please read CONTRIBUTING.md before opening a pull request.
Built by Aditya