feat: show per-stage timing (듣기/LLM/TTS) in the transcript channel
The transcript channel only showed STT and LLM seconds. Add wall-clock start/end times and durations for listening, LLM and TTS so it's obvious what takes long; STT surfaces as the gap between listening end and LLM start. - bridge: emit llm_start_ms/llm_end_ms on meta and tts_*_ms on the end event - bot: capture the listening window, assemble full timing after the stream, and render a per-stage breakdown in the transcript message Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -33,10 +33,12 @@ test("converseStream surfaces meta first, then plays each sentence clip in order
|
||||
transcript: "안녕",
|
||||
reply: "안녕하세요. 반갑습니다!",
|
||||
broadcast_action: "start",
|
||||
llm_start_ms: 1000,
|
||||
llm_end_ms: 2600,
|
||||
}),
|
||||
JSON.stringify({ type: "audio", seq: 0, audio_b64: clipA.toString("base64") }),
|
||||
JSON.stringify({ type: "audio", seq: 1, audio_b64: clipB.toString("base64") }),
|
||||
JSON.stringify({ type: "end" }),
|
||||
JSON.stringify({ type: "end", tts_sec: 0.9, tts_start_ms: 2600, tts_end_ms: 3500 }),
|
||||
].join("\n") + "\n";
|
||||
|
||||
const orig = globalThis.fetch;
|
||||
@@ -50,6 +52,7 @@ test("converseStream surfaces meta first, then plays each sentence clip in order
|
||||
const events: string[] = [];
|
||||
const clips: Buffer[] = [];
|
||||
let meta: any;
|
||||
let end: any;
|
||||
await converseStream(Buffer.from("wav"), true, {
|
||||
onMeta: (m) => {
|
||||
meta = m;
|
||||
@@ -59,13 +62,23 @@ test("converseStream surfaces meta first, then plays each sentence clip in order
|
||||
clips.push(c);
|
||||
events.push("audio");
|
||||
},
|
||||
onEnd: (e) => {
|
||||
end = e;
|
||||
events.push("end");
|
||||
},
|
||||
});
|
||||
|
||||
expect(meta.transcript).toBe("안녕");
|
||||
expect(meta.broadcast_action).toBe("start");
|
||||
// Meta must arrive before any audio, and clips must stay in order.
|
||||
expect(events).toEqual(["meta", "audio", "audio"]);
|
||||
// LLM wall-clock window rides on the meta line.
|
||||
expect(meta.llm_start_ms).toBe(1000);
|
||||
expect(meta.llm_end_ms).toBe(2600);
|
||||
// Meta must arrive before any audio, the end (with TTS timing) comes last,
|
||||
// and clips stay in order.
|
||||
expect(events).toEqual(["meta", "audio", "audio", "end"]);
|
||||
expect(clips.map((c) => c.toString())).toEqual(["clipA", "clipB"]);
|
||||
expect(end.tts_start_ms).toBe(2600);
|
||||
expect(end.tts_end_ms).toBe(3500);
|
||||
} finally {
|
||||
globalThis.fetch = orig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user