malayalam-tamil / app.py
rajeshradhakrishnan's picture
update as per the new api changes
7903f66
raw
history blame
1.32 kB
import requests
import json
import gradio as gr
uri = "https://ai4bharat-indictrans-indic2indic.hf.space/api/predict"
examples = [
["വടശ്ശേരിക്കര-ഗവി"],
["തിരുവനന്തപുരം-എറണാകുളം"],
["നെന്മാറ - നെല്ലിയാമ്പതി"]
]
def transIndic(idx,text, srclang, trgLang):
response = requests.post(
uri,
json={
"data": [text, srclang, trgLang]
}
)
data = ""
if 200 == response.status_code :
output = json.loads(response.text)
data = output['data']
return data
def translate_ML_TM(malayalam_text):
ml_tm = transIndic(malayalam_text, "Malayalam","Tamil")
return ml_tm[0]
interface = gr.Interface(
translate_ML_TM,
inputs="textbox",
outputs='label',
theme="default",
title="Malayalam to Tamil Translater",
description="Try to translate മലയാളം to தமிழ் ? Input a few malayalam text and verify whether the model translated it appropriately!",
article="<p style='text-align: center'>മലയാളം - தமிழ் | Demo Application</p>",
examples=examples,
cache_examples=False,
# live=True,
)
interface.launch(debug=True,share=False)