SathvikGanta commited on
Commit
42707d7
·
verified ·
1 Parent(s): 92ddc05

Create utils/translator.py

Browse files
Files changed (1) hide show
  1. utils/translator.py +8 -0
utils/translator.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from config import TRANSLATION_MODEL
3
+
4
+ translator = pipeline("translation_en_to_fr", model=TRANSLATION_MODEL)
5
+
6
+ def translate_to_french(text):
7
+ translation = translator(text)[0]
8
+ return translation['translation_text']