balaramas commited on
Commit
5c21fac
1 Parent(s): 719c72c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ subprocess.check_call(["pip", "install", "transformers"])
4
+ subprocess.check_call(["pip", "install", "torch"])
5
+
6
+ from transformers import pipeline
7
+
8
+ pipe = pipeline("text2text-generation", model="balaramas/mbart-sahitrans_new_data")
9
+
10
+
11
+ def sanmt(txt):
12
+ output=pipe(txt, max_length=20, min_length=5, do_sample=False)[0]['generated_text']
13
+ return output
14
+
15
+ iface = gr.Interface(
16
+ fn=sanmt,
17
+ inputs=gr.Textbox(label="Enter text in Sanskrit", placeholder="Type here..."),
18
+ outputs=gr.Textbox(label="Translated Hindi Text"),
19
+ title="Sanskrit to Hindi Translator"
20
+ )
21
+ iface.launch()