File size: 880 Bytes
8cd0ff6 5c147df d7aaead 8cd0ff6 5c147df 8cd0ff6 5c147df 2ecc02f 5c147df 2ecc02f 5c147df d7aaead 5c147df 2ecc02f 5c147df 2ecc02f 5c147df d7aaead 2ecc02f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import streamlit as st
from gtts import gTTS
import os
# Streamlit app setup
st.title("Text-to-Speech Converter")
st.write("Enter your text below to convert it into speech.")
# Text input
user_input = st.text_area("Enter text here:", "")
if st.button("Convert to Speech"):
if user_input.strip():
# Generate speech
tts = gTTS(user_input, lang="en")
tts.save("output.mp3")
# Display audio player
st.audio("output.mp3", format="audio/mp3")
# Provide download link
with open("output.mp3", "rb") as audio_file:
st.download_button("Download Audio", audio_file, file_name="output.mp3", mime="audio/mp3")
# Clean up
os.remove("output.mp3")
else:
st.error("Please enter some text.")
# Footer
st.markdown("Developed by [Your Name]. Deployed on Hugging Face Spaces.")
|