Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Cargar el modelo de traducci贸n
|
| 5 |
+
translator = pipeline("translation", model="projecte-aina/aina-translator-es-ast")
|
| 6 |
+
|
| 7 |
+
# Funci贸n para traducir texto
|
| 8 |
+
def translate(text):
|
| 9 |
+
translation = translator(text, max_length=400)
|
| 10 |
+
return translation[0]['translation_text']
|
| 11 |
+
|
| 12 |
+
# Crear la interfaz de Gradio
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=translate,
|
| 15 |
+
inputs=gr.Textbox(lines=2, placeholder="Introduce el texto en espa帽ol aqu铆..."),
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Traductor Espa帽ol - Asturiano",
|
| 18 |
+
description="Traduce texto de espa帽ol a asturiano utilizando el modelo de Projecte Aina."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Lanzar la aplicaci贸n
|
| 22 |
+
iface.launch()
|