ayush-thakur02 commited on
Commit
a371f9f
1 Parent(s): 860e02b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,15 +1,14 @@
1
  import gradio as gr
2
- from googletrans import Translator
3
 
4
  def translate_text(text, direction):
5
- translator = Translator()
6
-
7
  if direction == "Hindi to English":
8
- translated = translator.translate(text, src='hi', dest='en')
9
  else: # English to Hindi
10
- translated = translator.translate(text, src='en', dest='hi')
11
 
12
- return translated.text
 
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(debug=True)
 
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()