Lesson 9 / Unit 3: First Recognizer
Acoustic Encoder
Follow the small convolutional and recurrent network from spectral frames to token probabilities.
The model has three jobs: reduce the frame rate, combine acoustic context and assign a probability to each token. Every weight in these stages starts randomly. There is no pretrained speech encoder hidden in the baseline.
Model Stages
self.conv = nn.Sequential( nn.Conv1d(129, 64, 5, stride=2, padding=2), nn.ReLU(), nn.Conv1d(64, 64, 5, stride=2, padding=2), nn.ReLU())self.gru = nn.GRU(64, 64, batch_first=True, bidirectional=True)self.head = nn.Linear(128, 11)The two GRU directions produce 128 features per frame. The final linear layer maps those features to eleven scores, and log_softmax turns them into the log probabilities consumed by the loss.
Context Cost
The backward GRU direction uses later frames. This makes the baseline an offline encoder even if the forward pass is very fast. Feeding it partial audio repeatedly can produce useful previews, but that is not equivalent to incremental inference with a causal model.
Packing lengths matters here: padded frames should not become future context. Revisit Batch Construction before replacing the recurrent layer.
Inspect Parameters
from lab import Recognizermodel = Recognizer()print(sum(p.numel() for p in model.parameters()))The checked-in implementation has 113,227 trainable parameters. That is a count from the code, not a capacity recommendation. Changing channel width, vocabulary size or directionality changes the count and the task the model can solve.
Use the complete class in the lab download; the excerpt omits packing and output-length code. Next comes CTC Alignment, which trains the frame predictions without manually timed character labels.
We do this work for teams shipping voice agents: Self-Hosted Voice Agent .
Edit this lesson on GitHub ↗Discussion
Questions, corrections and war stories welcome. Sign in with GitHub to comment.