Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,10 @@ def translate_speech(audio_file_path):
|
|
37 |
if 'generated_token_ids' in translated_text[0]:
|
38 |
# Decode the tokens into text
|
39 |
translated_text_str = translator.tokenizer.decode(translated_text[0]['generated_token_ids'])
|
|
|
|
|
|
|
|
|
40 |
print(f"Translated text string: {translated_text_str}") # Print the translated text string
|
41 |
else:
|
42 |
print("The translated text does not contain 'generated_token_ids'")
|
|
|
37 |
if 'generated_token_ids' in translated_text[0]:
|
38 |
# Decode the tokens into text
|
39 |
translated_text_str = translator.tokenizer.decode(translated_text[0]['generated_token_ids'])
|
40 |
+
|
41 |
+
# Remove special tokens
|
42 |
+
translated_text_str = translated_text_str.replace("<pad>", "").replace("</s>", "").strip()
|
43 |
+
|
44 |
print(f"Translated text string: {translated_text_str}") # Print the translated text string
|
45 |
else:
|
46 |
print("The translated text does not contain 'generated_token_ids'")
|