Translate_It / app.py
Jesus Carrasco
Update app.py
07a4801
raw
history blame
680 Bytes
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()