Baghdad99 commited on
Commit
730fef5
1 Parent(s): 774e76f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -41,10 +41,18 @@ def translate_speech(audio):
41
 
42
  # Use the text-to-speech pipeline to synthesize the translated text
43
  synthesised_speech = tts(translated_text_str)
 
 
 
 
 
 
 
 
44
 
45
  # Define the max_range variable
46
  max_range = 32767 # You can adjust this value based on your requirements
47
- synthesised_speech = (synthesised_speech.numpy() * max_range).astype(np.int16)
48
 
49
  return 16000, synthesised_speech
50
 
 
41
 
42
  # Use the text-to-speech pipeline to synthesize the translated text
43
  synthesised_speech = tts(translated_text_str)
44
+ print(f"Synthesised speech: {synthesised_speech}") # Print the synthesised speech to see what it contains
45
+
46
+ # Check if the synthesised speech contains the expected key
47
+ if 'key' in synthesised_speech: # Replace 'key' with the actual key
48
+ synthesised_speech_data = synthesised_speech['key'] # Replace 'key' with the actual key
49
+ else:
50
+ print("The synthesised speech does not contain 'key'") # Replace 'key' with the actual key
51
+ return
52
 
53
  # Define the max_range variable
54
  max_range = 32767 # You can adjust this value based on your requirements
55
+ synthesised_speech = (synthesised_speech_data.numpy() * max_range).astype(np.int16)
56
 
57
  return 16000, synthesised_speech
58