How does the Token-and-Duration Transducer (TDT) speed up speech recognition?
- Authors
- Name
- Amit Shekhar
- Published on
The Token-and-Duration Transducer (TDT) speeds up speech recognition by predicting two things at every step: the next token, and how many audio frames to jump ahead. Because it can skip several frames at once, it needs far fewer steps than a normal Transducer to turn the same audio into text.
In this blog, we will learn about how the Token-and-Duration Transducer (TDT) speeds up speech recognition. We will also see how speech is broken into frames, how a normal Transducer reads those frames one by one, why that wastes so much time, how TDT adds a duration prediction to skip ahead, how it is trained, and where it works well and where it fails.
We will cover the following:
- How a speech model sees audio
- What is a Transducer?
- The problem: too many steps
- What is the Token-and-Duration Transducer (TDT)?
- How TDT decodes, step by step
- How TDT is trained
- Normal Transducer vs TDT
- Where TDT 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.
How a speech model sees audio
Before jumping into TDT, we must know how a speech recognition model looks at audio.
Speech recognition means turning spoken audio into written text.
A speech recognition model does not hear a sentence the way we do. It cuts the audio into tiny slices of time, called frames. Each frame is a very short piece of sound.
For example, many modern models first cut the audio into 10-millisecond pieces and then merge every 8 pieces into one, so that each frame covers 80 milliseconds.
So, a 10-second audio clip becomes around 125 frames. The first part of the model, called the encoder, turns each frame into a list of numbers that describes what sound is present in that slice.
On the output side, the model writes text as tokens. A token is a small piece of text. It can be a full word like "hello" or a part of a word like "ing".
The number of frames is usually much larger than the number of tokens.
A person speaks around 2 to 4 tokens per second, but the model sees around 12.5 frames per second. Means, most frames do not produce any new token. They are just the middle of a sound, or a pause, or silence.
TDT is built on top of this observation.
What is a Transducer?
A Transducer is a speech recognition model that reads the audio frames from start to end and, at each step, decides whether to write a token or to move to the next frame.
It is also known as RNN-T (RNN Transducer), because the first version was built with RNNs (Recurrent Neural Networks), an older kind of neural network that reads things in order. Today, the parts are often built with newer networks like Conformer, but the name Transducer stays.
A Transducer has three parts:
- Encoder: It reads the audio frames and turns each frame into numbers.
- Prediction network: It reads the tokens written so far, so that the model knows what text has already been produced.
- Joint network: It takes the current frame from the encoder and the current text from the prediction network, and decides what to output next.
The joint network has one extra choice besides the real tokens. It is a special symbol called blank. Blank means "nothing new to write here, move to the next frame."
So, at every step, a normal Transducer follows one rule:
- If it outputs a real token, it writes the token and stays on the same frame. It stays because one frame can sometimes contain more than one token.
- If it outputs blank, it writes nothing and moves forward by exactly one frame.
Let's say we have 6 frames and the spoken word is "cat", which is one token. The normal Transducer works like below:
Frame 1 -> blank (move to frame 2)
Frame 2 -> blank (move to frame 3)
Frame 3 -> "cat" (stay on frame 3)
Frame 3 -> blank (move to frame 4)
Frame 4 -> blank (move to frame 5)
Frame 5 -> blank (move to frame 6)
Frame 6 -> blank (end)
Here, we can see that the model made 7 decisions to write just one token. Six of those decisions were blank.
This is how a normal Transducer works. Now, let's understand why this is a problem.
The problem: too many steps
Every decision in the example above is one run of the joint network. And every time a real token is written, the prediction network also runs again to read the new text. These runs happen one after another. The model cannot make decision 5 before it knows the result of decision 4.
So, the total number of steps for a normal Transducer is:
Number of steps = Number of frames + Number of tokens
Let's take a bigger example. Suppose we have 10 seconds of speech. That is around 125 frames. Suppose the speaker says 30 tokens.
- Steps for the normal Transducer: 125 + 30 = 155 steps
- Steps that produce a real token: 30
- Steps that only say blank: 125
Means, around 80 percent of the steps are spent saying "nothing here, move on".
The encoder processes all frames together in parallel, so it is fast. The slow part is this step-by-step loop at the end. And this loop gets longer as the audio gets longer.
Now, the question is: if the model already knows that the next few frames are just the rest of the same sound, why can it not jump over them in one step?
So, here comes the Token-and-Duration Transducer to the rescue.
What is the Token-and-Duration Transducer (TDT)?
The Token-and-Duration Transducer (TDT) is a Transducer that, at every step, predicts both a token and a duration. The duration tells the model how many frames to jump forward after this step.
TDT was introduced by researchers at NVIDIA in the paper "Efficient Sequence Transduction by Jointly Predicting Tokens and Durations" at ICML 2023.
The name itself tells us the idea:
- Token: what to write (a real token or blank).
- Duration: how many frames this output covers, which means how far to jump.
In a normal Transducer, the jump is fixed. Blank always jumps 1 frame. A real token always jumps 0 frames. In TDT, the model learns the jump size by itself.
The durations come from a small fixed list chosen before training. A common list is:
Durations = 4
So, at each step, the model can say "write this token and jump 3 frames", or "blank and jump 4 frames", and etc.
Note: Blank must always jump at least 1 frame. If blank could jump 0 frames, the model would write nothing and stay on the same frame forever. A real token can jump 0 frames, so that the model can still write two tokens from the same frame.
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.
Two outputs from one joint network
The only change in the architecture is inside the joint network. An output head is the last layer of a network that gives the final answer. A normal joint network has one output head, which gives a probability for each token plus blank.
The TDT joint network has two output heads:
- Token head: gives a probability for each token plus blank.
- Duration head: gives a probability for each duration in the list, like 0, 1, 2, 3, and 4.
Both heads look at the same input, which is the current frame and the current text.
Each head turns its scores into probabilities on its own. The paper calls this "independently normalized". Means, the token probabilities add up to 1, and the duration probabilities add up to 1, separately.
The diagram below shows one TDT step:
Audio frame t Tokens written so far
↓ ↓
+-------------+ +----------------------+
| Encoder | | Prediction network |
+-------------+ +----------------------+
↓ ↓
+-------------+--------------+
↓
+----------------------------+
| Joint network |
+----------------------------+
↓ ↓
+------------+ +---------------+
| Token head | | Duration head |
+------------+ +---------------+
↓ ↓
"cat" jump 3
Here, the encoder and the prediction network work exactly like in a normal Transducer. Only the joint network has one extra head. This is why TDT adds very less extra cost per step.
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.
How TDT decodes, step by step
Decoding means turning the audio frames into text, one step at a time.
The best way to learn this is by taking an example.
Let's take the same 6 frames and the same word "cat". This time, the model uses TDT.
Step 1: The model is at frame 1. It predicts blank with duration 2. It writes nothing and jumps from frame 1 to frame 3.
Step 2: The model is at frame 3. It predicts "cat" with duration 3. It writes "cat" and jumps from frame 3 to frame 6.
Step 3: The model is at frame 6. It predicts blank with duration 1. It writes nothing and moves past the last frame. The audio is finished.
The decoding looks like below:
Frame 1 -> blank, jump 2 (move to frame 3)
Frame 3 -> "cat", jump 3 (move to frame 6)
Frame 6 -> blank, jump 1 (end)
Here, we can see that TDT made only 3 decisions. The normal Transducer made 7 decisions for the same audio and the same output.
We can write the TDT decoding loop as below:
t = 0 # current frame
tokens = [] # text written so far
while t < num_frames:
token, duration = joint(encoder_out[t], prediction(tokens))
if token != BLANK:
tokens.append(token)
if token == BLANK and duration == 0:
duration = 1 # blank must always move forward
t = t + duration
Here, we have:
tis the frame the model is looking at right now.joint(...)returns the most likely token and the most likely duration. Picking the most likely choice at each step is called greedy decoding.- If the token is not blank, we add it to the text.
- Then we move
tforward by the predicted duration, instead of by a fixed 1 or 0.
This one line, t = t + duration, is where the speed comes from.
In a normal Transducer, the same line would be t = t + 1 for blank and t = t + 0 for a real token.
Note: In a real implementation, the decoding code also limits how many tokens can be written from the same frame, so that it does not get stuck in a loop.
I have kept only the important lines of the code and removed other lines for brevity.
Now, let's go back to our 10-second audio with 125 frames and 30 tokens. Suppose, just for the sake of understanding, that every real token jumps 1 frame and every blank jumps 4 frames.
- The 30 tokens take 30 steps and cover 30 frames.
- The remaining 95 frames need 24 blanks, because 24 * 4 = 96 frames, which is enough.
- Total steps: 30 + 24 = 54 steps, instead of 155 steps.
The real numbers depend on the audio and on what the model predicts. The paper reports that on speech recognition, TDT models are up to 2.82 times faster than normal Transducers when turning new audio into text, with better or similar accuracy.
Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.
How TDT is trained
Now, the next big question is: how does the model learn the right durations? Nobody marks in the training data that "cat" lasts exactly 3 frames.
The training data only has two things: the audio and the correct text. It does not say which frame each token belongs to.
A normal Transducer has the same problem, and it solves it with a special loss. A loss is a score that tells the model how wrong it is during training. Let's understand this loss.
Think of a grid. One side is the frames (time). The other side is the tokens written so far. Every possible way to read the audio and write the correct text is one path through this grid.
The normal Transducer loss adds up the probability of every valid path, and trains the model to make the total as high as possible.
This is done efficiently with a method called the forward-backward algorithm, so that we do not need to list every path one by one.
TDT uses the same idea with one change. In a normal Transducer, each move in the grid goes either 1 frame to the right (blank) or 1 token up (real token). In TDT, the moves follow the durations:
- A blank moves to the right by its duration, which can be 1, 2, 3, or 4 frames.
- A real token moves 1 token up and also moves to the right by its duration, which can be 0, 1, 2, 3, or 4 frames.
Let's take our 6 frames and the word "cat" again. One valid path is the one we saw: blank and jump 2, "cat" and jump 3, blank and jump 1. Another valid path is: blank and jump 4, "cat" and jump 0, blank and jump 2. Both paths cover all 6 frames and write "cat", so the loss counts both of them.
The probability of a move is now:
Probability of a move = Probability of the token * Probability of the duration
And the probability of a full path is the probabilities of all its moves multiplied together.
So, the TDT loss adds up the probability of all valid paths with all allowed jump sizes. The model is never told the exact duration. It discovers by itself which durations make the correct text most likely.
This is how TDT learns both what to write and how far to jump, from just audio and text.
To learn Loss Functions and how a model learns from its training data from the ground up, check out our AI and Machine Learning Program at Outcome School.
Normal Transducer vs TDT
Let me tabulate the differences between a normal Transducer and TDT for your better understanding.
| Point | Normal Transducer | TDT |
|---|---|---|
| Output at each step | One token or blank | One token or blank, plus a duration |
| Jump after blank | Always 1 frame | Predicted, at least 1 frame |
| Jump after a real token | Always 0 frames | Predicted, can be 0 or more frames |
| Joint network heads | One head | Two heads (token and duration) |
| Number of decoding steps | Number of frames plus tokens | Fewer, because it skips frames |
| Training loss | Transducer loss | Transducer loss extended with jumps |
Where TDT works well and where it fails
Where it works well:
- Long audio: Long recordings have many stretches of blank frames, like pauses and the middle of long sounds, and TDT saves time by jumping over them.
- Large amounts of audio: It is useful when we need to transcribe a lot of audio quickly, or when we need low cost per hour of audio.
- Same building blocks: It keeps the same encoder and prediction network as a normal Transducer, so it fits into existing Transducer systems. NVIDIA uses it in its Parakeet-TDT speech recognition models in the NeMo toolkit.
- Beyond speech recognition: The paper also shows speedups on speech translation and on finding the intent behind spoken commands.
Where it fails or has limits:
- The jump has a maximum: The model can only jump as far as the largest duration in the list, for example 4 frames. In very long silences, it still needs several steps.
- Wrong jumps skip sound: If the model predicts a jump that is too large, it can skip over frames that contain a token, and that token gets missed.
- The loop is still sequential: TDT reduces the number of steps, but each step still waits for the previous one. It is faster, not fully parallel.
- The duration list is fixed: We must pick the list of durations before training. A list with a small maximum jump gives less speedup.
Now we must have understood how the Token-and-Duration Transducer (TDT) speeds up speech recognition, how it predicts a token and a duration at every step, how it skips frames, and how it is trained.
Frequently Asked Questions
Is RNN-T the same as a Transducer?
Yes. RNN-T, or RNN Transducer, is another name for a Transducer. It got this name because the first version was built with RNNs (Recurrent Neural Networks). Today, its parts are often built with newer networks like Conformer, but the name Transducer stays. TDT is a Transducer that also predicts how many frames to jump at every step.
Why must blank always jump at least one frame in TDT?
Blank must jump at least one frame so that the model never gets stuck. If blank could jump 0 frames, the model would write nothing and stay on the same frame forever. A real token can still jump 0 frames, so that the model can write two tokens from the same frame.
Does TDT change the encoder of a speech recognition model?
No. TDT keeps the same encoder and prediction network as a normal Transducer. The only change is inside the joint network, which gets a second output head that predicts the duration. This is why TDT adds very little extra cost per step and fits into existing Transducer systems.
How much faster is TDT than a normal Transducer?
The paper that introduced TDT reports that on speech recognition, TDT models are up to 2.82 times faster than normal Transducers when turning new audio into text, with better or similar accuracy. The real numbers depend on the audio and on what the model predicts, because larger jumps over blank frames mean fewer decoding steps.
Who created the Token-and-Duration Transducer?
TDT was introduced by researchers at NVIDIA in the paper "Efficient Sequence Transduction by Jointly Predicting Tokens and Durations" at ICML 2023. NVIDIA uses it in its Parakeet-TDT speech recognition models in the NeMo toolkit.
That's it for now.
Thanks
Amit Shekhar
Founder @ Outcome School
You can connect with me on:
Follow Outcome School on:
