Spaces:
Sleeping
Sleeping
Commit
•
f0d7f2f
1
Parent(s):
8a6de5e
Upload 2 files
Browse files- app.py +31 -0
- requirements.txt +46 -0
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import necessary libraries
|
2 |
+
import streamlit as st
|
3 |
+
from gtts import gTTS
|
4 |
+
from io import BytesIO
|
5 |
+
|
6 |
+
# Set Streamlit title
|
7 |
+
st.title("Text-to-Speech App")
|
8 |
+
|
9 |
+
# Add a textarea for user input
|
10 |
+
user_input = st.text_area("Enter the text you want to convert to speech:")
|
11 |
+
|
12 |
+
# Function to convert text to speech
|
13 |
+
def text_to_speech(text):
|
14 |
+
# Create a Text-to-Speech object
|
15 |
+
tts = gTTS(text=text, lang='en')
|
16 |
+
|
17 |
+
# Save the speech as a BytesIO object
|
18 |
+
speech_bytes = BytesIO()
|
19 |
+
tts.write_to_fp(speech_bytes)
|
20 |
+
|
21 |
+
return speech_bytes
|
22 |
+
|
23 |
+
# Check if the user has entered any text
|
24 |
+
if user_input:
|
25 |
+
# Add a button to trigger text-to-speech conversion
|
26 |
+
if st.button("Convert to Speech"):
|
27 |
+
# Convert text to speech
|
28 |
+
speech_bytes = text_to_speech(user_input)
|
29 |
+
|
30 |
+
# Display the audio player for the generated speech
|
31 |
+
st.audio(speech_bytes, format='audio/wav')
|
requirements.txt
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==5.2.0
|
2 |
+
attrs==23.2.0
|
3 |
+
blinker==1.7.0
|
4 |
+
cachetools==5.3.2
|
5 |
+
certifi==2024.2.2
|
6 |
+
charset-normalizer==3.3.2
|
7 |
+
click==8.1.7
|
8 |
+
gitdb==4.0.11
|
9 |
+
GitPython==3.1.41
|
10 |
+
gTTS==2.5.1
|
11 |
+
idna==3.6
|
12 |
+
importlib-metadata==7.0.1
|
13 |
+
Jinja2==3.1.3
|
14 |
+
jsonschema==4.21.1
|
15 |
+
jsonschema-specifications==2023.12.1
|
16 |
+
markdown-it-py==3.0.0
|
17 |
+
MarkupSafe==2.1.5
|
18 |
+
mdurl==0.1.2
|
19 |
+
numpy==1.26.4
|
20 |
+
packaging==23.2
|
21 |
+
pandas==2.2.0
|
22 |
+
pillow==10.2.0
|
23 |
+
protobuf==4.25.2
|
24 |
+
pyarrow==15.0.0
|
25 |
+
pydeck==0.8.1b0
|
26 |
+
Pygments==2.17.2
|
27 |
+
python-dateutil==2.8.2
|
28 |
+
pytz==2024.1
|
29 |
+
referencing==0.33.0
|
30 |
+
requests==2.31.0
|
31 |
+
rich==13.7.0
|
32 |
+
rpds-py==0.17.1
|
33 |
+
six==1.16.0
|
34 |
+
smmap==5.0.1
|
35 |
+
streamlit==1.31.0
|
36 |
+
tenacity==8.2.3
|
37 |
+
toml==0.10.2
|
38 |
+
toolz==0.12.1
|
39 |
+
tornado==6.4
|
40 |
+
typing_extensions==4.9.0
|
41 |
+
tzdata==2023.4
|
42 |
+
tzlocal==5.2
|
43 |
+
urllib3==2.2.0
|
44 |
+
validators==0.22.0
|
45 |
+
watchdog==4.0.0
|
46 |
+
zipp==3.17.0
|