File size: 1,321 Bytes
a95d13a
 
 
 
7903f66
 
a95d13a
5da610e
 
 
 
 
 
7903f66
a95d13a
7903f66
a95d13a
7903f66
a95d13a
 
 
 
 
 
 
 
 
 
7903f66
a95d13a
7903f66
a95d13a
 
 
 
 
41f17be
a95d13a
 
5da610e
 
499b09a
a95d13a
6a8ca84
a95d13a
816b492
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)