File size: 763 Bytes
b1362bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline

checkpoint = "Swekerr/eng2hindi"
translate = pipeline("translation", model=checkpoint)

def translate_text(text):
    result = translate(text, max_length=512)
    return result[0]['translation_text']

with gr.Blocks() as demo:
    gr.Markdown("# English to Hindi Translator")
    gr.Markdown("Enter English text below and get the Hindi translation.")

    with gr.Row():
        input_text = gr.Textbox(label="Input English Text", placeholder="Type something in English...")
        output_text = gr.Textbox(label="Translated Hindi Text", interactive=False)

    translate_button = gr.Button("Translate")

    translate_button.click(translate_text, inputs=[input_text], outputs=[output_text])

demo.launch()