Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,8 @@ if 'user_input' not in st.session_state:
|
|
51 |
st.session_state['user_input'] = ''
|
52 |
if 'audio_data' not in st.session_state:
|
53 |
st.session_state['audio_data'] = None
|
|
|
|
|
54 |
|
55 |
# --- Streamlit UI ---
|
56 |
st.title("Gemini Chatbot")
|
@@ -191,9 +193,10 @@ async def run_webrtc():
|
|
191 |
)
|
192 |
|
193 |
if webrtc_ctx.audio_receiver:
|
|
|
194 |
st.write("Recording audio...")
|
195 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
196 |
-
st.session_state.audio_data = b"".join([frame.to_ndarray() for frame in audio_frames])
|
197 |
|
198 |
if st.button("Send Recording"):
|
199 |
send_message(audio_data=st.session_state.audio_data)
|
|
|
51 |
st.session_state['user_input'] = ''
|
52 |
if 'audio_data' not in st.session_state:
|
53 |
st.session_state['audio_data'] = None
|
54 |
+
if 'is_recording' not in st.session_state:
|
55 |
+
st.session_state['is_recording'] = False
|
56 |
|
57 |
# --- Streamlit UI ---
|
58 |
st.title("Gemini Chatbot")
|
|
|
193 |
)
|
194 |
|
195 |
if webrtc_ctx.audio_receiver:
|
196 |
+
st.session_state.is_recording = True
|
197 |
st.write("Recording audio...")
|
198 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
199 |
+
st.session_state.audio_data = b"".join([frame.to_ndarray().tobytes() for frame in audio_frames])
|
200 |
|
201 |
if st.button("Send Recording"):
|
202 |
send_message(audio_data=st.session_state.audio_data)
|