Spaces:
Runtime error
Runtime error
from deep_translator import GoogleTranslator | |
from easynmt import EasyNMT | |
from utils.timing import Timer | |
def translate(text, source_language, target_language): | |
try: | |
print("Trying to use Google Translator...") | |
return GoogleTranslator(source = source_language, target = target_language).translate(text) | |
except: | |
print("Google Translator is not working... using M2M100") | |
translation_model = EasyNMT('m2m_100_418M') | |
return translation_model.translate(text, source_lang = source_language, target_lang = target_language) |