Registry / ai-ml / kaldi-native-fbank

kaldi-native-fbank

JSON →
library1.22.3pypypi✓ verified 24d ago

Kaldi-native-fbank is a Python library providing a Kaldi-compatible online filter bank (fbank) feature extractor. It is designed to be efficient and has no external native dependencies, aiming for seamless integration across various architectures and operating systems. The library is actively maintained with frequent releases, with the current stable version being 1.22.3.

pip install kaldi-native-fbank
INSTALL
IMPORT
SIG · KALDI-NATIVE-FBANK
K
kaldi-native-fbank
ai-mlpythonv1.22.3
Install
1.6s avg
Import
Disk
17MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.22.3 · 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.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

kaldi_native_fbank
import kaldi_native_fbank as knf

This quickstart demonstrates how to initialize the `OnlineFbank` extractor with `FbankOptions` and process a waveform. Note that `kaldi_native_fbank.OnlineFbank.accept_waveform` expects input samples as a Python list or NumPy array, unlike some other libraries that might accept `torch.Tensor` directly. The example uses `torch.randn` for convenience to generate sample data, which is then converted to a list.

import kaldi_native_fbank as knf import torch import numpy as np # Configure Fbank options opts = knf.FbankOptions() opts.frame_opts.dither = 0.0 opts.mel_opts.num_bins = 80 opts.frame_opts.snip_edges = False opts.mel_opts.debug_mel = False sampling_rate = 16000 # Generate 10 seconds of random audio samples (simulating real audio) # Using torch.randn for convenience, convert to list or numpy array for `accept_waveform` samples_tensor = torch.randn(sampling_rate * 10) samples = samples_tensor.tolist() # kaldi_native_fbank expects list or numpy array # Initialize the online Fbank extractor fbank_extractor = knf.OnlineFbank(opts) # Process the waveform fbank_extractor.accept_waveform(sampling_rate, samples) # Retrieve the number of frames available num_frames = fbank_extractor.num_frames_ready print(f"Number of frames ready: {num_frames}") # Retrieve and print the first frame if num_frames > 0: first_frame = fbank_extractor.get_frame(0) print(f"Shape of the first frame: {first_frame.shape}") print(f"First frame (first 5 values): {first_frame[:5].round(decimals=4)}")
Debug
Known issues
gotchaKaldi's Fbank features are typically in log space and might have different scaling or representation compared to filter bank features generated by other Python speech processing libraries (e.g., `python_speech_features`). Always verify the feature specifications if integrating with models trained on features from other sources.
fix
Consult the Kaldi documentation or `kaldi-native-fbank` source for feature computation details. Apply appropriate normalization or transformation if integrating with different feature pipelines.
affects: All versions
gotchaWhile `kaldi-native-fbank` itself is advertised as 'without external dependencies' (referring to native libraries), its Python usage examples, including the official ones, often utilize `torch` for waveform generation and comparison. If you're not using `torch`, ensure your audio data is converted to a standard Python list or NumPy array before passing it to methods like `accept_waveform`.
fix
If `torch` is not installed or desired, convert your audio data to `list` or `numpy.ndarray` (e.g., `your_audio_tensor.numpy().tolist()`) before calling `accept_waveform`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'kaldi_native_fbank'
The `kaldi-native-fbank` library is not installed or not accessible in the current Python environment, or it is being imported with an incorrect module name.
fix
Ensure the package is installed using `pip install kaldi-native-fbank`. The correct import statement is `import kaldi_native_fbank` or `import kaldi_native_fbank as knf`.
AttributeError: '_kaldi_native_fbank.FbankOptions' object has no attribute 'dither'
Configuration options like 'dither' are nested within sub-objects (e.g., `frame_opts` or `mel_opts`) of the `FbankOptions` object and cannot be accessed directly.
fix
Access nested options through their respective sub-objects. For 'dither', use `opts.frame_opts.dither` instead of `opts.dither`.
TypeError: accept_waveform() takes 'torch.Tensor' but 'list' was given
The `OnlineFbank.accept_waveform` method expects audio input as a Python list or NumPy array, but a `torch.Tensor` was provided directly.
fix
Convert `torch.Tensor` input to a Python list or NumPy array before passing it to `accept_waveform`. For example, `your_audio_tensor.numpy().tolist()`.
Mismatch in fbank computation parameters causing deletion errors (e.g., high_freq)
The default or configured `FbankOptions` parameters, such as `high_freq`, may not align with the parameters used during the training of a specific model, leading to feature discrepancies and performance issues.
fix
Adjust the `FbankOptions` parameters (e.g., `opts.mel_opts.high_freq = -400`) to match those used in the training pipeline of the model you are integrating with.
Upgrade
Version history
1.22.3latest on PyPI · released Oct 9, 2025
Audit
Dependencies
torchoptionalUsed in common examples and for convenient waveform generation/handling, but not a hard dependency for the core library.
numpyoptionalOften used for array manipulation and is compatible with `accept_waveform` which takes list or numpy array.
Agent activity
7 hits · last 30 days
node
6
Resources
kaldi-native-fbank — pip install kaldi-native-fbank · libregistry