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