Open Source Language translate by using libretranslate
What is LibreTranslate?
Simply put, It’s an Open Source Machine Translation API, entirely self-hosted.
Yes, that means you could run it at your premises without being connected to the Internet.
Is this even possible?
Yes, all thanks to Argos Translate which runs its translation engine.
Wanted to give it a try ? Try it online!
Note: This guide is written on Ubuntu.
Installation
Python (3.8 or higher is recommended) by official LibreTranslate.
- create a conda environment named py38
- Activate py38 environment
- Install libretranslate ….⏳
conda create — name py38 python=3.8
conda activate py38
pip install libretranslate
If any faced issue while installing libretranslate and failing atpyicu,
then refer.
Alternative way
Directly build form git. I prefer this method
git clone https://github.com/LibreTranslate/LibreTranslate
cd LibreTranslate
pip install -e .
Let’s start the libretranslate Server.
To find out the Language code reference
python main.py --load-only en,hi
# en,hi change these language code according to your need.
- en : English
- hi: Hindi
You can see it running at http://127.0.0.1:5000.
If you don’t believe me, turn off your Internet connection and see for yourself.
Demo using API programmatically in Python
- Created a text file with few news headlines names `sentence.txt`
2. Run the script shown below.
python english_hindi_API.py
3. Results into a hindi_translation.txt file.
These results are quite good. As the Machine Translation space is improving with time we may get some great results going ahead.