advanced29 min studyLesson 809 in Engineering

Interruption stops owned output while echo control follows what was actually rendered

Track generation identifiers, queued and device-resident audio, and aligned render references without confusing cancellation with already played sound or echo suppression with speech preservation.

On this page

What you’ll understand

  • Define stale-output rejection and safe cancellation ownership across synthesis and playback.
  • Calculate queued audio duration and a stated unflushable device tail.
  • Explain render-reference alignment, double talk, and limits of echo-reduction proxies.

A conversational system must notice when the user speaks over its reply, stop the old output, and avoid recognizing its own speaker as the new user. Those are connected but different jobs. Cancellation changes ownership of future work; it cannot erase sound already emitted or necessarily flush every hardware buffer. Echo control uses an aligned reference to the actual rendered waveform, including any old tail that remains audible. A correct design follows these timelines explicitly rather than treating a server-side canceled flag as proof that the room has gone silent.

Tag output ownership through every asynchronous stage

Associate synthesis work and audio chunks with a session and generation identifier. When an interruption commits, retire the old generation and prevent its late results from entering the active playback queue. Propagate cancellation to upstream generation, synthesis, transport, and client buffers where supported, while still rejecting stale chunks that arrive after the signal. A producer can finish an already launched task after cancellation; that outcome is safe only if downstream ownership checks prevent its obsolete audio from being played. Handle resources and acknowledgments without double release.

Separate application-queued samples from samples already handed to an output device. The application can often discard its queue immediately, while device or operating-system buffering may need a separate stop or flush operation. Some sound is already physical and cannot be undone. Measure interruption-detection time, cancellation propagation, and final audible tail on the actual platform. Keep current-generation ordering and sample coverage valid after a restart so the new response does not inherit a stale index or accidentally mix with the old one.

accept⁡(c)  ⟺  gc=gactive,ttail=Ndfs\operatorname{accept}(c)\iff g_c=g_{\rm active},\qquad t_{\rm tail}=\frac{N_d}{f_s}
The simplified acceptance rule assumes the session and authorization are already validated and g is the output generation identifier. The tail formula assumes N_d already queued device sample frames cannot be flushed and play at f_s frames/second with no new additions. Actual devices may support different stop behavior; detection and propagation delays are separate.↔ Scroll wide equations horizontally.

The echo reference represents rendered audio on the capture timeline

A microphone can contain desired near-end speech, acoustic reflections of the system's output, and noise. An echo canceller estimates the render-to-capture path using an appropriately aligned reference, not merely the text that the synthesizer intended to say. Account for gain, resampling, channel mixing, device buffering, and acoustic delay. An output chunk discarded before playback should not be treated as if it was rendered, while an old device tail may still need a reference after logical cancellation. Separate capture and render clocks can drift and require compatible alignment handling.

The pinned WebRTC audio-processing interface illustrates distinct reverse/render and capture processing and explicit delay and drift concerns. That historical interface is a concrete contract, not a promise that every modern wrapper exposes the same calls. Double talk means desired speech and echo occur together; overly aggressive suppression can reduce echo while damaging the user. Nonlinear speakers, clipping, changing acoustic paths, and incorrect delay can also leave residuals. Evaluate near-end speech preservation and actual interruption success alongside echo metrics rather than maximizing suppression alone.

m[n]=s[n]+∑kh[k]r[n−d−k]+v[n],e[n]=m[n]−a^[n]m[n]=s[n]+\sum_k h[k]r[n-d-k]+v[n],\qquad e[n]=m[n]-\widehat a[n]
This illustrative linear acoustic model has microphone m, desired speech s, rendered reference r, path h, integer delay d in samples, noise v, and estimated echo a-hat; all signal terms use compatible amplitude units. Residual e is not guaranteed to equal clean speech when the path is nonlinear, misaligned, or estimated incorrectly.↔ Scroll wide equations horizontally.

Measure interruption as an end-to-end interaction

Replay tests with quiet users, overlapping syllables, room changes, headsets and speakers, different volumes, and late stale chunks. Label which waveform was actually rendered and when the user's interruption began. Report false interruptions, missed interruptions, audible stop latency, clipped user speech, and recognition outcomes. A low residual-energy score can result from suppressing both echo and desired speech, so it is not a sufficient quality guarantee. Test reconnects and generation-ID reuse as well as the ordinary case, because stale ownership bugs often appear only after delayed completion.

The waves lab illustrates an ideal cancellation mismatch. Reset, explicitly set BOTH phase=180 degrees and ratio=1, predict resultant amplitude zero, then Play or Step. Reset and re-set BOTH phase=180 degrees and ratio=0.8; predict residual amplitude 0.2. Edits retain t. These are equal-frequency analytic signals, not an adaptive echo canceller, microphone recording, or double-talk detector. The example shows that matching a reference's phase and level matters while leaving the actual room response, clocks, nonlinearities, and speech-preservation tests outside the toy model.

Cancel queued audio without losing the rendered echo reference

At sixteen kilohertz, a client has 640 sample frames in a discardable application queue and 160 in an unflushable device queue. Assume no new accepted old audio after cancellation. An illustrative render-to-capture echo delay is 480 samples. The active output generation changes from 42 to 43.

  1. The application queue represents 640/16000=40 milliseconds and the device queue 160/16000=10 milliseconds. Without discarding the application queue, their serial remaining audio would total 50 milliseconds under this model.

  2. Discard the 640 application frames and reject late generation 42 chunks. The unflushable device tail still lasts 10 milliseconds, and its actually rendered samples remain relevant to the echo reference rather than disappearing with the logical generation flag.

  3. The stated echo delay is 480/16000=30 milliseconds. Align that reference on the capture timeline while generation 43 takes ownership of new output; cancellation timing and reference alignment are distinct from the duration of the remaining tail.

The result

Correct interruption combines stale-result rejection, platform-aware playback stopping, and a reference to sound that really reached the speaker.

Explore the model

Interactive lab

Interactive lab · waves

An imperfect reference leaves a residual even in an ideal tone model

For EACH run Reset, set BOTH phase and ratio, predict, then Play or Step. At phase 180 degrees, ratio 1 gives amplitude 0 and ratio 0.8 gives 0.2. Edits retain t. This analytic superposition has no microphone, adaptive filter, acoustic path, output queue, generation ownership, or double-talk handling.

An imperfect reference leaves a residual even in an ideal tone modelTwo waves share the same frequency and wave number. Playback advances t in sin(2x − t) + a sin(2x − t + phase). Current readings: Sum at x = 0: 0.866; Resultant amplitude: 1.732; Phase difference: 60°. All parameters are adjustable with the labeled controls below.−3.14−1.5701.573.14−3.4−1.701.73.4x · radiansAmplitude
SumFirst componentSecond component
Sum at x = 0
0.866
Resultant amplitude
1.732
Phase difference
60°
t = 0 s

Two waves share the same frequency and wave number. Playback advances t in sin(2x − t) + a sin(2x − t + phase). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forEcho reference quality and output cancellation require real timing and speech-preservation tests beyond ideal waveform cancellation.

Check your understanding

The server marks a reply canceled, but an old synthesis task completes and sends audio afterward. What prevents that stale audio from resuming playback?

Try it yourself

A twenty-four-kilohertz device has 240 unflushable sample frames left after the application queue is purged. Calculate the ideal remaining tail. If stale generation 7 audio arrives after generation 8 is active, should it enter playback or the rendered-reference timeline?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

A reference should describe audio actually rendered, not every produced or received chunk.

Compare with the solution

The remaining tail is 240/24000=0.01 seconds, or ten milliseconds, under the unflushable fixed-rate assumption. Generation 7 audio should be rejected from playback. If it is not rendered, it must not be added as though it had reached the speaker; the real existing tail still needs its correctly aligned reference.

Take it with you

  • Cancellation and generation ownership prevent late obsolete results from reaching playback.
  • Application queues, device queues, and already emitted sound have different stopping behavior.
  • Echo reduction needs an aligned rendered reference and evaluation of desired-speech preservation.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.