In Operation
Do an update first.
(argostranslate) [sde@linuxlinks ~]$ argospm update
Let’s say we want to translate English text into German. We need to install the relevant translation package with the command:
(argostranslate) [sde@linuxlinks ~]$ argospm install translate-en_de
Alternatively we can install all translation packages with the command:
(argostranslate) [sde@linuxlinks ~]$ argospm install translate
Machine learning apps often consume a heavy chunk of disk space. Argos Translate is no exception with the translation packages gobbling over 7GB of hard disk space. Remember that the virtual environment uses 2GB of hard disk space.
Command Line Interface
We can translate text from English to German using the argos-translate command. For example:
(argostranslate) [sde@linuxlinks ~]$ ARGOS_DEVICE_TYPE=cuda argos-translate --from en --to de "Hello World!"
outputs the translation Hallo Welt!
We’re using the GPU here. This example actually takes longer to run on the GPU than the CPU because of the time it takes to move the model from main memory to the GPU’s VRAM. For small translations it’s therefore best to use the CPU. For large translations, we see massive speed improvements using the GPU.
Here’s a translation of a few sentences.
Python Library
We don’t have to use the command line interface. Another option is to write some Python code. Here’s an example.
import argostranslate.package import argostranslate.translate from_code = "en" to_code = "es" # Download and install Argos Translate package argostranslate.package.update_package_index() available_packages = argostranslate.package.get_available_packages() package_to_install = next( filter( lambda x: x.from_code == from_code and x.to_code == to_code, available_packages ) ) argostranslate.package.install_from_path(package_to_install.download()) # Translate translatedText = argostranslate.translate.translate("Is this translation software accurate? We're not native Spanish speakers. Maybe we should find a human to help verify the translated text?", from_code, to_code) print(translatedText)
The translated text…
Here’s an image of the GUI in action which uses PyQt, a Python binding of the cross-platform GUI toolkit Qt. The GUI is very basic but functional.
Summary
Argos Translate is a welcome alternative to online services such as Google Translate. From our limited testing, accuracy of the translation is commendable.
Argos Translate supports a wide range of languages. Supported languages are: Arabic, Azerbaijani, Catalan, Chinese, Czech, Danish, Dutch, English, Esperanto, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Irish, Italian, Japanese, Korean, Persian, Polish, Portuguese, Russian, Slovak, Spanish, Swedish, Turkish, and Ukrainian.
Argos Translate also manages automatically pivoting through intermediate languages to translate between languages that don’t have a direct translation between them installed.
Website: www.argosopentech.com
Support: GitHub Code Repository
Developer: Argos Open Technologies, LLC
License: MIT License
For other useful open source apps that use machine learning/deep learning, we’ve compiled this roundup.
Argos Translate is written in Python. Learn Python with our recommended free books and free tutorials.
Pages in this article:
Page 1 – Introduction and Installation
Page 2 – In Operation and Summary