Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
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 |
+
|