| | import streamlit as st |
| | from gtts import gTTS |
| | from io import BytesIO |
| |
|
| | LANG = "en" |
| |
|
| |
|
| | |
| | |
| | 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') |
| | |
| | |
| | |
| | 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() |
| |
|