File size: 733 Bytes
8767a7a
 
e006874
8767a7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39e8960
 
8767a7a
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from transformers import pipeline
import torch

translator = pipeline(
    task="translation",
    model="facebook/nllb-200-distilled-600M"
)


def translate_text(text):
    translated = translator(text, src_lang="eng_Latn", tgt_lang="tur_Latn")
    return translated[0]['translation_text']


demo = gr.Interface(
    fn=translate_text,
    inputs=gr.Textbox(label="Input Text (English)"),
    outputs=gr.Textbox(label="Translated Text (Turkish)"),
    title="English to Turkish Translator",
    description="A demo that translates English text to Turkish using the NLLB-200 model.",
    examples=[["What are you doing?"], ["Where should we time travel to?"], ["Let's translate me!"]],
)


demo.launch(share=True)