Streaming Multimodal Interaction › A Worked Example: A Local Trace
Language AI HandbookAll chapters The trace uses integer milliseconds on a synthetic common clock. Turn 1 includes a pause, a revised transcript and a detected point toward Tuesday. Turn 2 begins while the assistant is still playing audio from generation 7. Event identifiers make it possible to pair the interruption with the correct audio and cancellation acknowledgment. In this fixture, the player invalidates generation 7 at the same recorded millisecond as interrupt detection. Separate events let the trace measure the player boundary even if a real controller invalidates later.
Setup and Event Schema
Some events use an input turn alone. Output and cancellation events carry the applicable generation ID. The first useful audio is annotated at the completion of the useful phrase. That event is part of the fixture, so the metric can be reproduced without a speech recognizer or subjective text heuristic.
PythonIn [3]Expand
from dataclasses import dataclass
from math import ceil
import numpy as np
@dataclass(frozen=True)
class Event:
t_ms: int
kind: str
channel: str
turn: int | None = None
generation: int | None = None
payload: int | str | None = None
def build_trace():
return [
Event(0, "capture_start", "control"),
Event(1000, "speech_onset", "input audio", 1),
Event(1510, "partial_transcript", "input text", 1, payload="Meet at"),
Event(1710, "pause_start", "input audio", 1),
Event(2110, "speech_resumes", "input audio", 1),
Event(
2160,
"point_detected",
"input video",
1,
payload="Tuesday on the calendar",
),
Event(2400, "speech_end_annotated", "input audio", 1),
Event(
2520,
"final_transcript",
"input text",
1,
payload="Meet there at three",
),
Event(2750, "endpoint_committed", "control", 1),
Event(2770, "prefill_started", "control", 1, 7),
Event(3060, "first_token", "output text", 1, 7, "Okay"),
Event(3130, "audio_started", "output audio", 1, 7),
Event(
3300,
"useful_audio_completed",
"output audio",
1,
7,
"Tuesday at three",
),
Event(3470, "speech_onset", "input audio", 2),
Event(3500, "interrupt_detected", "control", 2, 7),
Event(3500, "generation_invalidated", "playback control", 2, 7),
Event(3505, "cancel_requested", "control", 2, 7),
Event(3565, "cancel_ack", "control", 2, 7),
Event(3580, "queued_samples_discarded", "control", 2, 7, 2400),
Event(3610, "audio_stopped", "output audio", 2, 7),
]
trace = build_trace()ConsoleOut [4]Expand
0 ms | capture_start | control | turn None | generation None 1000 ms | speech_onset | input audio | turn 1 | generation None 1510 ms | partial_transcript | input text | turn 1 | generation None 1710 ms | pause_start | input audio | turn 1 | generation None 2110 ms | speech_resumes | input audio | turn 1 | generation None 2160 ms | point_detected | input video | turn 1 | generation None 2400 ms | speech_end_annotated | input audio | turn 1 | generation None 2520 ms | final_transcript | input text | turn 1 | generation None 2750 ms | endpoint_committed | control | turn 1 | generation None 2770 ms | prefill_started | control | turn 1 | generation 7 3060 ms | first_token | output text | turn 1 | generation 7 3130 ms | audio_started | output audio | turn 1 | generation 7 3300 ms | useful_audio_completed | output audio | turn 1 | generation 7 3470 ms | speech_onset | input audio | turn 2 | generation None 3500 ms | interrupt_detected | control | turn 2 | generation 7 3500 ms | generation_invalidated | playback control | turn 2 | generation 7 3505 ms | cancel_requested | control | turn 2 | generation 7 3565 ms | cancel_ack | control | turn 2 | generation 7 3580 ms | queued_samples_discarded | control | turn 2 | generation 7 3610 ms | audio_stopped | output audio | turn 2 | generation 7
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!