Registry / ai-ml / kaldifst

kaldifst

JSON →
library1.8.0pypypi✓ verified 83d ago

Kaldifst is a Python wrapper for the OpenFst library, a widely used C++ library for creating, manipulating, and performing operations on Finite State Transducers (FSTs) and Finite State Automata (FSAs). It is commonly used in speech recognition (e.g., Kaldi). As of version 1.8.0, it maintains an active release cadence, frequently updating with minor versions to address build fixes, performance improvements, and new features.

pip install kaldifst
INSTALL
IMPORT
SIG · KALDIFST
K
kaldifst
ai-mlpythonv1.8.0
Install
1.7s avg
Import
17ms
Disk
20MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.7s · import 0.017s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StdVectorFst
from kaldifst import StdVectorFst
import kaldifst; fst = kaldifst.Fst()
StdFst
from kaldifst import StdFst
compose
from kaldifst import compose

This quickstart demonstrates how to create a simple FST from a string, print its representation, apply common FST operations like determinization and minimization, and find the shortest path within it. The `from_str` method provides a convenient way to define FSTs for testing or simple cases.

import kaldifst # Create a simple Finite State Transducer (FST) from a string representation # Format: from_state to_state input_label output_label weight # Final states are specified by 'state_id final_weight' fst = kaldifst.Fst.from_str(""" 0 1 a a 0.5 1 2 b b 1.0 2 0.0 """) print("Initial FST:") print(fst) # Perform operations like determinization and minimization # Note: Many kaldifst functions modify the FST in-place kaldifst.det_and_minimize(fst) print("\nDeterminized and minimized FST:") print(fst) # Find the shortest path in the FST shortest_path_fst = kaldifst.shortestpath(fst) print("\nShortest path FST:") print(shortest_path_fst)
Debug
Known issues
gotchaKaldifst operations often mutate FST objects in-place. Be mindful of this when chaining operations or passing FSTs to functions, as it can lead to unexpected side effects if copies are not made explicitly.
fix
If you need to preserve the original FST, make an explicit copy before performing operations that modify it, e.g., `new_fst = kaldifst.Fst(original_fst)` or `new_fst = original_fst.copy()` if available.
affects: All versions
gotchaKaldifst wraps OpenFst, which supports various semirings (e.g., standard/tropical, log). Misunderstanding the implications of the chosen semiring (e.g., default `StdArc` for tropical) or mixing different semiring concepts can lead to incorrect results or errors in FST algorithms.
fix
Ensure a clear understanding of FST semirings. For most graph-shortest-path type problems, `StdArc` (tropical semiring) is appropriate. For probability computations, the log semiring is often used. Explicitly choose and understand your semiring.
affects: All versions
breakingWhile not frequently user-facing, updates to underlying C++ libraries like OpenFst or pybind11 (e.g., v1.8.0 updated OpenFst to 1.8.5) can sometimes lead to ABI incompatibilities or subtle behavioral changes, particularly if building from source or using custom OpenFst installations.
fix
Always use the pre-built wheels if possible. If building from source, ensure your OpenFst C++ library version is compatible with the `kaldifst` version's requirements, or allow `kaldifst` to build its own bundled OpenFst dependencies.
affects: >=1.8.0
Upgrade
Version history
1.8.0latest on PyPI · released Apr 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
20
Resources
kaldifst — pip install kaldifst · libregistry