Upload 2 files
Browse files- app.py +36 -0
- requirements.txt +0 -0
app.py
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from gtts import gTTS
|
| 3 |
+
from io import BytesIO
|
| 4 |
+
|
| 5 |
+
LANG = "en"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# https://gtts.readthedocs.io/en/latest/
|
| 9 |
+
#
|
| 10 |
+
def tts_gtts(text):
|
| 11 |
+
mp3_fp = BytesIO()
|
| 12 |
+
tts = gTTS(text, lang=LANG)
|
| 13 |
+
tts.write_to_fp(mp3_fp)
|
| 14 |
+
return mp3_fp
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def pronounce(text, gender=None):
|
| 18 |
+
if len(text) > 0:
|
| 19 |
+
data1 = tts_gtts(text)
|
| 20 |
+
st.text('gTTS (gender not supported):')
|
| 21 |
+
st.audio(data1, format="audio/wav", start_time=0)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def main():
|
| 25 |
+
st.title('TTS Demo')
|
| 26 |
+
# uploaded_file = st.file_uploader("Upload a recording of you saying the text in .wav format")
|
| 27 |
+
# if uploaded_file is not None:
|
| 28 |
+
# pass
|
| 29 |
+
text_input = st.text_input("", value="Input the text you are saying in your recording.")
|
| 30 |
+
gender_input = st.radio("Gender", ["M", "F"], captions=["", ""], horizontal=True)
|
| 31 |
+
if st.button("Pronounce"):
|
| 32 |
+
pronounce(text_input, gender_input)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
main()
|
requirements.txt
ADDED
|
File without changes
|