Why do low frame-rate codecs make speech LLMs faster?

Authors
Why do low frame-rate codecs make speech LLMs faster?

Low frame-rate codecs make speech LLMs faster because they turn every second of speech into far fewer tokens, so the model has fewer steps to generate, less to pay attention to, and less to keep in memory.

In this blog, we will learn about why low frame-rate codecs make speech LLMs faster. We will also see what an audio codec, frame rate, and codebooks are, how many tokens one second of speech costs, why fewer frames save time and memory, how the codebooks inside one frame are handled, how these codecs keep the voice quality high, and where this approach works well and where it fails.

We will cover the following:

  • What is a speech LLM?
  • What is an audio codec?
  • What is frame rate in an audio codec?
  • What are codebooks?
  • How many tokens does one second of speech cost?
  • Why fewer frames make the speech LLM faster
  • A step-by-step example
  • What happens to the codebooks inside one frame?
  • How low frame-rate codecs keep the quality high
  • Where it works well and where it fails

I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

I teach AI and Machine Learning at Outcome School.

Let's get started.

What is a speech LLM?

A speech LLM is a model that understands or produces speech by reading and generating audio tokens, the same way a text LLM reads and generates text tokens.

For example, a voice assistant that listens to us and speaks back is built on a speech LLM.

A text LLM (Large Language Model) works one token at a time. It looks at all the tokens so far, predicts the next token, adds it to the sequence, and repeats.

A speech LLM does exactly the same thing. The only difference is that its tokens represent small pieces of sound instead of pieces of text.

We have a detailed blog on Spoken Language Models that explains this in depth.

But, feeding raw sound directly to an LLM is not practical. Raw audio is a very long list of numbers. Speech audio for these models is often stored as 24,000 numbers for every single second. If we treat each of those numbers as a token, the sequence becomes far too long for an LLM to handle.

So, we need something that converts the raw sound into a short list of tokens, and converts the tokens back into sound. Here comes the audio codec into the picture.

What is an audio codec?

A neural audio codec is a trained model that compresses raw audio into a small list of tokens, and then rebuilds the audio back from those tokens.

Codec = Coder + Decoder. In this blog, when we say codec, we mean a neural audio codec. It has two parts:

  • Encoder: It takes the raw audio and turns it into tokens.
  • Decoder: It takes the tokens and turns them back into audio.

The flow looks like below:

Raw audio (24,000 numbers per second)
                  ↓
               Encoder
                  ↓
            Audio tokens
                  ↓
             Speech LLM
                  ↓
          New audio tokens
                  ↓
               Decoder
                  ↓
        Raw audio we can hear

Here, we can see that the speech LLM never touches the raw audio. It only works with the tokens. So, the number of tokens that the codec produces decides how much work the speech LLM has to do.

What is frame rate in an audio codec?

The encoder does not create one token for every one of the 24,000 numbers. It groups the audio into small slices of time. Each slice is called a frame.

Frame rate is the number of frames the codec creates for every one second of audio. It is written in Hz, which means "per second".

Let's say we have a codec with a frame rate of 75 Hz. Means, it cuts every second of audio into 75 frames. Each frame covers 1/75 of a second, which is about 13 milliseconds of sound.

Now, assume that we have another codec with a frame rate of 12.5 Hz. It cuts every second into only 12.5 frames. Each frame covers 1/12.5 of a second, which is 80 milliseconds of sound.

Let's see two real codecs:

  • EnCodec (from Meta), at 24 kHz audio, works at 75 frames per second.
  • Mimi (from Kyutai, used in the Moshi voice model) works at 12.5 frames per second.

So, Mimi creates 6 times fewer frames than EnCodec for the same speech. This is what we call a low frame-rate codec.

Let's say we must describe one second of sound using written notes. A high frame-rate codec writes 75 short notes. A low frame-rate codec writes only 12.5 notes, so each note must say much more.

Planning your move into AI?

No matter which tech domain you work in today, with your effort, you can transition to these roles:

  • AI Engineer
  • Forward Deployed Engineer
  • AI Agent Engineer
  • Harness Engineer
  • Voice AI Engineer
  • AI Architect
  • LLM Engineer
  • LLM Inference Engineer
  • Gen AI Engineer
  • MLOps Engineer
  • ML Engineer
  • Deep Learning Engineer

Our AI and Machine Learning Program at Outcome School takes you there.

What are codebooks?

One frame is still a rich slice of sound. A single token is not enough to describe it well. So, codecs describe each frame with a small stack of tokens.

They do this using a method called Residual Vector Quantization, or RVQ. Here, residual means "what is left over".

Let's understand it in simple steps:

  • The first token gives a rough description of the frame.
  • The second token describes what the first token missed.
  • The third token describes what is still missing after the first two tokens.
  • And so on.

Each level in this stack picks its token from its own list of possible values. That list is called a codebook. The token is the position number of the chosen entry in that list. So, if a codec uses 8 codebooks, every frame becomes 8 tokens.

Total tokens per second = Frame rate * Number of codebooks

How many tokens does one second of speech cost?

Now, let's put the numbers together.

Let me tabulate the differences between a high frame-rate codec and a low frame-rate codec for your better understanding.

CodecFrames per secondCodebooksTokens per secondBitrate
EnCodec (24 kHz)7586006 kbps
Mimi (in Moshi)12.58100about 1.1 kbps

Here, we can see that for the same one second of speech, EnCodec with 8 codebooks produces 600 tokens and Mimi produces only 100 tokens. Bitrate is the amount of data per second, in kilobits per second (kbps).

Now, let's compare it with text. When we speak at a normal pace, we say about 2 to 3 words per second. That is only around 3 to 4 text tokens per second.

So, even at 12.5 Hz, audio is still more costly than text. At 75 Hz, it is far more costly. This is why reducing the frame rate gives such a big saving.

We have a detailed blog on why speech LLMs lose reasoning ability compared to text LLMs that explains how a long list of speech tokens hurts the model.

We can also reduce the number of codebooks, but every codebook we remove takes away detail from the voice. And, as we will see later, the codebooks inside one frame can be handled by a small, cheap model. So, the frame rate is the number that controls the cost of the big model.

A quick note for you

No matter which tech domain you work in, get familiar with these topics:

  • LLM
  • RAG
  • MCP
  • Agent
  • Fine-tuning
  • Quantization

We put it all together in one video:

AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization

No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.

Now, let's get back to the topic.

Why fewer frames make the speech LLM faster

The speech LLM moves forward one frame at a time, and every step takes time. So, fewer frames per second directly means fewer steps per second. But, that is not the only gain. There are three gains.

Gain 1: Fewer generation steps

To speak 1 second of audio, the model must produce all the frames of that second. At 75 Hz, it needs 75 main steps. At 12.5 Hz, it needs only 12.5 main steps.

For a real-time voice assistant, the model must create audio at least as fast as we listen to it. If it is slower, the voice breaks and stutters. With 12.5 steps per second, each step gets 80 milliseconds of time budget. With 75 steps per second, each step gets only about 13 milliseconds. A large model can finish its work in 80 milliseconds much more easily than in 13 milliseconds.

Gain 2: Less attention work

At every step, the model looks back at all the earlier frames using attention. When the sequence gets longer, this work grows quickly. For the full sequence, the attention work grows roughly with the square of the length.

So, if the sequence becomes 6 times shorter, the attention work becomes roughly 36 times smaller. The other layers of the model do a fixed amount of work for every frame, so their work becomes about 6 times smaller.

Gain 3: Less memory and longer conversations

The model keeps a memory of the earlier frames, called the KV Cache, so that it does not repeat old work. This memory grows with every new frame.

Fewer frames means a smaller KV Cache. And a fixed context window now covers a much longer conversation.

Let's say the model can hold 4,096 frames in its context:

  • At 75 Hz, 4,096 frames hold about 55 seconds of audio.
  • At 12.5 Hz, 4,096 frames hold about 5 and a half minutes of audio.

To learn the Attention Mechanism, KV Cache, and Transformer Architecture, and build a Large Language Model (LLM) from scratch, we can check out our AI and Machine Learning Program at Outcome School.

A step-by-step example

The best way to learn this is by taking an example.

Suppose our voice assistant must reply with a 10-second answer.

Step 1: We count the frames. At 75 Hz, 10 seconds becomes 750 frames. At 12.5 Hz, 10 seconds becomes 125 frames.

Step 2: We count the tokens with 8 codebooks. At 75 Hz, it is 750 * 8 = 6,000 tokens. At 12.5 Hz, it is 125 * 8 = 1,000 tokens.

Step 3: We count the main generation steps. The main model moves forward one frame at a time, so it takes 750 steps at 75 Hz, and only 125 steps at 12.5 Hz. Since 10 seconds = 10,000 milliseconds, to keep up in real time, each step must finish in 10,000 / 750 = about 13 milliseconds at 75 Hz, but it gets 10,000 / 125 = 80 milliseconds at 12.5 Hz.

Step 4: We compare the attention work. The length ratio is 750 / 125 = 6. So, the attention work over the frames is roughly 6 * 6 = 36 times smaller at 12.5 Hz.

Here, we can notice that the same 10 seconds of speech needs 6 times fewer steps and much less attention work. The words of the answer are the same. Only the codec changed.

What happens to the codebooks inside one frame?

Now, the question is: if every frame still has 8 tokens, does the big model still need 8 steps for every frame?

If we simply put all 8 tokens of every frame in one long line, the answer is yes. The line becomes 8 times longer, and we lose a large part of the gain.

So, models like Moshi split the work into two parts:

  • A big main model that moves forward one frame at a time, 12.5 times per second. It handles the meaning and the flow of the conversation.
  • A small helper model that, inside each frame, quickly generates the 8 codebook tokens one after another.

In Moshi, these are called the Temporal Transformer and the Depth Transformer.

The big model is the expensive one, and it now runs only 12.5 times per second. The small model is cheap, so running it 8 times inside each frame costs far less than running the big model 8 times.

Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.

How low frame-rate codecs keep the quality high

To reach 12.5 Hz, the encoder must pack much more audio into each frame. At 24,000 numbers per second, a 75 Hz frame holds 24,000 / 75 = 320 numbers, while a 12.5 Hz frame holds 24,000 / 12.5 = 1,920 numbers.

So, every frame must describe 6 times more sound. A simple codec loses detail here, and the voice starts to sound muffled or robotic.

So, low frame-rate codecs like Mimi use two ideas to keep the quality high:

  • Transformer layers inside the codec: Mimi adds Transformer layers to its encoder and decoder. These layers let each frame look at a wider window of the surrounding sound, so each frame captures more context.
  • Meaning in the first codebook: The first codebook is trained to match a speech understanding model called WavLM. So, the first token of each frame carries information about what is being said, and the other codebooks carry the details of the voice.

Because of this, Mimi reaches about 1.1 kilobits per second while keeping the speech clear.

Where it works well and where it fails

Where it works well:

  • Real-time voice assistants that must reply quickly and speak smoothly.
  • Long conversations, because more minutes of audio fit into the context window.
  • Running with less GPU memory, because the KV Cache stays small.
  • Mixing text and speech in one model, because a lower audio frame rate is closer to the text token rate. Moshi, for example, predicts text tokens alongside its audio tokens on the same 12.5 Hz timeline.

Where it fails:

  • Very fast sounds can get blurred. A frame of 80 milliseconds can hold more than one quick sound, so some fine detail can be lost.
  • Music and complex background audio usually need more detail than speech, and a very low frame rate struggles with them.
  • The codec itself becomes harder to design and train, because each frame must carry so much information.
  • The first audio of a reply cannot come out before at least one full frame is ready, so a longer frame sets a small minimum delay.

So, the frame rate is a balance. Lower means faster and lighter, but if we go too low, the voice loses detail.

Now we must have understood why low frame-rate codecs make speech LLMs faster, how they reduce the steps, the attention work, and the memory, and where this approach works well and where it fails.

Frequently Asked Questions

What is Mimi in Moshi?

Mimi is a low frame-rate neural audio codec from Kyutai, used in the Moshi voice model. It works at 12.5 frames per second with 8 codebooks, so one second of speech becomes about 100 tokens at about 1.1 kilobits per second. It uses Transformer layers and a first codebook trained to match WavLM to keep the speech clear.

Does a lower frame rate reduce voice quality?

It can. At a lower frame rate, every frame must describe more sound, and a simple codec loses detail, so the voice can sound muffled or robotic. Very fast sounds can also get blurred, and music or complex background audio usually needs more detail than a very low frame rate can give.

Why not just reduce the number of codebooks instead?

Because every codebook we remove takes away detail from the voice. Also, the codebooks inside one frame can be handled by a small, cheap helper model, while the big main model moves forward one frame at a time. So, the frame rate is the number that controls the cost of the big model.

Does a low frame-rate codec add delay?

A little. The first audio of a reply cannot come out before at least one full frame is ready, so a longer frame sets a small minimum delay. At 12.5 Hz, each frame covers 80 milliseconds of sound, but each generation step also gets an 80 millisecond time budget, which a large model can meet much more easily.

That's it for now.

Thanks

Amit Shekhar
Founder @ Outcome School

You can connect with me on:

Follow Outcome School on:

Read all of our high-quality blogs here.