Spaces:
Paused
Paused
myhanhhyugen
commited on
Commit
•
931193b
1
Parent(s):
3c1780c
Update app.py
Browse files
app.py
CHANGED
@@ -16,20 +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.
|
20 |
-
|
21 |
-
|
22 |
-
if text:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
else:
|
35 |
-
|
|
|
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 st.button("Synthesize 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.")
|