iabd04's picture
Primera versi贸n.
0cc555b verified
raw
history blame contribute delete
655 Bytes
import gradio as gr
from transformers import pipeline
# Cargar el modelo de traducci贸n
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
# Funci贸n para traducir texto
def translate_text(text):
translation = translator(text)
return translation[0]['translation_text']
# Crear la interfaz con Gradio
iface = gr.Interface(
fn=translate_text,
inputs=gr.Textbox(label="Texto en ingl茅s"),
outputs=gr.Textbox(label="Traducci贸n en espa帽ol"),
title="Traductor Ingl茅s - Espa帽ol",
description="Introduce un texto en ingl茅s y obt茅n la traducci贸n al espa帽ol.",
)
# Ejecutar la aplicaci贸n
iface.launch()