Streaming Speech

A batch voice agent cannot start until you stop talking. A streaming stack works while you talk, and a frame-level model like Moshi answers in 200 ms, under the 230 ms gap people leave in conversation.

Pick a system and drag the sentence length. Watch the silence after your last word. Then we build each piece: the causal encoder, the chunk mask, the decoder that commits, the stable prefix, the early synthesizer and the ledger.

You need a spectrogram is sound as a picture and attention means each output looks at some inputs. We build the rest from zero. Background: Audio Representations and Whisper.

Published numbers come from the papers named beside them: Moshi (Défossez et al., 2024), Qwen2.5-Omni (2025), Emformer (Shi et al., 2020) and Whisper-Streaming (Macháček et al., 2023). Every other number on this page is an illustrative toy and says so.

Hear the gap after your last word

4.2 s

The 200 ms frame-level gap is Moshi's measured latency and 230 ms is the human average it cites (Stivers et al., 2009). The batch and cascade stage times are an illustrative model built in Chapters 5 and 6.

Chapter 0

The Model That Waits

See why an offline speech model cannot start early, and what the obvious fix costs

You call an airline and say: "I'd like to move my flight to Tuesday morning." That takes about 4.2 seconds. Then you stop and wait.

An offline recognizer did nothing during those 4.2 seconds. Its first layer looks at the whole clip at once, so it cannot run until the clip ends. A streaming model emits text for the audio it has heard, and it never needs audio from far ahead to do so.

The obvious fix: re-run the batch model

Keep the offline model. Re-run it on everything said so far, every 200 ms. The front end makes one frame (a 10 ms slice of audio features) every 10 ms. So 4.2 seconds is 420 frames and 21 runs. Self-attention compares every frame with every other frame, so one pass over T frames costs about T squared units of work.

Call the frames added between two runs f and the number of runs K. Run number k sees f times k frames.

Say it aloud

W equals the sum over k from 1 to K of f times k, squared.

W
W the total attention work of the re-run loop, in units of one frame-pair comparison.
Σk=1..K
the sum over k from 1 to K add one term for each run.
f
f the frames added between runs: 200 ms over a 10 ms hop is 20.
k
k the run number. Run k sees f times k frames.
2
squared one attention pass over n frames compares n by n pairs.
In plain words

Run k sees f times k frames and pays that number squared. Add the cost of all K runs. Compare W with one pass over the whole clip.

With numbers

With f = 20 and K = 21: W = 400 × (1 + 4 + … + 441) = 400 × 3,311 = 1,324,400. One pass over 420 frames costs 420 × 420 = 176,400. The loop does 7.5 times the work.

Price the re-run loop

Each pink bar is one re-run; it grows because each run sees more audio. Shorten the interval or lengthen the sentence and watch the ratio.

200 ms
4.2 s

A cost model that counts only attention pairs. Real encoders also pay per-frame costs, which make the ratio smaller but keep it above 1.

The loop also flickers. Each re-run is a fresh pass that sees the latest audio, so "move" can become "prove" and back again. Streaming needs a different architecture, not a loop. It rests on three properties:

  1. Bounded lookahead. Output at time t uses input up to t + Δ only, for a small fixed Δ.
  2. Reuse. The work for each frame is done once.
  3. Stable output. Words already shown stay put.

Δ is the algorithmic latency, also called the lookahead: how far into the future the model waits before it commits.

Symptom: server load climbs with call length, and captions twitch.

Measure: log encoder work per second of audio against call duration. It should stay flat.

Fix: a causal, chunked encoder with a cache (Chapters 1 and 2).

The road

  1. Causality: which inputs each output may read, and the cache it allows.
  2. Chunked attention: the mask, built by hand, turned into milliseconds.
  3. Decoders that commit: CTC and the transducer.
  4. Flicker: the stable prefix and LocalAgreement.
  5. Incremental TTS: speak early without a hole in the audio.
  6. The ledger: every knob on one turn gap. The hero's cascade bar comes from here.
  7. Frame-level streaming: Moshi's 80 ms audio tokens. The hero's 200 ms bar.
  8. Quality against latency: what lookahead buys.
  9. Field guide: terms, numbers, code and links.
Why is re-running an offline model every 200 ms a poor way to stream?

Chapter 1

Causality: Where the Future Leaks In

Find every part of an encoder that reads ahead, and make the reuse of past work possible

An encoder maps input frames x0 to xT into output states h0 to hT. Which inputs may ht read? That set is the receptive field. Its right edge is your latency.

Encoderht readsWait before ht
Bidirectionalframes 0 to Tuntil the clip ends
Causalframes 0 to tzero
Chunkedup to its chunk's end, plus L framesa few frames

Slide the query and watch the right edge

Each row is one encoder. Teal cells are inputs the query may read; warm cells are future frames it must wait for. Pick an encoder and slide the query frame.

5

Twelve frames at a 10 ms hop, a toy clip. The chunked row uses chunks of 4 frames and 1 frame of lookahead.

Convolutions read ahead too

Speech encoders start with convolution layers. Whisper's stem has two of width 3. The second has a stride of 2: it steps two input frames per output. A width-3 kernel centred on frame t reads t + 1, so with symmetric padding each layer leaks one step of the future.

Call the kernel width of layer i ki and its stride si. The receptive field in input frames is R.

Say it aloud

R equals 1 plus the sum over layers i of k-i minus 1, times the product of s-j over the layers j below i.

R
R how many input frames one output frame sees.
Σi
the sum over i add one term per layer, from the bottom up.
ki
k-i the kernel width of layer i, here 3.
Πj<i sj
the product of s-j for j below i how many input frames one step of layer i spans. It is 1 below any stride.
In plain words

Each layer widens the view by k-i minus 1 of its own steps. Turn those steps into input frames by multiplying the strides below it. With symmetric padding, half of R minus 1 lies in the future.

With numbers

Five layers of width 3, all stride 1: R = 1 + 5 × 2 = 11. That is 5 future frames, 50 ms. Now give layer 2 a stride of 2. Layers 3 to 5 each add 2 × 2 = 4. R = 1 + 2 + 2 + 4 + 4 + 4 = 17, so 8 future frames, 80 ms.

The fix is causal padding: pad k − 1 zeros on the left and none on the right. Output t then reads t − 2, t − 1 and t. The view keeps its size; it now ends at the present.

pythonimport torch, torch.nn.functional as F
x = torch.tensor([[[1., 2., 3., 4., 5.]]])       # (batch 1, channel 1, T 5)
w = torch.ones(1, 1, 3)                          # a width-3 moving sum
F.conv1d(F.pad(x, (1, 1)), w)   # [3, 6, 9, 12, 9]  output t reads t+1: future
F.conv1d(F.pad(x, (2, 0)), w)   # [1, 3, 6, 9, 12]  output t reads t-2..t: causal

Causality makes a cache possible

In a causal model, frame 5's key and value vectors never change after frame 5 arrives. So the encoder stores them in a KV cache, and frame t compares one new query with t stored keys. Over 420 frames that is 1 + 2 + … + 420 = 88,410 comparisons. Recomputing the prefix at every frame costs about 12.4 million, 141 times more.

Symptom: the transcript still appears only when the caller stops.

Measure: run the model on frames 0 to t, then on 0 to T. The first t + 1 outputs must match exactly.

Fix: find the part that reads ahead (a symmetric convolution, a normalization over the whole clip, a bidirectional LSTM) and make it causal.

A stem of five width-3 convolutions, stride 1, uses symmetric padding. How much future audio must exist before output frame t can run, at a 10 ms hop?

Chapter 2

Chunked Attention, Worked by Hand

Build the mask cell by cell, count what it keeps, and turn it into milliseconds

Causal attention gives up all of the future. Bidirectional attention waits for all of it. Chunked attention sits between them. Cut the frames into chunks of C frames. A query in chunk c may read every earlier frame, its own chunk, and L more frames past the chunk end.

So the right edge of chunk c is frame C × (c + 1) − 1 + L. Every frame in a chunk shares that edge, so the encoder runs the whole chunk as one batch. With C = 4, L = 1 and 12 frames, the edges are frames 4, 8 and 11 (12 clips to the last frame).

Mask on 12 framesAllowed pairsShare of full
Bidirectional12 × 12 = 144100%
Chunked, C 4, L 14 × 5 + 4 × 9 + 4 × 12 = 10472%
Causal1 + 2 + … + 12 = 7854%

Build the mask

Rows are queries, columns are keys. Teal cells are history and the query's own chunk; warm cells are the lookahead. Set C = 4 and L = 1 to match the table.

4
1

A toy 12-frame clip at a 10 ms hop. The waits count frames only; compute time comes on top.

Now the cost in time. Call the frame hop h. The first frame of a chunk waits longest, so the worst-case wait is Dmax.

Say it aloud

D-max equals C plus L minus 1, times h.

Dmax
D-max the longest any frame waits for its output: the worst-case algorithmic latency.
C
C the chunk size, in frames.
L
L the lookahead past the chunk end, in frames.
h
h the frame hop, 10 ms here.
In plain words

The first frame of a chunk waits for the other C minus 1 frames of its chunk, then for L lookahead frames. Multiply that count by the hop h. The last frame of a chunk waits only L frames.

With numbers

Take C = 4, L = 1 and h = 10 ms. Then Dmax = 4 × 10 = 40 ms. In chunk 0 the waits are 4, 3, 2 and 1 frames, an average of 2.5 frames, 25 ms.

What does the mask take away? Take query frame 3 with scores 0.2, 1.0, 2.0, 1.4, 0.6 and 1.8 against keys 0 to 5. The softmax spreads weight over the keys the mask allows.

MaskWeight on key 2Weight on keys after 3
Causal (keys 0 to 3)0.4800
Chunked, L 1 (keys 0 to 4)0.4290.106
Full (keys 0 to 5)0.3180.338

A third of this head's attention pointed at the future. The causal model never gets it. Emformer (Shi et al., 2020) is a chunked encoder for streaming recognition. It caches the keys and values of the left context, so no chunk recomputes them.

Symptom: you trained with a chunk mask and latency did not drop.

Measure: log the time each chunk enters the encoder.

Fix: serve chunk by chunk with the cache. A masked model fed the whole file is still a batch system.

With C = 4 and L = 1 at a 10 ms hop, what is the worst-case wait, and which frame has it?

Chapter 3

Decoders That Can Commit: CTC and the Transducer

Turn encoder frames into text with an alignment that only moves forward

The encoder makes vectors. The decoder makes text. An attention decoder, the kind Whisper uses, picks each next token by attending to any encoder frame. Nothing forces it forward in time, so it must wait for every frame.

CTC (Connectionist Temporal Classification, Graves et al., 2006) emits one symbol per frame. The symbols are the letters plus a blank, written _, which means "nothing new here". Two rules turn a frame string into text, in this order:

  1. Merge adjacent repeats: C C becomes C.
  2. Delete every blank.

The order matters. "T _ T" keeps two T's, so CTC can spell "butter". Because each output belongs to one frame, CTC is monotonic: the text only moves forward with the audio. A frame's symbol can be committed the moment the frame arrives.

Decode CAT frame by frame

Columns are frames, rows are symbols, brightness is probability. The outlined cell wins each frame. Reveal frames one at a time, then push the blank bias.

8
1.0

The eight probability columns are a made-up example. The bias multiplies the blank's probability before each frame picks its winner.

Greedy decoding gives _ C C _ A _ T T. Merge repeats: _ C _ A _ T. Drop blanks: CAT. How likely is that one path? Call the probability the model gives symbol at at frame t pt(at), and the whole frame string a.

Say it aloud

P of a equals the product over t from 1 to T of p-t of a-t.

P(a)
P of a the probability of one whole frame string a.
Πt=1..T
the product over t from 1 to T multiply one factor per frame; here T = 8.
pt(at)
p-t of a-t the probability the model gives the chosen symbol a-t at frame t.
In plain words

Pick one symbol per frame. Multiply the T chosen probabilities. That is the chance of this path; the chance of the word is the sum over every path that collapses to it.

With numbers

0.70 × 0.70 × 0.60 × 0.80 × 0.75 × 0.60 × 0.80 × 0.55 = 0.047. The CTC forward pass sums every path that collapses to CAT and gets 0.334, so the best path holds 14% of the word's probability.

CTC has no sense of which words follow which. The transducer (RNN-T, Graves, 2012) adds a small prediction network over the text so far. Its blank means "done with this frame, move on", so it can emit several symbols in one frame.

DecoderAlignmentKnows word orderStreams
CTCforward onlynoyes
Transducerforward onlyyes, prediction networkyes
Attention decoderfreeyesonly with extra machinery

Symptom: the transcript drops letters, or adds stray ones.

Measure: count deletions and insertions against a reference.

Fix: tune the blank bias. Too high swallows letters; too low invents them.

Why can a CTC decoder on a causal encoder commit each symbol at once?

Chapter 4

Flicker and the Stable Prefix

Split the transcript into a promise and a guess, and price the promise

Watch live captions: "I'd like to prove" turns into "I'd like to move my". That change is flicker: the model changed its mind because more audio arrived. On a screen it is harmless. For an agent it is a bug, because the agent reasons about words nobody said. For a speech synthesizer it is worse: spoken audio cannot be taken back.

So a streaming recognizer returns two strings. The volatile part is the current guess, fine to show in grey. The stable prefix is a promise that these words never change. Only the stable prefix goes to the agent and the synthesizer.

LocalAgreement

LocalAgreement-n promotes a word to stable when the last n hypotheses agree on it. Whisper-Streaming (Macháček et al., 2023) wraps the offline Whisper with this policy and reports 3.3 seconds of latency on long-form speech. Here it is with n = 2 and an update every 200 ms:

TimeHypothesisAgreed with the last oneNew stable words
0.2 si'd like tonone yetnone
0.4 si'd like to provei'd like toi'd like to
0.6 si'd like to move myi'd like tonone
0.8 si'd like to move my flighti'd like to move mymove my
1.0 si'd like to move my flight toi'd like to move my flightflight

"Prove" never became stable, so nothing was retracted. The model changed its mind inside the volatile zone.

Damp the flicker

Blue words are stable, yellow words are volatile, red words are ones the system showed and then took back. Change n and the update interval.

200 ms

The five hypotheses are a scripted example, the same as the table.

Call the agreement count n and the update interval u. The extra wait before a word turns stable is d.

Say it aloud

d equals n minus 1, times u.

d
d the emission delay: time from a word's first sighting to its promotion.
n
n how many updates in a row must agree.
u
u the time between two hypothesis updates.
In plain words

A word must appear in n updates in a row. Its first sighting costs nothing extra; each of the other n minus 1 sightings costs one interval u.

With numbers

With n = 2 and u = 200 ms, d = 200 ms. With n = 3, d = 400 ms. Keep n = 2 and update every 100 ms: d = 100 ms, for twice the decoder runs.

Emitting every word at once retracts "prove": 1 retraction in 7 words, a flicker rate of 14%. LocalAgreement-2 retracts nothing and pays 200 ms per word.

Symptom: a misheard name becomes stable and the agent acts on it.

Measure: the error rate of the stable text alone.

Fix: agreement guards against a model that hesitates, not one that is sure and wrong. Pass confidence or a list of alternatives to the agent.

LocalAgreement-2 removed every retraction in the example. What did it cost?

Chapter 5

Incremental TTS: Speak Before the Sentence Ends

Cut the reply into chunks, make the first one small, and never let the audio run dry

The reply arrives as tokens. Say it has 20 words and the language model writes 10 words per second: the last word lands 1.9 seconds after the first. A synthesizer that waits for the full sentence throws that time away.

Incremental TTS cuts the text into chunks and synthesizes each chunk when it closes. The real-time factor (RTF) is compute seconds per second of audio, so 0.3 means one second of speech takes 0.3 seconds to make. With made-up numbers: 2.5 words per second of speech (one word is 0.4 s), RTF 0.3, and 60 ms of fixed cost per call.

First chunkAudioTime to first audio
3 words1.2 s60 + 0.3 × 1,200 = 420 ms
8 words3.2 s60 + 960 = 1,020 ms
20 words, whole sentence8.0 s60 + 2,400 = 2,460 ms

Never let the buffer run dry

Once playback starts, audio drains at real time. If chunk k is not ready when chunk k − 1 ends, the listener hears a buffer underrun: a hole in the middle of the reply. Call the audio length of chunk k Ak, the fixed cost per call o and the real-time factor r.

Say it aloud

o plus r times A-k is at most A-k-minus-1.

o
o the fixed cost of one synthesis call, 60 ms here.
r
r the real-time factor: compute seconds per audio second.
Ak
A-k the audio length of chunk k, the one being made.
≤
is at most the left side must not be longer than the right side.
Ak−1
A-k-minus-1 the audio length of the chunk now playing.
In plain words

Making chunk k takes o plus r times A-k. That must fit inside the playing time A-k-minus-1 of the chunk before it. Slack saved by earlier chunks adds room.

With numbers

Chunks of 3, 8 and 16 words: A = 1.2, 3.2 and 6.4 s. With r = 0.3: 0.06 + 0.96 = 1.02 ≤ 1.2, safe by 0.18 s. With r = 0.9: 0.06 + 2.88 = 2.94 > 1.2, a 1.74 s hole, though r is below 1.

Race synthesis against playback

Pink bars are synthesis, purple bars are playback, red gaps are holes. Shrink the first chunk to start sooner; raise RTF to see the race fail.

3 words
0.30

Illustrative timing model: chunks of the first size, then 8 and 16 words, made back to back. Real RTF varies from call to call.

Seams can also be heard. A chunk made alone gets its own falling pitch, so the reply sounds like a list. Cut at clause boundaries, and give the synthesizer the previous text as context without speaking it again. Qwen2.5-Omni's speech decoder sees 2 blocks back and 1 block ahead of the block it renders.

Symptom: the reply stutters about a second in.

Measure: per chunk, log when synthesis ends and when playback of the previous chunk ends. Check the margin at the slow tail of RTF, not the median.

Fix: grow chunk sizes only as fast as the margin allows.

The synthesizer runs at RTF 0.9, yet the audio stutters after the first chunk of 3 words. Why?

Chapter 6

The Latency Ledger

Put every knob on one turn gap and find which ones move it

Every chapter so far gave you a knob. Here they meet in one number: the turn gap, from your last syllable to the first sound of the reply.

After you stop, two clocks start together. The endpoint hold is the silence timer that decides you are done. The recognizer's tail is the last chunk's wait, its compute and its stability delay. The reply waits for the later of the two. Call the hold E, the chunk wait Wc, the compute K and the stability delay d.

Say it aloud

T-asr equals the max of E, and W-c plus K plus d.

Tasr
T-asr the time from your silence until a final transcript exists.
max
the max of the larger of the two; the faster clock costs nothing.
E
E the endpoint hold, in ms.
Wc
W-c the chunk wait, (C + L − 1) times the hop, from Chapter 2.
K
K the encoder and decoder compute for the last chunk.
d
d the stability delay from Chapter 4.
In plain words

Start both clocks at your silence. Add W-c, K and d for the recognizer. Take whichever of E and that sum is larger.

With numbers

With made-up defaults: E = 250, Wc = (14 + 2 − 1) × 10 = 150, K = 60, d = 1 × 140 = 140. The recognizer needs 350 ms, so Tasr = max(250, 350) = 350 ms.

The rest is a plain sum, because each stage needs the one before it. Uplink 95, recognizer 350, three service hops 30, first token 375, first audio 180, downlink 95. Total: 1,125 ms.

Tune the turn gap

The top bar is the turn gap, stage by stage. The two thin bars below race: the hatched one lost and costs nothing. Drag any slider.

14
2
2
250 ms
375 ms
1 word

Every stage time here is an illustrative model. It uses 10 ms frames and 60 ms of recognizer compute. Stability delay is (n − 1) × C × 10 ms; first audio is 60 + 120 ms per word. The 230 ms human gap and Moshi's 200 ms are published.

  1. Drag the chunk from 14 down to 4. The total falls only to 1,025 ms, because the endpoint hold becomes the larger clock.
  2. Raise the first TTS chunk from 1 to 12 words. The total grows by 1,320 ms and no model changed.
  3. Set n = 3 and a chunk of 30. The recognizer needs 970 ms and the total reaches 1,745 ms.

Symptom: you made the recognizer twice as fast and users noticed nothing.

Measure: log both clocks on every turn, and look at the slow tail (the 95th percentile), not the median.

Fix: work on the clock that finishes later, and on the serial stages after it.

The endpoint hold is 500 ms and the recognizer tail is 200 ms. You halve the encoder's compute. What happens to the turn gap?

Chapter 7

Frame-Level Streaming: Audio as Tokens

Delete the pipeline, turn sound into 80 ms tokens, and count the delay in frames

A cascade waits at every seam. The other route makes audio itself the token stream, so one model listens and speaks in the same step. Moshi (Défossez et al., 2024) takes this route.

A neural audio codec turns a waveform into a few discrete tokens per second, and back. Moshi's codec, Mimi, sends 24 kHz audio through causal convolutions with strides 4, 5, 6 and 8, then one more of stride 2. Each frame gets 8 tokens from 8 codebooks of 2,048 entries.

QuantityArithmeticResult
Downsampling4 × 5 × 6 × 8 × 21,920
Frame rate24,000 / 1,92012.5 per second
Frame length1 / 12.580 ms
Bitrate12.5 × 8 codebooks × 11 bits1.1 kbps

Mimi distills WavLM, a self-supervised speech model, into its first codebook, so that codebook carries what was said. WavLM reads ahead, but it is used only in training, so the shipped codec stays causal.

Delay between codebooks

A large temporal transformer steps once per frame; a small depth transformer predicts the 8 tokens inside each frame. Call the acoustic delay τ: codebooks 2 to 8 lag the first by τ frames. The latency is ℓ.

Say it aloud

ell equals 1 plus tau, times 80 milliseconds.

ℓ
ell the theoretical latency before the model's first full frame of speech.
τ
tau the acoustic delay, in frames.
80 ms
80 milliseconds one Mimi frame.
In plain words

Wait one frame to hear 80 ms of input. The acoustic tokens of a frame come tau frames after its first token. Count the frames and multiply by 80 ms.

With numbers

Delay 0 gives 80 ms. Delay 1 gives 160 ms. Delay 2 gives 240 ms. A fully staggered pattern lags codebook 8 by 7 frames: 640 ms. Moshi pre-trains with τ = 2 and fine-tunes with τ = 1: 160 ms in theory, 200 ms in practice.

Stagger the codebooks

Columns are 80 ms steps, rows are codebooks. Teal is the first, semantic codebook; purple are acoustic ones. Frame 0's tokens have an outline. Press Play, then change the delay.

1

Moshi's paper tests delays of 0, 1 and 2 frames and a fully staggered pattern. Delays of 3 to 7 are shown for comparison.

Moshi models its own voice and the user's as two parallel token streams. It predicts its next 80 ms whether or not you speak, so there is no endpoint hold to tune. Its Inner Monologue also predicts text tokens aligned with its speech. Delay the text 2 s behind the audio and the model is a streaming recognizer: 5.7% WER on LibriSpeech test-clean. Delay the audio 2 s behind the text and it is a streaming synthesizer: 4.7%, against VALL-E's 5.9%.

Qwen2.5-Omni keeps separate modules and streams each one: its audio encoder attends in 2-second blocks, and its speech decoder uses that 4-block window.

Symptom: you cannot audit what the agent heard.

Measure: check whether a text transcript exists for each turn.

Fix: keep a text stream, or keep a cascade where review and redaction matter more than speed.

Why does Moshi's delay of one frame give 160 ms and not 80 ms?

Chapter 8

Quality Against Latency

Measure the error rate as the user saw it, and find where more lookahead stops paying

Lookahead buys accuracy. To budget it, you need a curve of error rate against lookahead. Compare the model's words with a reference. Count the S substituted words, the D deleted words and the I inserted words. The reference has N words.

Say it aloud

WER equals S plus D plus I, over N.

WER
W-E-R the word error rate.
S
S substitutions: words replaced by the wrong word.
D
D deletions: reference words the model dropped.
I
I insertions: words the model added.
N
N the number of words in the reference.
In plain words

Line up the two word lists with the fewest edits. Count S, D and I. Divide by N, the reference length.

With numbers

Reference "i would like to move my flight", N = 7. Output "i would like to prove flight": S = 1 (prove), D = 1 (my), I = 0. WER = 2 / 7 = 28.6%.

Score the text the agent saw, each word frozen when it turned stable. Scoring the final transcript counts late fixes the agent never saw.

Published points show the shape. Emformer reports 3.01% WER on LibriSpeech test-clean at 80 ms average latency and 2.50% at about 960 ms: twelve times the lookahead for half a point. Moshi's recognizer gets 5.7% with 2 s of delay, and the paper notes a Streaming FastConformer gets 3.6% with similar lookahead.

Find the knee of the curve

Top: error rate against lookahead, your point marked. Bottom: what each extra 100 ms buys. Drag the lookahead past the knee, then stretch the scale.

300 ms
300 ms

Illustrative curve: the error falls from 11% with no lookahead toward a 5.5% floor, and each "scale" of lookahead removes about 63% of the gap left. Its shape matches the published points; its numbers are made up.

On this toy, the first 100 ms buys 1.56 points; the step from 900 to 1,000 ms buys 0.08. Past the knee, spend milliseconds on the endpoint hold or the first TTS chunk instead.

Symptom: accuracy falls off a cliff after the switch to streaming.

Measure: check the lookahead the model was trained with against the one it is served with.

Fix: train or fine-tune for each setting, or sample the chunk size at random during training so one model serves many.

The first 100 ms of lookahead saves 1.56 points; the step from 900 to 1,000 ms saves 0.08. What follows?

Chapter 9

Field Guide

Keep the terms, the numbers, the checklist and the core code in one place

A streaming stack reads only a little ahead, does each frame's work once, and never takes back a word it promised. The recognizer commits through a forward-only decoder and a stable prefix. The synthesizer starts on a small first chunk and keeps its buffer full. The turn gap is a max of two clocks plus a serial sum. Frame-level models remove the seams.

TermMeaningNumber on this page
C, Lchunk size and lookahead, in framesC 4, L 1: worst wait 40 ms
Receptive fieldthe inputs one output readsfive width-3 layers: 11 frames, 5 ahead
BlankCTC's "nothing new" symbolbest CAT path 0.047 of 0.334
Stable prefixwords promised never to changeLocalAgreement-2: 200 ms per word
RTFcompute seconds per audio second0.9 with chunks 3 then 8: a 1.74 s hole
Turn gapsilence from your last word to the replytoy cascade 1,125 ms; Moshi 200 ms; people 230 ms
Mimi frameone audio token step80 ms, 12.5 per second, 1.1 kbps
WER(S + D + I) / NEmformer 3.01% at 80 ms, 2.50% at 960 ms

Checklist

  1. Run the prefix test: outputs on frames 0 to t match the full run.
  2. Serve chunk by chunk with a KV cache; keep memory bounded.
  3. Return a stable prefix and a volatile guess; feed only the stable part downstream.
  4. Keep the first TTS chunk small; check the buffer margin at the slow tail of RTF.
  5. Log both clocks after silence; work on the later one.
  6. Score WER on emitted text, at the lookahead the model was trained with.

The core, in code

pythonimport numpy as np

def chunk_mask(T, C, L):                         # (T, T) bool, True = query may read key
    m = np.zeros((T, T), dtype=bool)
    for t in range(T):
        edge = min(T - 1, C * (t // C + 1) - 1 + L)
        m[t, :edge + 1] = True
    return m                                       # chunk_mask(12, 4, 1).sum() == 104

def ctc_greedy(probs, vocab):                     # probs: (T, V); vocab[0] is the blank
    out, prev = [], None
    for i in probs.argmax(axis=1):
        if i != prev and i != 0: out.append(vocab[i])   # emit once, never take back
        prev = i
    return ''.join(out)

class LocalAgreement:
    def __init__(self, n=2): self.n, self.hist, self.stable = n, [], []
    def update(self, words):                     # words: list[str], the newest hypothesis
        self.hist = (self.hist + [words])[-self.n:]
        if len(self.hist) == self.n:
            agree = min(len(h) for h in self.hist)
            for i in range(agree):
                if len({h[i] for h in self.hist}) > 1: agree = i; break
            if agree > len(self.stable): self.stable = words[:agree]   # a ratchet: never shrinks
        return self.stable, words[len(self.stable):]           # (stable, volatile)

def turn_gap(up, E, Wc, K, d, hops, ttft, ttfa, down):    # all in ms
    return up + max(E, Wc + K + d) + hops + ttft + ttfa + down
# turn_gap(95, 250, 150, 60, 140, 30, 375, 180, 95) == 1125

Keep going

Sources

Défossez et al., Moshi: a speech-text foundation model for real-time dialogue (2024). Qwen Team, Qwen2.5-Omni Technical Report (2025). Shi et al., Emformer (2020). Macháček, Dabre and Bojar, Turning Whisper into Real-Time Transcription System (2023). Graves, Sequence Transduction with Recurrent Neural Networks (2012). Graves et al., Connectionist Temporal Classification (ICML 2006).

The takeaway. A model that answers before you finish is not a faster model. It is a model that never has to wait: bounded lookahead, work done once, and words that stay put.
In one sentence, what makes a speech model streamable?

Now press Present or Teach and explain, from memory, the chunk mask, the stable prefix and the two clocks. Then go back to the hero and say which chapter removes each part of the batch system's gap.

Streaming Speech
Moshi · Qwen2.5-Omni · Emformer · Whisper-Streaming · Back to Gleams