Spaces:
Sleeping
Sleeping
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") | |