Imarticuslearning commited on
Commit
d54a028
·
verified ·
1 Parent(s): c0a1685

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -816,7 +816,13 @@ def get_ice_servers():
816
 
817
  return token.ice_servers
818
 
 
 
 
819
 
 
 
 
820
 
821
  # === Main QA Interface ===
822
  if st.session_state["generated_questions"]:
@@ -825,6 +831,7 @@ if st.session_state["generated_questions"]:
825
  question = st.session_state["generated_questions"][idx].lstrip("1234567890. ").strip()
826
 
827
  # Phase 0: Play audio first and wait 5s before countdown
 
828
  if not st.session_state.get("question_played"):
829
  st.session_state["question_audio_file"] = asyncio.run(generate_question_audio(question))
830
  st.session_state.update({
@@ -833,6 +840,14 @@ if st.session_state["generated_questions"]:
833
  "record_phase": "audio_playing",
834
  # "recorded_text": ""
835
  })
 
 
 
 
 
 
 
 
836
 
837
  st.markdown(f"**Q{idx + 1}:** {question}")
838
  st.audio(st.session_state["question_audio_file"], format="audio/mp3")
 
816
 
817
  return token.ice_servers
818
 
819
+ # Function to generate question audio (placeholder)
820
+ async def generate_question_audio(question):
821
+ return "question.mp3"
822
 
823
+ @st.cache_data(show_spinner=False)
824
+ def get_cached_question_audio(question_text):
825
+ return asyncio.run(generate_question_audio(question_text))
826
 
827
  # === Main QA Interface ===
828
  if st.session_state["generated_questions"]:
 
831
  question = st.session_state["generated_questions"][idx].lstrip("1234567890. ").strip()
832
 
833
  # Phase 0: Play audio first and wait 5s before countdown
834
+ """
835
  if not st.session_state.get("question_played"):
836
  st.session_state["question_audio_file"] = asyncio.run(generate_question_audio(question))
837
  st.session_state.update({
 
840
  "record_phase": "audio_playing",
841
  # "recorded_text": ""
842
  })
843
+ """
844
+ if not st.session_state.get("question_played"):
845
+ st.session_state["question_audio_file"] = get_cached_question_audio(question)
846
+ st.session_state.update({
847
+ "question_played": True,
848
+ "question_start_time": time.time(),
849
+ "record_phase": "audio_playing",
850
+ })
851
 
852
  st.markdown(f"**Q{idx + 1}:** {question}")
853
  st.audio(st.session_state["question_audio_file"], format="audio/mp3")