Mds21 commited on
Commit
4b735d6
1 Parent(s): b2164b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -17,6 +17,17 @@ def hindi_translate(text_):
17
  # Decode the translation
18
  hindi_translation = tokenizer.decode(translation[0], skip_special_tokens=True)
19
  return hindi_translation
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  # results = translation_pipeline('I love ice cream')
22
  # results[0]['translation_text']
@@ -25,7 +36,7 @@ def translate_transformers(English,Language_To_Translate):
25
  results = translation_pipeline_german(English)
26
  return results[0]['translation_text']
27
  elif "Hindi" in Language_To_Translate:
28
- results = hindi_translate(English)
29
  return results
30
 
31
 
 
17
  # Decode the translation
18
  hindi_translation = tokenizer.decode(translation[0], skip_special_tokens=True)
19
  return hindi_translation
20
+ def en_hi_translate(text):
21
+ from googletrans import Translator
22
+ # Initialize the translator
23
+ translator = Translator()
24
+
25
+ # English text to be translated
26
+ english_text = "Hello, how are you?"
27
+
28
+ # Translate text from English to Hindi
29
+ translation = translator.translate(english_text, src='en', dest='hi')
30
+ return translation
31
 
32
  # results = translation_pipeline('I love ice cream')
33
  # results[0]['translation_text']
 
36
  results = translation_pipeline_german(English)
37
  return results[0]['translation_text']
38
  elif "Hindi" in Language_To_Translate:
39
+ results = en_hi_translate(English)
40
  return results
41
 
42