Skip to content

Instantly share code, notes, and snippets.

@RonyMacfly
Last active October 27, 2021 08:52
Show Gist options
  • Save RonyMacfly/6749c3ec1c6bfda7bad3e0a3baa51a02 to your computer and use it in GitHub Desktop.
Save RonyMacfly/6749c3ec1c6bfda7bad3e0a3baa51a02 to your computer and use it in GitHub Desktop.
Argostraslate example
# https://github.com/argosopentech/argos-translate
# sudo apt-get install python python3
# sudo apt-get install python-pip python3-pip
# pip3 install argostranslate
# pip install --no-cache-dir install torchvision
# Models: https://drive.google.com/drive/folders/11wxM3Ze7NCgOk_tdtRjwet10DmtvFu3i
# gdown --fuzzy 'https://drive.google.com/file/d/1Vr_u7mzfwWRVpwgr7loMX7-62DaHKrSJ/view?usp=sharing'
# Your folder: argostraslate_demo.py translate-en_XX-1_1.argosmodel
# python3 argostraslate_demo.py
from argostranslate import package, translate
package.install_from_path('translate-en_ru-1_1.argosmodel')
installed_languages = translate.get_installed_languages()
translation_en_ru = installed_languages[0].get_translation(installed_languages[1])
while(1):
input_str = input()
print(translation_en_ru.translate( input_str ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment