|
import streamlit as st |
|
from gtts import gTTS |
|
import os |
|
|
|
|
|
st.title("Text-to-Speech Converter") |
|
st.write("Enter your text below to convert it into speech.") |
|
|
|
|
|
user_input = st.text_area("Enter text here:", "") |
|
|
|
if st.button("Convert to Speech"): |
|
if user_input.strip(): |
|
|
|
tts = gTTS(user_input, lang="en") |
|
tts.save("output.mp3") |
|
|
|
|
|
st.audio("output.mp3", format="audio/mp3") |
|
|
|
|
|
with open("output.mp3", "rb") as audio_file: |
|
st.download_button("Download Audio", audio_file, file_name="output.mp3", mime="audio/mp3") |
|
|
|
|
|
os.remove("output.mp3") |
|
else: |
|
st.error("Please enter some text.") |
|
|
|
|
|
st.markdown("Developed by [Your Name]. Deployed on Hugging Face Spaces.") |
|
|