Skip to content

About

Android app for Hindi, English, and Marathi translation in all six directions, built with Kotlin, Jetpack Compose, FastAPI, and IndicTrans2.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TranslationApp

Hindi ↔ English ↔ Marathi Android translation app

Project CI Kotlin Android FastAPI IndicTrans2

A full-stack Android translation project for Hindi, English and Marathi using a FastAPI backend, IndicTrans2 ONNX models and SQLite result caching.

Android source · Backend source · Report a bug


Supported translations

  • 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.

Architecture

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

Features

Android

  • 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

Backend

  • 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

Translation models

The backend uses three INT8 ONNX model families:

  • hari31416/indictrans2-en-indic-dist-200M-ONNX-int8
  • hari31416/indictrans2-indic-en-dist-200M-ONNX-int8
  • hari31416/indictrans2-indic-indic-dist-320M-ONNX-int8

Only the model needed for the current direction is kept active in memory.

Run the backend

cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000

Then check:

curl http://127.0.0.1:8000/health

Example 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.

Run the Android app

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.

Current limitations

  • 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.

Roadmap

  • 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

Contributing

Please read CONTRIBUTING.md before opening a pull request.


Built by Aditya

About

Android app for Hindi, English, and Marathi translation in all six directions, built with Kotlin, Jetpack Compose, FastAPI, and IndicTrans2.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages