Spaces:
Runtime error
Runtime error
NadiaHolmlund
commited on
Commit
·
1855ed6
1
Parent(s):
14e381d
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
-
import gradio as gr
|
2 |
from googletrans import Translator
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
translation =
|
8 |
-
|
|
|
9 |
|
10 |
-
|
11 |
-
fn=
|
12 |
inputs="text",
|
13 |
-
outputs="text",
|
14 |
-
|
15 |
-
|
16 |
-
theme="default"
|
17 |
)
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
1 |
from googletrans import Translator
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
def translate(text):
|
5 |
+
translator = Translator()
|
6 |
+
result = translator.translate(text, dest='en')
|
7 |
+
translation = result.text
|
8 |
+
pronunciation = translator.translate(translation, dest='ja').pronunciation
|
9 |
+
return f"Pronunciation: {pronunciation}", f"Translation: {translation}"
|
10 |
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=translate,
|
13 |
inputs="text",
|
14 |
+
outputs=["text", "text"],
|
15 |
+
output_labels=["Pronunciation", "Translation"],
|
16 |
+
title="Japanese to English Translator"
|
|
|
17 |
)
|
18 |
|
19 |
+
iface.launch()
|
|