2023-03-02 18:58:40 +01:00
|
|
|
from io import BytesIO
|
|
|
|
|
|
|
|
import streamlit as st
|
2023-03-22 17:13:02 +01:00
|
|
|
from gtts import gTTS, gTTSError
|
2023-03-02 18:58:40 +01:00
|
|
|
|
|
|
|
|
2023-04-15 22:03:29 +02:00
|
|
|
def show_audio_player(ai_content: str) -> None:
|
2023-03-02 18:58:40 +01:00
|
|
|
sound_file = BytesIO()
|
2023-03-08 14:07:09 +01:00
|
|
|
try:
|
2023-03-22 17:13:02 +01:00
|
|
|
tts = gTTS(text=ai_content, lang=st.session_state.locale.lang_code)
|
2023-03-08 14:07:09 +01:00
|
|
|
tts.write_to_fp(sound_file)
|
2023-05-21 22:53:02 +02:00
|
|
|
st.write("try TTS")
|
2023-03-08 14:07:09 +01:00
|
|
|
st.audio(sound_file)
|
|
|
|
except gTTSError as err:
|
|
|
|
st.error(err)
|