File size: 680 Bytes
1398925
af1aba9
1398925
 
 
 
af1aba9
 
07a4801
 
 
af1aba9
 
07a4801
 
af1aba9
07a4801
5be9305
07a4801
 
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
from gradio import inputs, outputs
from transformers import MarianMTModel, MarianTokenizer

# Define the translator function
def translate_text(text, target_language):
    # ... (the rest of the code)

# Define the Gradio interface
language_options = ["Spanish", "French", "Italian", "Ukrainian"]
inputs = [
    inputs.Textbox(lines=5, label="Enter text to translate:"),
    inputs.Dropdown(choices=language_options, label="Select target language:"),
]
outputs = outputs.Textbox(label="Translated text:")

iface = gr.Interface(fn=translate_text, inputs=inputs, outputs=outputs, title="Language Translator")

# Launch the Hugging Face Spaces app
iface.launch()