NadiaHolmlund commited on
Commit
1855ed6
·
1 Parent(s): 14e381d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -1,20 +1,19 @@
1
- import gradio as gr
2
  from googletrans import Translator
 
3
 
4
- translator = Translator()
5
-
6
- def translate_text(text):
7
- translation = translator.translate(text, dest="en")
8
- return translation.text
 
9
 
10
- gradio_interface = gr.Interface(
11
- fn=translate_text,
12
  inputs="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
-
 
 
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()