Engineer-Areeb commited on
Commit
3899ba5
·
verified ·
1 Parent(s): a584f28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from gtts import gTTS
3
+ import os
4
+ from io import BytesIO
5
+
6
+ st.set_page_config(page_title="Text to Speech App", layout="centered")
7
+ st.title("🗣️ Text to Speech Converter")
8
+
9
+ text = st.text_area("Enter the text you want to convert to speech:")
10
+
11
+ if st.button("Convert to Audio"):
12
+ if text.strip() == "":
13
+ st.warning("Please enter some text first.")
14
+ else:
15
+ tts = gTTS(text)
16
+ audio_bytes = BytesIO()
17
+ tts.write_to_fp(audio_bytes)
18
+ audio_bytes.seek(0)
19
+
20
+ st.success("✅ Conversion successful!")
21
+ st.audio(audio_bytes, format="audio/mp3")
22
+