Imarticuslearning commited on
Commit
d152d8d
·
verified ·
1 Parent(s): 63a69f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -868,13 +868,18 @@ if st.session_state["generated_questions"]:
868
  remaining = 15 - int(now - st.session_state.get("timer_start", 0))
869
  if remaining > 0:
870
  st.markdown(f"<h4 class='timer-text'>🎙️ {remaining} seconds to answer...</h4>", unsafe_allow_html=True)
871
- webrtc_ctx = webrtc_streamer(
872
- key = f"webrtc_{idx}",
873
- mode=WebRtcMode.SENDONLY,
874
- audio_receiver_size=1024,
875
- media_stream_constraints={"audio": True, "video": False},
876
- rtc_configuration={"iceServers": get_ice_servers()},
877
- )
 
 
 
 
 
878
 
879
  if webrtc_ctx.state.playing:
880
  if st.button("⏹️ Stop Recording"):
 
868
  remaining = 15 - int(now - st.session_state.get("timer_start", 0))
869
  if remaining > 0:
870
  st.markdown(f"<h4 class='timer-text'>🎙️ {remaining} seconds to answer...</h4>", unsafe_allow_html=True)
871
+
872
+ audio_bytes = st.audio_input("🎙️ Record your answer (tap when done)", key=f"audio_{idx}")
873
+
874
+ if audio_bytes:
875
+ wav_path = f"response_{idx}.wav"
876
+ with open(wav_path, "wb") as f:
877
+ f.write(audio_bytes.getbuffer())
878
+ st.audio(wav_path)
879
+ st.session_state["answers"].append({
880
+ "question": question,
881
+ "response_file": wav_path
882
+ })
883
 
884
  if webrtc_ctx.state.playing:
885
  if st.button("⏹️ Stop Recording"):