Maintained. Last release 4 days ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install kaldi-hmm-gmmREADME as published on PyPI with version 1.4.0.
Introduction
Kaldi's HMM-GMM reimplementation with Eigen: diagonal-covariance GMMs, HMM topology and transition model, decision trees / context dependency, training-graph compilation, MLE/MAP estimation, and GMM decodables for forced alignment and decoding — from C++ and Python, without any kaldi binaries.
The decoding engine (lattice decoders, decoder wrappers, lattice best path)
lives in kaldi-decoder; this library links its C++ core and
implements its DecodableInterface / TransitionInformation.
Build
git clone https://github.com/csukuangfj/kaldi-hmm-gmm
cd kaldi-hmm-gmm
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
ctest --output-on-failure
All C++ dependencies (kaldi-decoder, kaldifst/openfst, Eigen, pybind11, googletest) are fetched automatically. To build a Python wheel instead:
python setup.py bdist_wheel
pip install dist/kaldi_hmm_gmm-*.whl
The Python package kaldi_hmm_gmm is self-contained — it does not require
the kaldi-decoder Python package at runtime.
Python API
import kaldi_hmm_gmm as khg
tm, am = khg.read_model("final.alimdl") # kaldi model format
tree = khg.read_tree("tree")
decodable = khg.DecodableAmDiagGmmScaled(am=am, tm=tm, feats=feats, scale=0.1)
cfg = khg.AlignConfig(beam=10.0, retry_beam=40.0) # kalpy/MFA defaults
num_done, num_error, _, like, frames, alignment, words = khg.align_utterance(
config=cfg, utt="utt", acoustic_scale=0.1,
transition_scale=1.0, self_loop_scale=0.1,
trans_model=tm, fst=training_graph, decodable=decodable)
See the documentation for the full API and two complete tutorials.
Examples
- yesno (
egs/yesno) — the kaldiegs/yesno/s5recipe, stage by stage: train a monophone GMM (40 iterations), build HCLG, decode, score. Run it withcd egs/yesno && ./run.sh. The corpus is the OpenSLR release; the script fetches the same tarball from a to reduce CI download time.