NadiaHolmlund commited on
Commit
84cec7f
·
1 Parent(s): b8446db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -1,19 +1,20 @@
1
- import googletrans
2
  import gradio as gr
 
3
 
4
- translator = googletrans.Translator()
5
 
6
- def translate(text):
7
- result = translator.translate(text, dest='en')
8
- translation = result.text
9
- return translation
10
 
11
- iface = gr.Interface(
12
- fn=translate,
13
- inputs="text",
14
- outputs="text"
15
- output_labels= translation
16
- title="Google Translate"
 
17
  )
18
 
19
- iface.launch()
 
 
 
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
+