Workspace/Lesson workspace
Loading progress
Acting & collaborating40 min

Align audio, images, and actions on a shared timeline

Lesson 3 of 3
How to study this lesson

Read one section, trace the worked example, and try the knowledge check. Bookmark saves a shortcut; notes appear in My notebook. Mark lesson complete is your own assessment and does not mark its lab passed.

By the end, you can

  • Distinguish semantic alignment from temporal alignment.
  • Associate speech segments with observed screen frames.
  • Handle missing, late, or contradictory multimodal evidence.

A shared clock is a modeling choice

Multimodal agents often receive screenshots, audio chunks, transcripts, and interface events at different rates. The phrase click that one depends on what the user was seeing or pointing at when they spoke, not necessarily the latest frame available when transcription finishes. Store both event time and receive time. Event time locates the observation in the interaction; receive time tells you when the system could use it.

Semantic alignment asks whether two representations refer to related content. Temporal alignment asks whether they belong to the same moment or interval. Neither implies the other. A transcript can correctly recognize save the chart while being associated with the wrong window because it arrived late. Define the clock source, timestamp units, and synchronization assumptions before joining modalities. Milliseconds from separate devices are not automatically comparable without an offset or synchronization mechanism.

Transcription is evidence with uncertainty

Speech recognition transforms audio into text and sometimes timing information. Whisper studies robust speech recognition using large-scale weak supervision across varied audio conditions. [Whisper paper](https://arxiv.org/abs/2212.04356). A transcript is a model output, not a lossless copy of the speaker's intent. Noise, overlapping speakers, specialized names, and punctuation can affect interpretation. Keep the source interval and relevant confidence or quality signals if the recognizer exposes them.

Do not infer speaker authorization from voice content alone. A background recording may say send it, and an automatic transcript may omit a negation. When the requested action has a concrete consequence, bind it to the active user's intent and an explicit target. A voice interface should be able to ask for a narrowly scoped clarification while preserving the draft action and its evidence rather than forcing the user to restart the entire task.

Choose an alignment rule and inspect its errors

The simplest temporal join assigns each word interval to the nearest screen frame using the interval midpoint. Suppose frames occur at 0, 500, and 1000 milliseconds. A word spanning 420 to 620 has midpoint 520 and joins the 500 millisecond frame. If the maximum acceptable gap is 200 milliseconds, a word centered at 1500 remains unmatched. This rule is deterministic but may associate a future frame with earlier speech.

A causal agent cannot use a frame it has not received yet. For live decisions, you may instead choose the most recent available frame before the utterance, with a freshness bound. For offline analysis, nearest-frame alignment can be appropriate. State which interpretation you use. In either case, preserve unmatched segments; dropping them can falsely imply that every spoken reference had visual support.

Fuse intervals, not just isolated timestamps

A user may say move this above that over two seconds while dragging or pointing. One midpoint cannot represent every reference in the utterance. Keep audio intervals, pointer events, and screen revisions so a later stage can align noun phrases with the relevant interaction. If the screen changes midway through the utterance, split the interpretation or ask which state the user meant.

Consider a frame showing chart A at 1000 milliseconds and chart B at 1800. Speech from 900 to 1900 says export this chart. A naive midpoint at 1400 might choose A even though the user switched to B before completing the command. The temporal join supplies candidate evidence, not an automatic authorization to export. Use interaction context and explicit confirmation of the selected target when the reference remains ambiguous. More modalities can expose disagreement rather than resolve it.

Test alignment before deploying perception models

A useful fixture dataset includes delayed transcripts, missing frames, tied timestamps, out-of-order arrival, and a known clock offset. Label which frame or interval is acceptable for each command and which commands must remain unresolved. Measure alignment error and unsupported-action rate separately from transcription accuracy. A perfectly transcribed command can still drive the wrong action if it is joined to the wrong visual state.

The lesson code performs an offline nearest-frame join with a maximum gap and a deterministic earlier-frame tie break. It uses text records, not actual audio or images, so it isolates temporal reasoning from model quality. The lab extends this contract and the project turns aligned evidence into reviewable proposals. A production system needs real timestamps, media buffering, synchronization, and privacy-aware retention, but the underlying question remains precise: which observation supports this interpretation of the user's request?

Work through the code

This teaching simulation aligns transcript intervals to synthetic screen timestamps. It permits future frames because it is offline, breaks ties by earlier time and then ID, and preserves an unmatched word as None. It does not perform speech recognition or visual perception.

m16_lesson3.py
python
frames = [{'time': 0, 'id': 'f0'},
          {'time': 500, 'id': 'f1'},
          {'time': 1000, 'id': 'f2'}]
words = [{'start': 420, 'end': 620, 'text': 'this'},
         {'start': 1400, 'end': 1600, 'text': 'chart'}]

def align(word, available, max_gap):
    if not available:
        return None
    midpoint = (word['start'] + word['end']) / 2
    frame = min(available,
                key=lambda item: (abs(item['time'] - midpoint),
                                  item['time'], item['id']))
    gap = abs(frame['time'] - midpoint)
    return frame['id'] if gap <= max_gap else None

for word in words:
    frame_id = align(word, frames, 200)
    print(word['text'], '->', frame_id)
print('mode: offline nearest frame')
EXPECTED / ILLUSTRATIVE OUTPUT
this -> f1
chart -> None
mode: offline nearest frame

Run Python snippets locally with the prerequisites named above. The module coding lab runs directly in your browser.

Pause and reason

Frames are at 100 and 300 ms. A word spans 180 to 220 ms. With max_gap 100 and an earlier-frame tie break, which frame is selected? Would a live causal join necessarily agree?

Check your understanding

A transcript arrives three seconds late. Which timestamp should identify the screen state it refers to?

Your notes

Explain the mechanism in your own words. Add a failure you want to test.

Saved notes appear in your notebook

Go deeper with primary sources

Practice this module