Skip to content

A free translator with online and offline translations and auto language detection

License

Notifications You must be signed in to change notification settings

sudoknight/good-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Good Translator (No API keys Needed)

Header


A free translator (wrapper) that can do online and offline translations. This package uses the Google translator as its first option. In cases when the google translation doesn't work, It uses the offline translation model. The dual mode feature (online + offline) allows this package to always return translation result without failing.

Machine with 16GB RAM can load and perform inferences with the local model.

The following translation models/services are used

Google Translation

It relies on deep-translator for performing translations through Google.

Language Detection

It uses facebook/fasttext-language-identification model for language detection. It can detect 217 languages. The model size is around 1.18GB. When the class object is initialized for the first time, this model is downloaded and stored in the cache dir "~/.cache/huggingface/hub"

Offline Translation Model

It uses facebook/m2m100_1.2B model for performing offline translations. This model can directly translate between the 9,900 directions of 100 languages. It has 1.2B parameters. The model size is around 4.96GB. When the class object is initialized for the first time, this model is downloaded and stored in the cache dir "~/.cache/huggingface/hub"

Find the langauges supported by each model/service in 'docs/supported_langauges.md'

Usage

Install the package directly using:

python setup.py install

Translating a single string (other language to english)

from good_translator import GoodTranslator
gt = GoodTranslator()
text =  "Hola. Cómo estás ? ¿Cómo va todo en España?"
gt.translate(text)  # default value for param target_lang="en"

Demo1

Translating a single string (english to other language)

from good_translator import GoodTranslator
gt = GoodTranslator()
text =  "Translate me to spanish please."
gt.translate(text, target_lang="es")

Demo1

Translating a batch of strings

The result will contains list of tuples with (original text, translated text)

from good_translator import GoodTranslator
gt = GoodTranslator()
texts = ["Hola. Cómo estás ? ¿Cómo va todo en España?", "Extraño la paella."]
gt.batch_translate(texts)  # default value for param target_lang="en"

Demo2

About

A free translator with online and offline translations and auto language detection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages