Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
5 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-en-es")
|
6 |
|
7 |
def traducir_texto(texto_en):
|
8 |
"""
|
@@ -15,7 +14,7 @@ def traducir_texto(texto_en):
|
|
15 |
str: El texto traducido al espa帽ol.
|
16 |
"""
|
17 |
try:
|
18 |
-
resultado =
|
19 |
return resultado[0]['translation_text']
|
20 |
except Exception as e:
|
21 |
return f"Error en la traducci贸n: {e}"
|
|
|
1 |
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
|
2 |
import gradio as gr
|
3 |
|
4 |
+
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
|
|
|
5 |
|
6 |
def traducir_texto(texto_en):
|
7 |
"""
|
|
|
14 |
str: El texto traducido al espa帽ol.
|
15 |
"""
|
16 |
try:
|
17 |
+
resultado = pipe(texto_en)
|
18 |
return resultado[0]['translation_text']
|
19 |
except Exception as e:
|
20 |
return f"Error en la traducci贸n: {e}"
|