LoveLogicAI commited on
Commit
169fcab
·
verified ·
1 Parent(s): 4b260b9

Fix posture-check window: epoch timestamps captured at speech-end/answer-end

Browse files
Files changed (1) hide show
  1. tests/e2e_roleplay.py +5 -3
tests/e2e_roleplay.py CHANGED
@@ -281,7 +281,8 @@ async def conversation():
281
  np.copyto(np.frombuffer(frame.data, dtype=np.int16), piece)
282
  await source.capture_frame(frame)
283
  t_speech_end = time.perf_counter()
284
- print(f"[client] turn {i}: '{q_text}' pushed (abs {time.time():.3f})", flush=True)
 
285
 
286
  while audio_state["first"] is None:
287
  await asyncio.sleep(0.05)
@@ -297,6 +298,7 @@ async def conversation():
297
  if time.perf_counter() - t_speech_end > 90:
298
  break
299
  bot_pcm = np.concatenate(audio_state["chunks"])
 
300
  segs, _ = verifier.transcribe(bot_pcm.astype(np.float32) / 32768.0, language="en")
301
  text = " ".join(s.text.strip() for s in segs).strip()
302
  ok = any(k in text.lower() for k in keywords)
@@ -307,8 +309,8 @@ async def conversation():
307
  turns.append({"t_perceived": t_perceived, "text": text,
308
  "t_speech_end": t_speech_end,
309
  "t_end": audio_state["last"],
310
- "t_speech_end_abs": time.time(),
311
- "t_end_abs": time.time()})
312
  await asyncio.sleep(0.5)
313
 
314
  await room.disconnect()
 
281
  np.copyto(np.frombuffer(frame.data, dtype=np.int16), piece)
282
  await source.capture_frame(frame)
283
  t_speech_end = time.perf_counter()
284
+ t_speech_end_abs = time.time() # captured AT speech end, not at append
285
+ print(f"[client] turn {i}: '{q_text}' pushed (abs {t_speech_end_abs:.3f})", flush=True)
286
 
287
  while audio_state["first"] is None:
288
  await asyncio.sleep(0.05)
 
298
  if time.perf_counter() - t_speech_end > 90:
299
  break
300
  bot_pcm = np.concatenate(audio_state["chunks"])
301
+ t_end_abs = time.time() # end of the answer (silence wait included)
302
  segs, _ = verifier.transcribe(bot_pcm.astype(np.float32) / 32768.0, language="en")
303
  text = " ".join(s.text.strip() for s in segs).strip()
304
  ok = any(k in text.lower() for k in keywords)
 
309
  turns.append({"t_perceived": t_perceived, "text": text,
310
  "t_speech_end": t_speech_end,
311
  "t_end": audio_state["last"],
312
+ "t_speech_end_abs": t_speech_end_abs,
313
+ "t_end_abs": t_end_abs})
314
  await asyncio.sleep(0.5)
315
 
316
  await room.disconnect()