Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,11 @@ def translate_speech(audio_input):
|
|
35 |
if 'generated_token_ids' in translated_text[0]:
|
36 |
# Decode the tokens into text
|
37 |
translated_text_str = translator.tokenizer.decode(translated_text[0]['generated_token_ids'])
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
else:
|
40 |
print("The translated text does not contain 'generated_token_ids'")
|
41 |
return
|
|
|
35 |
if 'generated_token_ids' in translated_text[0]:
|
36 |
# Decode the tokens into text
|
37 |
translated_text_str = translator.tokenizer.decode(translated_text[0]['generated_token_ids'])
|
38 |
+
|
39 |
+
# Remove padding tokens
|
40 |
+
translated_text_str = translated_text_str.replace("<pad>", "").strip()
|
41 |
+
|
42 |
+
print(f"Translated text string: {translated_text_str}") # Print the translated text string
|
43 |
else:
|
44 |
print("The translated text does not contain 'generated_token_ids'")
|
45 |
return
|