File size: 621 Bytes
878f47d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import streamlit as st
from transformers import pipeline

# Initialize text-to-speech pipeline
tts_model = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")

st.title("Text-to-Speech Generator")
st.write("Convert text into speech audio.")

text = st.text_area("Enter text to convert to speech:", placeholder="Type your text here...")
if st.button("Generate Speech"):
    if not text.strip():
        st.error("Please provide some text to convert.")
    else:
        with st.spinner("Generating speech..."):
            audio = tts_model(text)
            st.audio(audio["output"], format="audio/wav")