No project description provided
Project description
Introduction
Kaldi-compatible online fbank feature extractor without external dependencies.
Tested on the following architectures and operating systems:
- Linux
- macOS
- Windows
- Android
- x86
- arm
- aarch64
Usage
See the following CMake-based speech recognition (i.e., text-to-speech) projects for its usage:
- https://github.com/k2-fsa/sherpa-ncnn
- Specifically, please have a look at https://github.com/k2-fsa/sherpa-ncnn/blob/master/sherpa-ncnn/csrc/features.h
- https://github.com/k2-fsa/sherpa-onnx
They use kaldi-native-fbank
to compute fbank features for real-time
speech recognition.
Python APIs
First, please install kaldi-native-fbank
by
git clone https://github.com/csukuangfj/kaldi-native-fbank
cd kaldi-native-fbank
python3 setup.py install
or use
pip install kaldi-native-fbank
To check that you have installed kaldi-native-fbank
successfully, please use
python3 -c "import kaldi_native_fbank; print(kaldi_native_fbank.__version__)"
which should print the version you have installed.
Please refer to https://github.com/csukuangfj/kaldi-native-fbank/blob/master/kaldi-native-fbank/python/tests/test_online_fbank.py for usages.
For easier reference, we post the above file below:
#!/usr/bin/env python3
import sys
try:
import kaldifeat
except:
print("Please install kaldifeat first")
sys.exit(0)
import kaldi_native_fbank as knf
import torch
def main():
sampling_rate = 16000
samples = torch.randn(16000 * 10)
opts = kaldifeat.FbankOptions()
opts.frame_opts.dither = 0
opts.mel_opts.num_bins = 80
opts.frame_opts.snip_edges = False
opts.mel_opts.debug_mel = False
online_fbank = kaldifeat.OnlineFbank(opts)
online_fbank.accept_waveform(sampling_rate, samples)
opts = knf.FbankOptions()
opts.frame_opts.dither = 0
opts.mel_opts.num_bins = 80
opts.frame_opts.snip_edges = False
opts.mel_opts.debug_mel = False
fbank = knf.OnlineFbank(opts)
fbank.accept_waveform(sampling_rate, samples.tolist())
assert online_fbank.num_frames_ready == fbank.num_frames_ready
for i in range(fbank.num_frames_ready):
f1 = online_fbank.get_frame(i)
f2 = torch.from_numpy(fbank.get_frame(i))
assert torch.allclose(f1, f2, atol=1e-3), (i, (f1 - f2).abs().max())
if __name__ == "__main__":
torch.manual_seed(20220825)
main()
print("success")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for kaldi_native_fbank-1.18.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 701040fbc827435ef59362032e753177c774d67060148f568e60a4b7a3578563 |
|
MD5 | ac258a8fe8b9a2ba5e4c86419abeedaf |
|
BLAKE2b-256 | 7a4a921cb349b1ae143e12277ce4078258337ebe78dff777aa2bcbe480daf089 |
Hashes for kaldi_native_fbank-1.18.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6fadf311e8c847fe1fcaea1c045f857f86a3667fafdd58543a80dbf4cdd4675 |
|
MD5 | 8f6e1a2d73dd08806b7f23a0e973aed7 |
|
BLAKE2b-256 | 1b469c34f709fc7c03d5ef91f210203cf0b50e5c8954ac65b1441313ff31985c |
Hashes for kaldi_native_fbank-1.18.2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09ec87ecf15e3098975fb922842b8981805275fcd6af0cff3f6c78ebc3ca3bd9 |
|
MD5 | f687285ccbfdd064a64a04321baefb89 |
|
BLAKE2b-256 | a2a80476570ad91aff9276ff171083f01a29a13e6361d476fcb133c0c34f51b3 |
Hashes for kaldi_native_fbank-1.18.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e53ac1d5e243d97730a2159d91c75ac03ec18cb471704dcdfd570435d422da2 |
|
MD5 | be94ce22ba1b396dbd4a1d83b7feb360 |
|
BLAKE2b-256 | 2a9e6e481f7d41956934137da0e61572b264a83e2dba1e731cc5f9691a7c9229 |
Hashes for kaldi_native_fbank-1.18.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9084ebb9289001157615af03e33759730b3faf5895872fe33db3924a04750da |
|
MD5 | 782acea5fc0ae2ad7b25079d679d05a0 |
|
BLAKE2b-256 | ca6c983c8e39a4982a2bf2f30f58301b927dbea2223de75ca3f3e35c830878ff |
Hashes for kaldi_native_fbank-1.18.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 778940564206e1bc38c58b8b9c27dc74233a5ec8bae5e7fa5c4b48dd7f2b5fe8 |
|
MD5 | 67b5c7d31872d1f674a65bf75618fdd2 |
|
BLAKE2b-256 | 634317e67cff1e8f4e57713f0ce497e75a03877946515eea355b607ebfc595d2 |
Hashes for kaldi_native_fbank-1.18.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92b534bc33e4d64a4a1675e5f9d2e641b7f1921f9479373f56dd51760af120ae |
|
MD5 | 78887050ea2ae80c8d3e88864f73c0f1 |
|
BLAKE2b-256 | d7a2e377df7dc0ce9b932138934021a20603412c3198cced4a3eb6dd7743ecf6 |
Hashes for kaldi_native_fbank-1.18.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 627583d0fe597a297b7ac4687abca2e76e64c77f016f9419fc9c8fccd86e5f26 |
|
MD5 | 294d8f4d780f587defe3789fe9c74646 |
|
BLAKE2b-256 | 5263a1f4c06238f9a279f2e964880119f380f70d256ca4ff8aeca61a14fbf983 |
Hashes for kaldi_native_fbank-1.18.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e8c915e15c3a51b5129b44cb9127d4bf51d72c030277b3f223b14c41df93d2 |
|
MD5 | 9f8ba2563c96bf8e9171105b72f21a17 |
|
BLAKE2b-256 | b09a095674d986740efe7076099a136045d3088f2952fc03fd0d01ee02f79d72 |