Harveenchadha's picture
Update app.py
5476941
raw
history blame
1.07 kB
import os
#import gradio as gr
os.system('wget -q https://storage.googleapis.com/vakyaansh-open-models/translation_models/en-indic.zip')
os.system('unzip /home/user/app/en-indic.zip')
os.system('pip uninstall -y numpy')
os.system('pip install numpy')
#os.system('pip uninstall -y numba')
#os.system('pip install numba==0.53')
from fairseq import checkpoint_utils, distributed_utils, options, tasks, utils
import gradio as grd
from inference.engine import Model
indic2en_model = Model(expdir='en-indic')
INDIC = {"Assamese": "as", "Bengali": "bn", "Gujarati": "gu", "Hindi": "hi","Kannada": "kn","Malayalam": "ml", "Marathi": "mr", "Odia": "or","Punjabi": "pa","Tamil": "ta", "Telugu" : "te"}
def translate(text, lang):
return indic2en_model.translate_paragraph(text, 'en', INDIC[lang])
languages = INDIC.keys()
#print(translate('helo how are you'))
ddwn = grd.inputs.Dropdown(languages, type="value", default="Hindi", label="Select Target Language")
iface = grd.Interface(fn=translate, inputs=["text",ddwn] , outputs="text")
iface.launch(enable_queue=True)