prol99 commited on
Commit
253e06f
verified
1 Parent(s): 6279809

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -1,22 +1,33 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Cargar el modelo de traducci贸n
5
- translator = pipeline("translation_es_to_ast", model="Helsinki-NLP/opus-mt-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 Helsinki-NLP/opus-mt-es-ast."
 
 
 
 
 
19
  )
20
 
21
  # Lanzar la aplicaci贸n
22
- iface.launch()
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Inicializar el modelo de traducci贸n
5
+ translator = pipeline("translation", model="projecte-aina/aina-translator-es-ast")
6
 
7
+ def translate_text(text):
8
+ """
9
+ Traduce texto del espa帽ol al asturiano
10
+ """
11
+ if not text:
12
+ return ""
13
+
14
+ result = translator(text, max_length=400)
15
+ return result[0]['translation_text']
16
 
17
+ # Crear la interfaz Gradio
18
+ demo = gr.Interface(
19
+ fn=translate_text,
20
+ inputs=gr.Textbox(label="Texto en espa帽ol", placeholder="Escribe aqu铆 el texto a traducir..."),
21
+ outputs=gr.Textbox(label="Traducci贸n al asturiano"),
22
+ title="Traductor Espa帽ol-Asturiano",
23
+ description="Traductor basado en el modelo AINA para traducir del espa帽ol al asturiano.",
24
+ examples=[
25
+ ["Hola, 驴c贸mo est谩s?"],
26
+ ["Me gusta mucho Asturias y su cultura"],
27
+ ["El cielo est谩 muy azul hoy"]
28
+ ]
29
  )
30
 
31
  # Lanzar la aplicaci贸n
32
+ if __name__ == "__main__":
33
+ demo.launch()