Spaces:
Sleeping
Sleeping
Phạm Anh Tuấn
commited on
Commit
·
812ef64
1
Parent(s):
9dbc8cb
Initial commit
Browse files- app.py +35 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from gtts import gTTS
|
3 |
+
import io
|
4 |
+
|
5 |
+
# Function to generate audio from text
|
6 |
+
def text_to_audio(text):
|
7 |
+
tts = gTTS(text)
|
8 |
+
audio = tts.save("output.mp3")
|
9 |
+
return audio
|
10 |
+
|
11 |
+
st.title("Voice Synthesis App")
|
12 |
+
|
13 |
+
# Input form for the user to enter text
|
14 |
+
user_input = st.text_area("Enter the text:")
|
15 |
+
|
16 |
+
if st.button("Generate"):
|
17 |
+
if user_input:
|
18 |
+
audio = text_to_audio(user_input)
|
19 |
+
|
20 |
+
# Display the audio
|
21 |
+
st.audio("output.mp3", format="audio/mp3")
|
22 |
+
|
23 |
+
# Create a download link for the audio file
|
24 |
+
st.markdown("### Download the audio")
|
25 |
+
with open("output.mp3", "rb") as audio_file:
|
26 |
+
audio_bytes = audio_file.read()
|
27 |
+
st.download_button(
|
28 |
+
label="Click to download",
|
29 |
+
data=audio_bytes,
|
30 |
+
key="download_audio",
|
31 |
+
file_name="output.mp3",
|
32 |
+
mime="audio/mp3",
|
33 |
+
)
|
34 |
+
|
35 |
+
st.write("Note: This app uses gTTS for text-to-speech conversion.")
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gTTS
|