from TTSInferencing import TTSInferencing import streamlit as st from speechbrain.inference.vocoders import HIFIGAN import torchaudio tts_model = TTSInferencing.from_hparams(source="./", hparams_file='./hyperparams.yaml', pymodule_file='./module_classes.py', savedir="/results/", ) hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir='/pretrained_models/hifi-gan-ljspeech') # text = ["Hello I am a girl", "How is your day going", "I hope you are doing well"] # Input text text = [st.text_input("Enter your text here")] if text: mel_outputs = tts_model.encode_batch(text) waveforms = hifi_gan.decode_batch(mel_outputs) waveform = waveforms[0].squeeze(1) # Display the audio widget to play the synthesized speech st.audio(waveform.numpy(), format="audio/wav")