AMUseBot/ai_talks/src/utils/tts.py
Adrian Charkiewicz 0d3b7d0a31 initial commit
2023-05-21 22:53:02 +02:00

16 lines
386 B
Python

from io import BytesIO
import streamlit as st
from gtts import gTTS, gTTSError
def show_audio_player(ai_content: str) -> None:
sound_file = BytesIO()
try:
tts = gTTS(text=ai_content, lang=st.session_state.locale.lang_code)
tts.write_to_fp(sound_file)
st.write("try TTS")
st.audio(sound_file)
except gTTSError as err:
st.error(err)