hashhac commited on
Commit
3931f99
·
1 Parent(s): 58bcff1

no more int16

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -101,13 +101,11 @@ def text_to_speech(text):
101
  )
102
 
103
  # Convert to numpy array
104
- # Make sure speech is float32 before any conversion to avoid the error
105
  audio_array = speech.cpu().numpy().astype(np.float32)
106
 
107
- # Normalize and convert to int16 for output
108
- audio_array = (audio_array / np.max(np.abs(audio_array) + 1e-6) * 32767).astype(np.int16)
109
 
110
- # Reshape for fastrtc
111
  audio_array = audio_array.reshape(1, -1).astype(np.float32)
112
 
113
  return (16000, audio_array) # SpeechT5 uses 16kHz sample rate
 
101
  )
102
 
103
  # Convert to numpy array
 
104
  audio_array = speech.cpu().numpy().astype(np.float32)
105
 
106
+ # Normalize the audio
107
+ audio_array = audio_array / np.max(np.abs(audio_array) + 1e-6)
108
 
 
109
  audio_array = audio_array.reshape(1, -1).astype(np.float32)
110
 
111
  return (16000, audio_array) # SpeechT5 uses 16kHz sample rate