Update app.py
Browse files
app.py
CHANGED
@@ -31,11 +31,12 @@ def translate_speech(audio):
|
|
31 |
translated_text = translator(transcription, return_tensors="pt")
|
32 |
print(f"Translated text: {translated_text}") # Print the translated text to see what it contains
|
33 |
|
34 |
-
# Check if the translated text contains '
|
35 |
-
if '
|
36 |
-
|
|
|
37 |
else:
|
38 |
-
print("The translated text does not contain '
|
39 |
return
|
40 |
|
41 |
# Use the text-to-speech pipeline to synthesize the translated text
|
|
|
31 |
translated_text = translator(transcription, return_tensors="pt")
|
32 |
print(f"Translated text: {translated_text}") # Print the translated text to see what it contains
|
33 |
|
34 |
+
# Check if the translated text contains 'generated_token_ids'
|
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 |
else:
|
39 |
+
print("The translated text does not contain 'generated_token_ids'")
|
40 |
return
|
41 |
|
42 |
# Use the text-to-speech pipeline to synthesize the translated text
|