Space / pages /libraries /text_translation.py
Nax07onix3's picture
Upload 11 files
46e7aa4 verified
raw
history blame
268 Bytes
from transformers import pipeline
def load_translator(language1, language2):
modelo = f"Helsinki-NLP/opus-mt-{language1}-{language2}"
return pipeline('translation', model=modelo)
def translator(text, pipe):
return pipe(text)[0]['translation_text']