vsj0702 commited on
Commit
0dd364f
·
verified ·
1 Parent(s): badf556

adding restriction to play one audio at a time

Browse files
Files changed (1) hide show
  1. chatbot.py +16 -6
chatbot.py CHANGED
@@ -169,9 +169,19 @@ def render_chatbot(code, output, error):
169
  st.session_state.chat_display_count += 5
170
  st.rerun()
171
 
172
- st.markdown("""
173
- <script>
174
- const c = window.parent.document.querySelector('.chat-container');
175
- if (c) c.scrollTop = c.scrollHeight;
176
- </script>
177
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
169
  st.session_state.chat_display_count += 5
170
  st.rerun()
171
 
172
+ st.markdown("""
173
+ <script>
174
+ const c = window.parent.document.querySelector('.chat-container');
175
+ if (c) c.scrollTop = c.scrollHeight;
176
+ </script>
177
+
178
+ <script>
179
+ document.querySelectorAll('audio').forEach(audio => {
180
+ audio.addEventListener('play', function () {
181
+ document.querySelectorAll('audio').forEach(a => {
182
+ if (a !== this) a.pause();
183
+ });
184
+ });
185
+ });
186
+ </script>
187
+ """, unsafe_allow_html=True)