myhanhhyugen commited on
Commit
9e918d6
·
verified ·
1 Parent(s): e816c9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -16,17 +16,20 @@ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech")
16
  # text = ["Hello I am a girl", "How is your day going", "I hope you are doing well"]
17
 
18
  # Input text
19
- text = st.text_input("Enter your text here")
20
-
21
- if text:
22
- mel_outputs = tts_model.encode_batch(text)
23
- waveforms = hifi_gan.decode_batch(mel_outputs)
24
-
25
- waveform = waveforms[0].squeeze(1).numpy()
26
-
27
- # Normalize the waveform to the range [-1, 1] if necessary
28
- if np.max(np.abs(waveform)) > 1.0:
29
- waveform /= np.max(np.abs(waveform))
30
-
31
- # Display the audio widget to play the synthesized speech
32
- st.audio(waveform, format="audio/wav", sample_rate = 22050)
 
 
 
 
16
  # text = ["Hello I am a girl", "How is your day going", "I hope you are doing well"]
17
 
18
  # Input text
19
+ text = st.text_area("Enter your text here")
20
+
21
+ if st.button("To Speech"):
22
+ if text:
23
+ mel_outputs = tts_model.encode_batch(text)
24
+ waveforms = hifi_gan.decode_batch(mel_outputs)
25
+
26
+ waveform = waveforms[0].squeeze(1).numpy()
27
+
28
+ # Normalize the waveform to the range [-1, 1] if necessary
29
+ if np.max(np.abs(waveform)) > 1.0:
30
+ waveform /= np.max(np.abs(waveform))
31
+
32
+ # Display the audio widget to play the synthesized speech
33
+ st.audio(waveform, format="audio/wav", sample_rate = 22050)
34
+ else:
35
+ st.error("Please enter text to get the speech.")