Spaces:
Runtime error
Runtime error
Commit
·
f80a870
1
Parent(s):
74fc30d
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import os
|
2 |
#import gradio as gr
|
3 |
|
4 |
-
os.system('wget -q https://storage.googleapis.com/vakyaansh-open-models/translation_models/en
|
5 |
-
os.system('unzip /home/user/app/en
|
6 |
os.system('pip uninstall -y numpy')
|
7 |
os.system('pip install numpy')
|
8 |
#os.system('pip uninstall -y numba')
|
@@ -11,26 +11,26 @@ os.system('pip install numpy')
|
|
11 |
from fairseq import checkpoint_utils, distributed_utils, options, tasks, utils
|
12 |
import gradio as grd
|
13 |
from inference.engine import Model
|
14 |
-
indic2en_model = Model(expdir='en
|
15 |
|
16 |
INDIC = {"Assamese": "as", "Bengali": "bn", "Gujarati": "gu", "Hindi": "hi","Kannada": "kn","Malayalam": "ml", "Marathi": "mr", "Odia": "or","Punjabi": "pa","Tamil": "ta", "Telugu" : "te"}
|
17 |
|
18 |
|
19 |
def translate(text, lang):
|
20 |
-
return indic2en_model.translate_paragraph(text, 'en'
|
21 |
|
22 |
|
23 |
|
24 |
languages = list(INDIC.keys())
|
25 |
|
26 |
#print(translate('helo how are you'))
|
27 |
-
ddwn = grd.inputs.Dropdown(languages, type="value", default="Hindi", label="Select
|
28 |
-
txt = grd.inputs.Textbox( lines=5, placeholder="Enter Text to translate", default="", label="Enter Text in
|
29 |
-
txt_ouptut = grd.outputs.Textbox(type="auto", label="Translated text in
|
30 |
|
31 |
-
example=[['
|
32 |
-
['
|
33 |
|
34 |
supp = ','.join(languages)
|
35 |
-
iface = grd.Interface(fn=translate, inputs=[txt,ddwn] , outputs=txt_ouptut, title='Translation for 11 Indic Languages', description = 'This is a demo based on IndicTrans. Languages Supported: '+supp, article = 'Original repo [link](https://github.com/AI4Bharat/indicTrans) by AI4Bharat. <b>Note: This space can only perform translation from
|
36 |
iface.launch(enable_queue=True)
|
|
|
1 |
import os
|
2 |
#import gradio as gr
|
3 |
|
4 |
+
os.system('wget -q https://storage.googleapis.com/vakyaansh-open-models/translation_models/indic-en.zip')
|
5 |
+
os.system('unzip /home/user/app/indic-en.zip')
|
6 |
os.system('pip uninstall -y numpy')
|
7 |
os.system('pip install numpy')
|
8 |
#os.system('pip uninstall -y numba')
|
|
|
11 |
from fairseq import checkpoint_utils, distributed_utils, options, tasks, utils
|
12 |
import gradio as grd
|
13 |
from inference.engine import Model
|
14 |
+
indic2en_model = Model(expdir='indic-en')
|
15 |
|
16 |
INDIC = {"Assamese": "as", "Bengali": "bn", "Gujarati": "gu", "Hindi": "hi","Kannada": "kn","Malayalam": "ml", "Marathi": "mr", "Odia": "or","Punjabi": "pa","Tamil": "ta", "Telugu" : "te"}
|
17 |
|
18 |
|
19 |
def translate(text, lang):
|
20 |
+
return indic2en_model.translate_paragraph(text, INDIC[lang], 'en')
|
21 |
|
22 |
|
23 |
|
24 |
languages = list(INDIC.keys())
|
25 |
|
26 |
#print(translate('helo how are you'))
|
27 |
+
ddwn = grd.inputs.Dropdown(languages, type="value", default="Hindi", label="Select Source Language")
|
28 |
+
txt = grd.inputs.Textbox( lines=5, placeholder="Enter Text to translate", default="", label="Enter Text in Source Language")
|
29 |
+
txt_ouptut = grd.outputs.Textbox(type="auto", label="Translated text in English Language")
|
30 |
|
31 |
+
example=[['मैं इस वाक्य का हिंदी में अनुवाद करना चाहता हूं','Hindi'],
|
32 |
+
['আজ আমার খুব ভালো লাগছে', 'Bengali']]
|
33 |
|
34 |
supp = ','.join(languages)
|
35 |
+
iface = grd.Interface(fn=translate, inputs=[txt,ddwn] , outputs=txt_ouptut, title='Translation for 11 Indic Languages', description = 'This is a demo based on IndicTrans. Languages Supported: '+supp, article = 'Original repo [link](https://github.com/AI4Bharat/indicTrans) by AI4Bharat. <b>Note: This space can only perform translation from Indic languages to English. Support for other combinations will be provided soon.', examples=example)
|
36 |
iface.launch(enable_queue=True)
|