Spaces:
Runtime error
Runtime error
NadiaHolmlund
commited on
Commit
·
84cec7f
1
Parent(s):
b8446db
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
-
import googletrans
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
translator =
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
translation
|
9 |
-
return translation
|
10 |
|
11 |
-
|
12 |
-
fn=
|
13 |
-
inputs="text",
|
14 |
-
outputs="text"
|
15 |
-
|
16 |
-
|
|
|
17 |
)
|
18 |
|
19 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from googletrans import Translator
|
3 |
|
4 |
+
translator = Translator()
|
5 |
|
6 |
+
def translate_text(text, dest_language):
|
7 |
+
translation = translator.translate(text, dest=dest_language)
|
8 |
+
return translation.text
|
|
|
9 |
|
10 |
+
gradio_interface = gr.Interface(
|
11 |
+
fn=translate_text,
|
12 |
+
inputs=["text", "text"],
|
13 |
+
outputs="text",
|
14 |
+
title="Google Translate",
|
15 |
+
description="Translate text using Google Translate API",
|
16 |
+
theme="default"
|
17 |
)
|
18 |
|
19 |
+
gradio_interface.launch()
|
20 |
+
|