Neprox commited on
Commit
466d654
1 Parent(s): 640273e

switch to yet another library

Browse files
Files changed (2) hide show
  1. app.py +5 -3
  2. requirements.txt +1 -1
app.py CHANGED
@@ -7,10 +7,11 @@ from moviepy.editor import AudioFileClip
7
 
8
  # import googletrans # googletrans api
9
  # from googletrans import Translator # googletrans api
10
- from google_trans_new import google_translator
 
11
 
12
  pipe = pipeline(model="Neprox/model")
13
- translator = google_translator()
14
  # translator = Translator() # googletrans api
15
 
16
  # Get languages available for translation
@@ -89,7 +90,8 @@ def get_translation(text, target_lang="English (en)"):
89
  Translates the given Swedish text to the language specified.
90
  """
91
  lang_code = target_lang.split(" ")[-1][1:-1]
92
- return translator.translate(text, lang_tgt=lang_code)
 
93
  # result = translator.translate(text, lang_code, 'sv') # googletrans api
94
  # return result.text # googletrans api
95
 
 
7
 
8
  # import googletrans # googletrans api
9
  # from googletrans import Translator # googletrans api
10
+ # from google_trans_new import google_translator # google_trans_new api
11
+ from deep_translator import MicrosoftTranslator # GoogleTranslator
12
 
13
  pipe = pipeline(model="Neprox/model")
14
+ # translator = google_translator() # google_trans_new api
15
  # translator = Translator() # googletrans api
16
 
17
  # Get languages available for translation
 
90
  Translates the given Swedish text to the language specified.
91
  """
92
  lang_code = target_lang.split(" ")[-1][1:-1]
93
+ return MicrosoftTranslator(source='sv', target=lang_code).translate(text)
94
+ # return translator.translate(text, lang_tgt=lang_code) # googletrans_new api
95
  # result = translator.translate(text, lang_code, 'sv') # googletrans api
96
  # return result.text # googletrans api
97
 
requirements.txt CHANGED
@@ -7,5 +7,5 @@ torch
7
  torchaudio
8
  moviepy
9
  git+https://github.com/pytube/pytube
10
- git+https://github.com/lushan88a/google_trans_new
11
  #google-trans-new
 
7
  torchaudio
8
  moviepy
9
  git+https://github.com/pytube/pytube
10
+ deep-translator
11
  #google-trans-new