Spaces:
Sleeping
Sleeping
ayush-thakur02
commited on
Commit
•
a371f9f
1
Parent(s):
860e02b
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
def translate_text(text, direction):
|
5 |
-
translator = Translator()
|
6 |
-
|
7 |
if direction == "Hindi to English":
|
8 |
-
|
9 |
else: # English to Hindi
|
10 |
-
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
# Define the Gradio interface
|
15 |
iface = gr.Interface(
|
@@ -24,4 +23,4 @@ iface = gr.Interface(
|
|
24 |
)
|
25 |
|
26 |
# Launch the interface
|
27 |
-
iface.launch(
|
|
|
1 |
import gradio as gr
|
2 |
+
from deep_translator import GoogleTranslator
|
3 |
|
4 |
def translate_text(text, direction):
|
|
|
|
|
5 |
if direction == "Hindi to English":
|
6 |
+
translator = GoogleTranslator(source='hi', target='en')
|
7 |
else: # English to Hindi
|
8 |
+
translator = GoogleTranslator(source='en', target='hi')
|
9 |
|
10 |
+
translated = translator.translate(text)
|
11 |
+
return translated
|
12 |
|
13 |
# Define the Gradio interface
|
14 |
iface = gr.Interface(
|
|
|
23 |
)
|
24 |
|
25 |
# Launch the interface
|
26 |
+
iface.launch()
|