File size: 627 Bytes
5c21fac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import subprocess
subprocess.check_call(["pip", "install", "transformers"])
subprocess.check_call(["pip", "install", "torch"])

from transformers import pipeline

pipe = pipeline("text2text-generation", model="balaramas/mbart-sahitrans_new_data")


def sanmt(txt):
    output=pipe(txt, max_length=20, min_length=5, do_sample=False)[0]['generated_text']  
    return output

iface = gr.Interface(
    fn=sanmt, 
    inputs=gr.Textbox(label="Enter text in Sanskrit", placeholder="Type here..."), 
    outputs=gr.Textbox(label="Translated Hindi Text"),
    title="Sanskrit to Hindi Translator"
)
iface.launch()