Set up the Aksharamukha Backend (Python/Flask)
masterThe backend is a Python 3 application using Flask. To run it, install the required dependencies and execute the main entry point.
python3 main.pyrepository·master·Indexed 42 days ago
https://github.com/virtualvinodh/aksharamukhaA comprehensive transliteration engine for script conversion within the Indic cultural sphere, supporting over 120 scripts and various romanization methods. It provides a REST API for text, XML, HTML, and DOCX conversion, along with tools for script auto-detection, syllabary retrieval, and conjunct mapping. The system can be deployed via Docker Compose with a Quasar/Vue frontend and a Python/Flask backend.
The backend is a Python 3 application using Flask. To run it, install the required dependencies and execute the main entry point.
python3 main.pyThe easiest way to run the full Aksharamukha stack (frontend, backend, and local font server) is via Docker Compose. This orchestrates all necessary containers and binds the web application to http://localhost:12345.
# Inside the project's root folder
docker compose uphttps://github.com/virtualvinodh/aksharamukha-python.The frontend is built with Quasar and Vue. To run it manually, follow these steps:
npm install -g @quasar/cli.quasar.conf.js: Comment out line 9 to disable the analytics plugin, which prevents build failures.src/pages/index.vue, comment out import keys from '../keys.js' and add an empty keys object to bypass Google's OCR API requirement:// sets empty API key for Google's OCR API to build the project without using that service
var keys = {}
keys['api_key'] = ''localhost in mixins/ScriptMixin.js.quasar dev and navigate to the address provided in the terminal output.npm install
# ... follow configuration steps above ...
quasar devYou can deploy the full Aksharamukha stack (Frontend, Backend, and Fonts) using Docker Compose. This setup orchestrates three distinct services, each exposing specific ports on the host machine.
| Service | Image | Host Port | Container Port |
|---|---|---|---|
| front (Frontend) | virtualvinodh/aksharamukha-front | 12345 | 80 |
| back (Backend) | virtualvinodh/aksharamukha-back | 8085 | 8085 |
| fonts (Fonts) | virtualvinodh/aksharamukha-fonts | 9899 | 80 |
To run the stack, ensure you have a docker-compose.yaml file with the following configuration and execute docker-compose up.
version: '3'
services:
front:
image: virtualvinodh/aksharamukha-front
ports:
- "12345:80"
back:
image: virtualvinodh/aksharamukha-back
ports:
- "8085:8085"
fonts:
image: virtualvinodh/aksharamukha-fonts
ports:
- "9899:80"http://aksharamukha.appspot.com/#/web-api.The project provides several JSON-based data resources located in aksharamukha-back/resources for script mappings, matrices, and syllabaries:
script_mapping/. Characters with approximate mappings to the generic Indic scheme are marked with ʽ (U+02BD). You may need to strip this character during post-processing.script_matrix/. Filenames indicate the guiding romanization and chunk size (e.g., script_matrix_IAST5.json uses IAST and chunks of 5).syllabary/. Contains lists of vowels, consonants, and consonant-vowel compounds for each script.conjuncts1/ and conjuncts2/. Files are split by the number of consonants and include a suffix for the appended vowel (e.g., conjuncts_Gujarati_o.json contains Gujarati conjuncts with the vowel /o/).The /api/convert_docx endpoint handles DOCX files. It expects the input text to be a comma-separated string where the first part is a Base64 encoded version of the file content.
Request Body (JSON):
source: Source script.target: Target script.text: A string in the format [base64_encoded_content],[file_part_identifier].nativize: Boolean.preOptions: List of strings.postOptions: List of strings.Response:
[base64_encoded_content],[file_part_identifier].POST /api/convert_docx
{
"source": "Devanagari",
"target": "Latin",
"text": "base64_data,file_id",
"nativize": true,
"preOptions": [],
"postOptions": []
}The /api/convert_html endpoint uses transliterate_file.convert_html to process HTML strings, preserving the structure while converting the text content.
Request Body (JSON):
source: Source script.target: Target script.text: The HTML string.nativize: Boolean.preOptions: List of strings.postOptions: List of strings.Response:
POST /api/convert_html
{
"source": "Devanagari",
"target": "Latin",
"text": "<p>नमस्ते</p>",
"nativize": true,
"preOptions": [],
"postOptions": []
}The /api/conjuncts endpoint returns lists of conjunct characters for a specific script and vowel.
Request Body (JSON):
script1: The source script.script2: The target script.vowel: The vowel to associate with the conjuncts.postoptions: List of post-processing options.Response:
conjuncts1S1, conjuncts1S2, etc.) representing different complexity levels or groupings.POST /api/conjuncts
{
"script1": "Devanagari",
"script2": "Latin",
"vowel": "a",
"postoptions": []
}Use the /api/detectpre endpoint to find appropriate pre-processing options for a specific script and text. This helps in preparing text for accurate transliteration.
Request Body (JSON):
text: The text to analyze.source: The detected or known source script name.Response:
POST /api/detectpre
{
"text": "your text here",
"source": "Tamil"
}The core functionality of the API is provided via the /api/convert endpoint. It allows transliterating text from a source script to a target script with optional pre/post-processing and nativization.
Request Body (JSON):
source: The source script name.target: The target script name.text: The text to be converted.nativize: Boolean (true/false) to determine if the output should be nativized.preOptions: List of strings representing pre-processing steps.postOptions: List of strings representing post-processing steps.Response:
<br/>).POST /api/convert
{
"source": "Devanagari",
"target": "Latin",
"text": "नमस्ते",
"nativize": true,
"preOptions": [],
"postOptions": []
}