Hi everyone,
I am trying to work on text to speech sing gTTS on streamlit cloud ant this is how the code is:
def text_speech(text):
tts = gTTS(text=text, lang='en')
speech_bytes = io.BytesIO()
tts.write_to_fp(speech_bytes)
speech_bytes.seek(0)
# Convert speech to base64 encoding
speech_base64 = base64.b64encode(speech_bytes.read()).decode('utf-8')
return speech_base64
when I press on the convert to speech I first get the player and then if I click it it plays, which Is ok but I wanted something like if I play convert to speech it should do the work.
Any way to do so?
2 Likes
Hi @Pooja_Harihar
Can you please paste the repo?
Thanks,
Charly
1 Like
Try autoplay in the meta data. I am doing it in my app https://conversation.streamlit.app/ . Let me know if you need some details.
def autoplay_audio3(file):
b64 = base64.b64encode(file).decode()
if autoplay:
md = f"""
<audio id="audioTag" controls autoplay>
<source src="data:audio/mp3;base64,{b64}" type="audio/mpeg" format="audio/mpeg">
</audio>
"""
else:
md = f"""
<audio id="audioTag" controls>
<source src="data:audio/mp3;base64,{b64}" type="audio/mpeg" format="audio/mpeg">
</audio>
"""
st.markdown(
md,
unsafe_allow_html=True,
)
3 Likes
Hii @shawngiese , I went through the conversation app, and its amazing, I am inspired by the different languages and planning to incorporate Indian languages too. Would be grateful if I receive the details.
1 Like
Thanks, @Pooja_Harihar .
Did you try adding autoplay to the metadata, as Shawn suggested?
Best,
Charly
1 Like
system
Closed
October 14, 2024, 8:12am
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.