LarissaE commited on
Commit
47520da
1 Parent(s): d0f02a4

Changes to google translate

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -57,10 +57,10 @@ def create_segments(audio_fpath, seconds_max):
57
  return segment_paths, segment_start_times
58
 
59
  def get_translation(text):
60
- translator = Translator()
61
- result = translator.translate(text, src='sv', dest='en')
62
-
63
- return result.text
64
 
65
  #translation_pipeline = pipeline("translation", model=model, tokenizer=tokenizer, src_lang=src_lang, tgt_lang=tgt_lang, max_length=400, device=device)
66
  #result = translation_pipeline(text)
 
57
  return segment_paths, segment_start_times
58
 
59
  def get_translation(text):
60
+ translator = Translator(service_urls=['translate.googleapis.com'])
61
+ translated_text = translator.translate(text, lang_tgt="en").text
62
+
63
+ return translated_text
64
 
65
  #translation_pipeline = pipeline("translation", model=model, tokenizer=tokenizer, src_lang=src_lang, tgt_lang=tgt_lang, max_length=400, device=device)
66
  #result = translation_pipeline(text)