myhanhhyugen commited on
Commit
fa0ce57
1 Parent(s): 66521e9

create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from TTSInferencing import TTSInferencing
2
+ import streamlit as st
3
+ from speechbrain.inference.vocoders import HIFIGAN
4
+ import torchaudio
5
+
6
+
7
+ tts_model = TTSInferencing.from_hparams(source="./",
8
+ hparams_file='./hyperparams.yaml',
9
+ pymodule_file='./module_classes.py',
10
+ savedir="/results/",
11
+ )
12
+
13
+ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir='/pretrained_models/hifi-gan-ljspeech')
14
+
15
+ # text = ["Hello I am a girl", "How is your day going", "I hope you are doing well"]
16
+
17
+ # Input text
18
+ text = [st.text_input("Enter your text here")]
19
+
20
+ 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")