rajeshradhakrishnan commited on
Commit
7903f66
1 Parent(s): 816b492

update as per the new api changes

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -2,11 +2,8 @@ import requests
2
  import json
3
  import gradio as gr
4
 
5
- uri = "https://hf.space/embed"
6
- API_URL = {
7
- "ml-en": f"{uri}/ai4bharat/IndicTrans-Indic2English/+/api/predict/",
8
- "en-tm": f"{uri}/ai4bharat/IndicTrans-English2Indic/+/api/predict/"
9
- }
10
 
11
  examples = [
12
  ["വടശ്ശേരിക്കര-ഗവി"],
@@ -14,11 +11,11 @@ examples = [
14
  ["നെന്മാറ - നെല്ലിയാമ്പതി"]
15
  ]
16
 
17
- def transIndic(idx,text, lang):
18
  response = requests.post(
19
- API_URL[idx],
20
  json={
21
- "data": [text, lang]
22
  }
23
  )
24
  data = ""
@@ -29,10 +26,9 @@ def transIndic(idx,text, lang):
29
 
30
  def translate_ML_TM(malayalam_text):
31
 
32
- ml_en = transIndic("ml-en",malayalam_text, "Malayalam")
33
- en_tm = transIndic("en-tm", ml_en[0], "Tamil")
34
 
35
- return en_tm[0]
36
 
37
  interface = gr.Interface(
38
  translate_ML_TM,
 
2
  import json
3
  import gradio as gr
4
 
5
+ uri = "https://ai4bharat-indictrans-indic2indic.hf.space/api/predict"
6
+
 
 
 
7
 
8
  examples = [
9
  ["വടശ്ശേരിക്കര-ഗവി"],
 
11
  ["നെന്മാറ - നെല്ലിയാമ്പതി"]
12
  ]
13
 
14
+ def transIndic(idx,text, srclang, trgLang):
15
  response = requests.post(
16
+ uri,
17
  json={
18
+ "data": [text, srclang, trgLang]
19
  }
20
  )
21
  data = ""
 
26
 
27
  def translate_ML_TM(malayalam_text):
28
 
29
+ ml_tm = transIndic(malayalam_text, "Malayalam","Tamil")
 
30
 
31
+ return ml_tm[0]
32
 
33
  interface = gr.Interface(
34
  translate_ML_TM,