Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -214,9 +214,11 @@ async def run_webrtc():
|
|
214 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
215 |
audio_data = [frame.to_ndarray() for frame in audio_frames]
|
216 |
st.session_state.audio_data = convert_frames_to_wav(audio_data)
|
|
|
|
|
217 |
|
218 |
-
|
219 |
-
|
220 |
|
221 |
# --- Other Buttons ---
|
222 |
st.button("Clear Conversation", on_click=clear_conversation)
|
@@ -227,20 +229,17 @@ st.session_state.uploaded_files = uploaded_files
|
|
227 |
# --- JavaScript for Ctrl+Enter ---
|
228 |
st.markdown(
|
229 |
"""
|
230 |
-
<script>
|
231 |
-
document.addEventListener(
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
});
|
238 |
-
});
|
239 |
-
</script>
|
240 |
""",
|
241 |
unsafe_allow_html=True
|
242 |
)
|
243 |
|
244 |
# --- Run WebRTC and display chat history ---
|
245 |
-
asyncio.
|
246 |
display_chat_history()
|
|
|
214 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
215 |
audio_data = [frame.to_ndarray() for frame in audio_frames]
|
216 |
st.session_state.audio_data = convert_frames_to_wav(audio_data)
|
217 |
+
else:
|
218 |
+
st.session_state.is_recording = False
|
219 |
|
220 |
+
if st.button("Send Recording"):
|
221 |
+
send_message(audio_data=st.session_state.audio_data)
|
222 |
|
223 |
# --- Other Buttons ---
|
224 |
st.button("Clear Conversation", on_click=clear_conversation)
|
|
|
229 |
# --- JavaScript for Ctrl+Enter ---
|
230 |
st.markdown(
|
231 |
"""
|
232 |
+
<script>
|
233 |
+
document.addEventListener("keydown", function(event) {
|
234 |
+
if (event.ctrlKey && event.key === 'Enter') {
|
235 |
+
document.querySelector('button[type="primary"]').click();
|
236 |
+
}
|
237 |
+
});
|
238 |
+
</script>
|
|
|
|
|
|
|
239 |
""",
|
240 |
unsafe_allow_html=True
|
241 |
)
|
242 |
|
243 |
# --- Run WebRTC and display chat history ---
|
244 |
+
asyncio.run(run_webrtc())
|
245 |
display_chat_history()
|