Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,10 @@ import numpy as np
|
|
6 |
|
7 |
|
8 |
tts_model = TTSInferencing.from_hparams(source="./",
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech")
|
15 |
|
@@ -18,18 +18,18 @@ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech")
|
|
18 |
# Input text
|
19 |
text = st.text_area("Enter your text here")
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
6 |
|
7 |
|
8 |
tts_model = TTSInferencing.from_hparams(source="./",
|
9 |
+
hparams_file='./hyperparams.yaml',
|
10 |
+
pymodule_file='./module_classes.py',
|
11 |
+
# savedir="./",
|
12 |
+
)
|
13 |
|
14 |
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech")
|
15 |
|
|
|
18 |
# Input text
|
19 |
text = st.text_area("Enter your text here")
|
20 |
|
21 |
+
|
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.")
|