From 09afc21283877091c1fca9d4c1510fce15d2a24c Mon Sep 17 00:00:00 2001 From: javis-bot Date: Sun, 14 Jun 2026 21:45:50 +0900 Subject: [PATCH] feat: split recording vs STT-processing time in turn logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log the captured speech-clip duration (녹음/음성) separately from the Whisper transcription time (STT처리) so it's clear whether a slow turn is the listening/recording or the transcription, per the user's request. --- bridge/server.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bridge/server.py b/bridge/server.py index 015cb47..634660b 100644 --- a/bridge/server.py +++ b/bridge/server.py @@ -459,14 +459,31 @@ def http_converse_stream(): # own Date.now() capture timestamps (same host, same clock). return int(time.time() * 1000) + # Length of the captured speech clip (16-bit mono PCM). This is the + # "음성 인식(녹음)" portion — how long the user actually spoke (+ the + # bot's trailing silence cutoff) — as opposed to "STT 처리", the Whisper + # transcription time below. Splitting them shows whether a slow turn is + # the listening/recording or the transcription. + try: + _frames, _sr = _read_wav_pcm(raw) + audio_sec = (len(_frames) / 2) / _sr if _sr else 0.0 + except Exception: + audio_sec = 0.0 + t0 = time.monotonic() stt = transcribe(raw) t_stt = time.monotonic() transcript = stt.get("text", "") if not transcript: + print( + f"[bridge] ⏱️ turn 녹음(음성)={audio_sec:.1f}s STT처리(whisper)={t_stt - t0:.1f}s " + f"→ 인식 결과 없음 ({stt.get('note', '빈 결과')})", + flush=True, + ) yield json.dumps({"type": "meta", "transcript": "", "language": stt.get("language"), "reply": "", "error": stt.get("error"), "note": stt.get("note", "빈 결과"), + "audio_sec": round(audio_sec, 1), "stt_sec": round(t_stt - t0, 1), "broadcast_action": None}) + "\n" yield json.dumps({"type": "end"}) + "\n" return @@ -482,6 +499,7 @@ def http_converse_stream(): "reply": reply, "error": result.get("error"), "note": "ok" if reply.strip() else "답변 없음", + "audio_sec": round(audio_sec, 1), "stt_sec": round(t_stt - t0, 1), "think_sec": round(t_think - t_stt, 1), # Wall-clock LLM window (epoch ms) for the transcript-channel timing @@ -516,8 +534,9 @@ def http_converse_stream(): "tts_end_ms": tts_end_ms, }) + "\n" print( - f"[bridge] ⏱️ turn stt={t_stt - t0:.1f}s think(LLM)={t_think - t_stt:.1f}s " - f"tts={tts_total:.1f}s total={time.monotonic() - t0:.1f}s replylen={len(reply)} " + f"[bridge] ⏱️ turn 녹음(음성)={audio_sec:.1f}s STT처리(whisper)={t_stt - t0:.1f}s " + f"think(LLM)={t_think - t_stt:.1f}s tts={tts_total:.1f}s " + f"total(STT~TTS)={time.monotonic() - t0:.1f}s replylen={len(reply)} " f"transcript={transcript[:40]!r}", flush=True, )