Spaces:
Runtime error
Runtime error
ziyadsuper2017
commited on
Commit
•
3f12240
1
Parent(s):
2319409
Update app.py
Browse files
app.py
CHANGED
@@ -171,24 +171,20 @@ uploaded_files = st.file_uploader(
|
|
171 |
# --- WebRTC Audio Recording ---
|
172 |
RTC_CONFIGURATION = RTCConfiguration({"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]})
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
rtc_configuration=RTC_CONFIGURATION,
|
182 |
-
audio_receiver_size=256,
|
183 |
-
media_stream_constraints={"video": False, "audio": True},
|
184 |
-
)
|
185 |
-
st.session_state.webrtc_initialized = True
|
186 |
-
st.experimental_rerun() # Force Streamlit to rerun
|
187 |
|
188 |
if webrtc_ctx.audio_receiver:
|
189 |
st.write("Recording audio...")
|
190 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
191 |
audio_data = b"".join([frame for frame in audio_frames])
|
|
|
|
|
192 |
if st.button("Send Recording"):
|
193 |
send_message(audio_data=audio_data)
|
194 |
|
|
|
171 |
# --- WebRTC Audio Recording ---
|
172 |
RTC_CONFIGURATION = RTCConfiguration({"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]})
|
173 |
|
174 |
+
webrtc_ctx = webrtc_streamer(
|
175 |
+
key="audio-recorder",
|
176 |
+
mode=WebRtcMode.SENDONLY,
|
177 |
+
rtc_configuration=RTC_CONFIGURATION,
|
178 |
+
audio_receiver_size=256,
|
179 |
+
media_stream_constraints={"video": False, "audio": True},
|
180 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
if webrtc_ctx.audio_receiver:
|
183 |
st.write("Recording audio...")
|
184 |
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
|
185 |
audio_data = b"".join([frame for frame in audio_frames])
|
186 |
+
|
187 |
+
# Send the recorded audio when the "Send" button is clicked
|
188 |
if st.button("Send Recording"):
|
189 |
send_message(audio_data=audio_data)
|
190 |
|