Skip to main content

Glue code connecting Kaldi data and Python.

Project description


'Glue' code connecting kaldi data and python.

Supported data types

  • vector (integer)
  • Vector (float, double)
  • Matrix (float, double)
  • Posterior (posteriors, nnet1 training targets, confusion networks, ...)


Reading feature scp example:
import kaldi_io
for key,mat in kaldi_io.read_mat_scp(file):
Writing feature ark to file/stream:
import kaldi_io
with open(ark_file,'wb') as f:
  for key,mat in dict.iteritems():
    kaldi_io.write_mat(f, mat, key=key)
Writing features as 'ark,scp' by pipeline with 'copy-feats':
import kaldi_io
ark_scp_output='ark:| copy-feats --compress=true ark:- ark,scp:data/feats2.ark,data/feats2.scp'
with kaldi_io.open_or_fd(ark_scp_output,'wb') as f:
  for key,mat in dict.iteritems():
    kaldi_io.write_mat(f, mat, key=key)


  • from pypi: python -m pip --user install kaldi_io
  • from sources:
    • git clone <kaldi-io-dir>
    • python install (default python)
  • for local development use: export PYTHONPATH=${PYTHONPATH}:<kaldi-io-dir> in $HOME/.bashrc

Note: it is recommended to set $KALDI_ROOT in your $HOME/.bashrc as export KALDI_ROOT=<some_kaldi_dir>, so you can read/write using pipes which contain kaldi binaries.


Apache License, Version 2.0 ('LICENSE-2.0.txt')


  • If you have an extension to share, please create a pull request.
  • For feedback and suggestions, please create a GitHub 'Issue' in the project.
  • For the positive reactions =) I am also reachable by email:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaldi_io-0.9.4.tar.gz (9.6 kB view hashes)

Uploaded source

Built Distribution

kaldi_io-0.9.4-py3-none-any.whl (14.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page