Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
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 =
|
22 |
-
return translation
|
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 |
+
|