deepugaur commited on
Commit
3a9379f
·
verified ·
1 Parent(s): 7a443de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from googletrans import Translator
3
  import datetime
4
 
5
  def translate_word(word):
@@ -16,10 +16,9 @@ def translate_word(word):
16
  return "Error: Words starting with vowels cannot be translated"
17
 
18
  # Translate the word using Google Translator
19
- translator = Translator()
20
  try:
21
- translation = translator.translate(word, src='en', dest='hi')
22
- return translation.text
23
  except Exception as e:
24
  return f"Error: {str(e)}"
25
 
@@ -31,3 +30,4 @@ word = st.text_input('Enter a word:')
31
  if st.button('Translate'):
32
  translation = translate_word(word)
33
  st.write(f"Translation: {translation}")
 
 
1
  import streamlit as st
2
+ from deep_translator import GoogleTranslator
3
  import datetime
4
 
5
  def translate_word(word):
 
16
  return "Error: Words starting with vowels cannot be translated"
17
 
18
  # Translate the word using Google Translator
 
19
  try:
20
+ translation = GoogleTranslator(source='en', target='hi').translate(word)
21
+ return translation
22
  except Exception as e:
23
  return f"Error: {str(e)}"
24
 
 
30
  if st.button('Translate'):
31
  translation = translate_word(word)
32
  st.write(f"Translation: {translation}")
33
+