The interview problem

Practice prompt

A voice assistant generates text and speech ahead of playback. Design barge-in so an interruption stops old audio and prevents late chunks from leaking into the next response.

Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.

1. Scope and assumptions

Assume separate text generation, synthesis, transport and device playback queues. Cancelling generation alone does not remove already buffered audio. Distinguish speech produced, delivered and actually played.

2. Architecture and decisions

Interrupt → advance response epoch → clear playback queue → cancel upstream → reject stale chunks → acknowledge stop

Tag every text segment and audio chunk with a response epoch and sequence number. On interruption, the client advances its accepted epoch and immediately stops queued playback using the platform’s supported controls. Send cancellation upstream to save work, but reject stale chunks locally even if the server cancellation races or fails.

Maintain a playback cursor for conversation state. If only the first sentence was heard, do not tell the model that the entire generated paragraph was communicated. Bound lookahead to trade smooth playback against cancellation waste. Use a short fade when supported to avoid abrupt waveform clicks, while still respecting the stop-latency target.

3. Work through the example

If the device has 40 ms of non-cancellable output already scheduled and event handling takes 15 ms, the earliest assumed stop is about 55 ms after detection, excluding detection delay itself. Clearing a separate 600 ms application queue prevents that additional queued speech from playing; it cannot retract sound already emitted.

4. Failure cases and trade-offs

An old chunk arriving after the queue is cleared can restart speech without epoch checks. Cancelling one utterance may not clear a platform-wide queue as intended. Very small buffers reduce interruption delay but increase underruns on jittery networks. Keep per-conversation ownership so stopping one session does not silence another.

5. Validation and acceptance

Inject interruption before the first chunk, during playback and just before completion. Delay old chunks until after a new response starts and verify they are discarded. Measure audible stop latency with loopback capture, not just cancellation acknowledgement time.

6. Follow-ups and self-review

How do you represent a half-spoken sentence in history? Reward end-to-end epoch fencing, playback-aware state and an honest device-buffer limit.

Sources and related practice

The Web Speech API specifies speech-synthesis cancellation; the distributed epoch protocol here is original.

Read the primary technical reference

Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.

Continue with Design a real-time voice assistant; Specify cancellation of partially executed batches.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.