A fast Python translation pipeline for converting English text into Indic languages using IndicTrans2 with robust preprocessing and postprocessing.
π Quick Start β’ π Docs β’ π§ Config β’ π€ Contributing
| π | English β Indic translation Uses ai4bharat/indictrans2-en-indic-dist-200M for multilingual translation from English to Indic scripts. |
| βοΈ | Inference-ready text pipeline Preprocesses punctuation, tokenization, and language tags before generation. |
| π‘οΈ | Placeholder preservation Protects URLs, emails, numerals, and tagged entities during translation and restores them after decoding. |
| π | GPU/CPU adaptive runtime Automatically picks CUDA when available and falls back to CPU otherwise. |
| π§© | Reusable API function Simple translate_text(...) interface for scripts and downstream integrations. |
graph LR
A[π Input Text] --> B[π§Ή IndicProcessor Preprocess]
B --> C[π€ Tokenizer]
C --> D[π€ IndicTrans2 Model]
D --> E[π€ Decode + Postprocess]
E --> F[β
Translated Output]
style A fill:#6C63FF,color:#fff,stroke:#4C46B8
style B fill:#A855F7,color:#fff,stroke:#7E22CE
style C fill:#F59E0B,color:#111,stroke:#B45309
style D fill:#10B981,color:#fff,stroke:#047857
style E fill:#EF4444,color:#fff,stroke:#B91C1C
style F fill:#6C63FF,color:#fff,stroke:#4C46B8
| Requirement | Badge | Notes |
|---|---|---|
| Python | Runtime for scripts | |
| PyTorch | Model execution backend | |
| Transformers | Model and tokenizer loading |
git clone https://github.com/IqbalHere/Meme-Karigar.git
cd Meme-Karigar
python -m venv .venv
source .venv/bin/activate
python -m venv .venv
.venv\Scripts\activate
pip install torch transformers indic-nlp-library sacremoses regex tqdm
python /home/runner/work/Meme-Karigar/Meme-Karigar/test_translation.py
[!TIP] First run may take longer because model weights are downloaded from Hugging Face.
| Variable | Required | Description |
|---|---|---|
src_lang | β | Source FLORES code passed to translate_text (default: eng_Latn) |
tgt_lang | β | Target FLORES code passed to translate_text (example: tel_Telu) |
text | β | Input string to translate |
[!NOTE] This repository currently uses function parameters for configuration; no environment variable is required by the checked-in Python code.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
text | str | β | β | Input sentence/text |
src_lang | str | β | eng_Latn | Source language FLORES code |
tgt_lang | str | β | tel_Telu | Target language FLORES code |
Example structured output:
{
"translated_text": "ΰ°ΰ°¦ΰ°Ώ ΰ°ͺΰ°°ΰ±ΰ°ΰ±ΰ°·.",
"source_language": "eng_Latn",
"target_language": "tel_Telu"
}
| Scenario | Behavior |
|---|---|
| β οΈ Unsupported FLORES mapping | Falls back to default ISO behavior where applicable in IndicProcessor (hi) |
| β Model/tokenizer load issue | Raises dependency/runtime exception from Transformers/PyTorch |
| π No CUDA available | Automatically runs on CPU |
# Run translation smoke test
python /home/runner/work/Meme-Karigar/Meme-Karigar/test_translation.py
π¦ Meme-Karigar
βββ π README.md
βββ π translator.py
βββ π indic_processor.py
βββ π test_translation.py
βββ π output.txt
βββ π useme.txt
| Technology | Role |
|---|---|
| Core implementation language | |
| Tensor runtime for inference | |
| Pretrained model/tokenizer APIs | |
| Indic normalization/tokenization/transliteration | |
| English punctuation normalization/tokenization |
git checkout -b feature/your-change)git commit -m "feat: describe your change")git push origin feature/your-change)License file is not currently present in this repository.
[!IMPORTANT] Add a
/LICENSEfile to clearly define usage rights for contributors and users.
Python
100.0%
A fast Python translation pipeline for converting English text into Indic languages using IndicTrans2 with robust preprocessing and postprocessing.
π Quick Start β’ π Docs β’ π§ Config β’ π€ Contributing
| π | English β Indic translation Uses ai4bharat/indictrans2-en-indic-dist-200M for multilingual translation from English to Indic scripts. |
| βοΈ | Inference-ready text pipeline Preprocesses punctuation, tokenization, and language tags before generation. |
| π‘οΈ | Placeholder preservation Protects URLs, emails, numerals, and tagged entities during translation and restores them after decoding. |
| π | GPU/CPU adaptive runtime Automatically picks CUDA when available and falls back to CPU otherwise. |
| π§© | Reusable API function Simple translate_text(...) interface for scripts and downstream integrations. |
graph LR
A[π Input Text] --> B[π§Ή IndicProcessor Preprocess]
B --> C[π€ Tokenizer]
C --> D[π€ IndicTrans2 Model]
D --> E[π€ Decode + Postprocess]
E --> F[β
Translated Output]
style A fill:#6C63FF,color:#fff,stroke:#4C46B8
style B fill:#A855F7,color:#fff,stroke:#7E22CE
style C fill:#F59E0B,color:#111,stroke:#B45309
style D fill:#10B981,color:#fff,stroke:#047857
style E fill:#EF4444,color:#fff,stroke:#B91C1C
style F fill:#6C63FF,color:#fff,stroke:#4C46B8
| Requirement | Badge | Notes |
|---|---|---|
| Python | Runtime for scripts | |
| PyTorch | Model execution backend | |
| Transformers | Model and tokenizer loading |
git clone https://github.com/IqbalHere/Meme-Karigar.git
cd Meme-Karigar
python -m venv .venv
source .venv/bin/activate
python -m venv .venv
.venv\Scripts\activate
pip install torch transformers indic-nlp-library sacremoses regex tqdm
python /home/runner/work/Meme-Karigar/Meme-Karigar/test_translation.py
[!TIP] First run may take longer because model weights are downloaded from Hugging Face.
| Variable | Required | Description |
|---|---|---|
src_lang | β | Source FLORES code passed to translate_text (default: eng_Latn) |
tgt_lang | β | Target FLORES code passed to translate_text (example: tel_Telu) |
text | β | Input string to translate |
[!NOTE] This repository currently uses function parameters for configuration; no environment variable is required by the checked-in Python code.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
text | str | β | β | Input sentence/text |
src_lang | str | β | eng_Latn | Source language FLORES code |
tgt_lang | str | β | tel_Telu | Target language FLORES code |
Example structured output:
{
"translated_text": "ΰ°ΰ°¦ΰ°Ώ ΰ°ͺΰ°°ΰ±ΰ°ΰ±ΰ°·.",
"source_language": "eng_Latn",
"target_language": "tel_Telu"
}
| Scenario | Behavior |
|---|---|
| β οΈ Unsupported FLORES mapping | Falls back to default ISO behavior where applicable in IndicProcessor (hi) |
| β Model/tokenizer load issue | Raises dependency/runtime exception from Transformers/PyTorch |
| π No CUDA available | Automatically runs on CPU |
# Run translation smoke test
python /home/runner/work/Meme-Karigar/Meme-Karigar/test_translation.py
π¦ Meme-Karigar
βββ π README.md
βββ π translator.py
βββ π indic_processor.py
βββ π test_translation.py
βββ π output.txt
βββ π useme.txt
| Technology | Role |
|---|---|
| Core implementation language | |
| Tensor runtime for inference | |
| Pretrained model/tokenizer APIs | |
| Indic normalization/tokenization/transliteration | |
| English punctuation normalization/tokenization |
git checkout -b feature/your-change)git commit -m "feat: describe your change")git push origin feature/your-change)License file is not currently present in this repository.
[!IMPORTANT] Add a
/LICENSEfile to clearly define usage rights for contributors and users.
Python
100.0%