Solshine commited on
Commit
28c0e05
1 Parent(s): 0a92a20

Added st.session_state.messages.append(audio_convert)

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -105,6 +105,8 @@ def launch_bot():
105
  if st.session_state.messages[-1]["role"] == "assistant" or st.session_state_messafes[-1]["role"] == "content":
106
  audio_result = st.button("Convert to Audio 🔊")
107
  if audio_result:
 
 
108
  #text-to-speech
109
  print("Calling in Text-to-speech via suno/bark-small")
110
  synthesiser = pipeline("text-to-speech", "suno/bark-small")
@@ -117,8 +119,9 @@ def launch_bot():
117
  audio_file = open('bark_out.wav', 'rb')
118
  audio_bytes = audio_file.read()
119
 
120
- st.audio(audio_bytes, format='audio/wav')
121
-
 
122
  sample_rate = 44100 # 44100 samples per second
123
  seconds = 2 # Note duration of 2 seconds
124
  frequency_la = 440 # Our played note will be 440 Hz
 
105
  if st.session_state.messages[-1]["role"] == "assistant" or st.session_state_messafes[-1]["role"] == "content":
106
  audio_result = st.button("Convert to Audio 🔊")
107
  if audio_result:
108
+ with st.chat_message("text-to-speech"):
109
+ with st.spinner("Thinking..."):
110
  #text-to-speech
111
  print("Calling in Text-to-speech via suno/bark-small")
112
  synthesiser = pipeline("text-to-speech", "suno/bark-small")
 
119
  audio_file = open('bark_out.wav', 'rb')
120
  audio_bytes = audio_file.read()
121
 
122
+ audio_convert = st.audio(audio_bytes, format='audio/wav')
123
+ st.session_state.messages.append(audio_convert)
124
+
125
  sample_rate = 44100 # 44100 samples per second
126
  seconds = 2 # Note duration of 2 seconds
127
  frequency_la = 440 # Our played note will be 440 Hz