myhanhhyugen commited on
Commit
4d27b7b
·
verified ·
1 Parent(s): fc16346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -21,7 +21,11 @@ if text:
21
  mel_outputs = tts_model.encode_batch(text)
22
  waveforms = hifi_gan.decode_batch(mel_outputs)
23
 
24
- waveform = waveforms[0].squeeze(1)
 
 
 
 
25
 
26
  # Display the audio widget to play the synthesized speech
27
- st.audio(waveform.numpy(), format="audio/wav", sample_rate = 22050)
 
21
  mel_outputs = tts_model.encode_batch(text)
22
  waveforms = hifi_gan.decode_batch(mel_outputs)
23
 
24
+ waveform = waveforms[0].squeeze(1).numpy()
25
+
26
+ # Normalize the waveform to the range [-1, 1] if necessary
27
+ if np.max(np.abs(waveform)) > 1.0:
28
+ waveform /= np.max(np.abs(waveform))
29
 
30
  # Display the audio widget to play the synthesized speech
31
+ st.audio(waveform, format="audio/wav", sample_rate = 22050)