fargerm commited on
Commit
390d4d0
1 Parent(s): 1829ce2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -39,7 +39,7 @@ def translate_text(text, target_lang):
39
 
40
  # Translate text
41
  encoded_text = tokenizer.encode(text, return_tensors="pt")
42
- translated = model.generate(encoded_text, forced_bos_token_id=tokenizer.get_lang_id(target_lang))
43
  translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
44
  return translated_text
45
 
@@ -64,3 +64,4 @@ if st.button("Translate and Synthesize Speech"):
64
  else:
65
  st.audio(audio_bytes, format="audio/wav")
66
 
 
 
39
 
40
  # Translate text
41
  encoded_text = tokenizer.encode(text, return_tensors="pt")
42
+ translated = model.generate(encoded_text, forced_bos_token_id=tokenizer.lang_code_to_id[target_lang])
43
  translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
44
  return translated_text
45
 
 
64
  else:
65
  st.audio(audio_bytes, format="audio/wav")
66
 
67
+