What Is Kaldi? ASR Data, Language Resources, and Decoding
Kaldi is a C++ toolkit for building and researching speech-recognition systems, not a ready-to-use transcription app. Learn how recipes connect audio, transcripts, pronunciation resources, language models, and decoding.
What Is Kaldi? ASR Data, Language Resources, and Decoding
Kaldi is a C++ toolkit for building and researching speech-recognition systems. It is not a single transcription app or a finished model: you select a dataset recipe, prepare audio and speaker/transcript metadata, configure language resources and models, then decode and evaluate. The project describes researchers as its primary audience and distributes Kaldi under Apache License 2.0.
How a recognizer forms a transcript
A speech recognizer extracts acoustic features from audio. An acoustic model scores likely phones or states over time; a pronunciation lexicon maps words to phone sequences; and a language model scores plausible word sequences. Kaldi combines these paths with finite-state transducers (FSTs) and a decoder to search for candidate transcripts. In simplified form:
audio → acoustic features and scores → pronunciation and language graph → decoder → words
This structure is flexible because components can be changed for research. It also means mismatched lexicons, phone sets, transcript conventions, or symbol tables can create errors later in training or decoding. Kaldi recipes group the steps into scripts tailored to a dataset.
Separate audio metadata from language resources
Kaldi documentation divides preparation into two broad parts:
A data directory such as data/train describes recordings, transcripts, and which speaker said each utterance.
A language directory such as data/lang holds word, pronunciation, phone-set, and symbol-table information. Depending on the recipe, a language model or grammar is added to a decoding graph.
For a simple case with one file per utterance, the key files you provide are:
| File | Purpose | Example line |
|---|---|---|
| wav.scp | Map an utterance ID to audio | spk01_utt01 /data/audio/spk01_utt01.wav |
| text | Correct transcript for that ID | spk01_utt01 turn left |
| utt2spk | Map utterance to speaker | spk01_utt01 spk01 |
| segments | Mark utterance times inside a longer recording | spk01_utt01 rec01 1.20 2.85 |
These are format examples, not real recordings or results. Without segments, a recording may be treated as one utterance. If a recording contains multiple utterances, IDs, recording IDs, and time boundaries must agree. The official data guide requires single-channel audio in wav.scp; extract a channel when the source is multichannel.
Move from an example recipe to your data
1. Choose an environment and recipe
Kaldi’s tutorial assumes C++, shell scripting, and basic speech-recognition knowledge, and focuses on Unix-like environments or Cygwin. Start with a recipe under egs that resembles your language and data format. Its local scripts contain corpus-specific preparation rules, so do not copy them unchanged for another dataset.
After cloning the source repository, follow its installation instructions and inspect dependencies. The tutorial presents this as a basic build path, though platform and library differences may require extra steps:
git clone https://github.com/kaldi-asr/kaldi.git
cd kaldi/tools
make
cd ../src
./configure
makeIf compilation fails, read the installation output and INSTALL guidance instead of guessing from the last error line. Causes can include missing dependencies or math-library configuration.
2. Split training and evaluation data by speaker
If the same speakers appear in training and evaluation sets, results may overstate performance on new speakers. Where possible, split by speaker and document how language, microphone, and noise conditions are represented. Keep evaluation transcripts out of training. This is an experimental-design recommendation to reduce data leakage.
Create wav.scp, text, and utt2spk under data/train and data/test; add segments when a recording contains multiple utterances. IDs must match across files, and every transcript must point to the correct audio. Follow the recipe’s rules for paths and command pipes in wav.scp.
3. Validate data and compute features
Before preprocessing, run the recipe’s data validation utility:
utils/validate_data_dir.sh data/trainIf it reports sorting, transcript, or missing-audio problems, check the original files and ID mapping first. utils/fix_data_dir.sh can reorder entries and remove utterances lacking required data. Review what it will remove and preserve an original inventory before using it; it cannot repair incorrect labels.
Then run the feature extraction and training steps specified by the recipe, such as steps/make_mfcc.sh. Features and models differ by recipe, so understand inputs, outputs, and settings before copying a command.
4. Build language resources and evaluate
Words in the transcript need pronunciations and a phone inventory. Kaldi’s utils/prepare_lang.sh builds the data/lang structure from simpler dictionary inputs. A language model or grammar can be converted into an FST and incorporated into the decoding graph. Words outside the vocabulary may map to a configured OOV symbol, so check transcript normalization and vocabulary coverage.
Decoding an evaluation set typically creates logs and outputs under exp/. Verify that results are nonempty, logs have no errors, and the audio matches its reference transcript. When the corpus supports it, calculate word error rate (WER) and inspect sample transcripts against the audio. A score on one corpus does not predict results for another language, device, or domain.
When Kaldi fits
| Situation | Fit |
|---|---|
| ASR research where you need control over models, lexicons, and language models | Strong fit; recipes and components are modifiable. |
| Reproducing training/evaluation on a public corpus | Useful when you can access the corpus and follow its recipe. |
| Adding transcription quickly through one API | Compilation, configuration, and data preparation may be more work than a higher-level library or service. |
| Audio without transcripts or pronunciation resources | Not ready for training; prepare labels, vocabulary resources, and evaluation splits first. |
Kaldi’s strength is a configurable and reproducible ASR pipeline. The trade-off is that corpus formats, speaker metadata, symbol tables, models, and shell recipes must be managed together. Decide whether the goal is simple transcription or research/adaptation, then confirm that you can obtain the data and language resources the recipe requires.
Sources
Kaldi, [About the project](https://kaldi-asr.org/doc/about.html)
Kaldi, [Data preparation](https://kaldi-asr.org/doc/data_prep.html)
Kaldi, [Tutorial prerequisites](https://kaldi-asr.org/doc/tutorial_prereqs.html)
Kaldi, [Getting started](https://kaldi-asr.org/doc/tutorial_setup.html)
Daniel Povey et al., [The Kaldi Speech Recognition Toolkit](https://publications.idiap.ch/downloads/papers/2012/Povey_ASRU2011_2011.pdf), ASRU 2011.