Package: pydrobert-kaldi
pydrobert-kaldiSomeKaldibindings for Python. I started this project
because I wanted to seamlessly incorporateKaldi's I/O
mechanisminto the gamut of Python-based
data science packages (e.g. Theano, Tensorflow, CNTK, PyTorch, etc.). The code
base is expanding to wrap more of Kaldi's feature processing and mathematical
functions, but is unlikely to include modelling or decoding.Eventually, I plan on adding hooks for Kaldi audio features and pre-/post-
processing. However, I have no plans on porting any code involving modelling or
decoding.This is student-driven code, so don't expect a stable API. I'll try to use
semantic versioning, but the best way to keep functionality stable is by
forking.DocumentationLatestInput/OutputMost I/O can be performed with thepydrobert.kaldi.io.openfunction:frompydrobert.kaldiimportiowithio.open('scp:foo.scp','bm')asf:formatrixinf:...openis a factory function that determines the appropriate underlying stream
to open, much like Python's built-inopen. The data types we can read (here,
aBaseMatrix) are listed inpydrobert.kaldi.io.enums.KaldiDataType. Big
data types, like matrices and vectors, are piped into Numpy arrays. Passing an
extended filename  (e.g. paths to files on discs,'-'for stdin/stdout,'gzip -c a.ark.gz |', etc.) opens a stream from which data types can be read
one-by-one and in the order they were written. Alternatively, prepending the
extended filename with'ark[,[option_a[,option_b...]]:'or'scp[,...]:'and
specifying a data type allows one to open a Kaldi table for iterator-like
sequential reading (mode='r'), dict-like random access reading (mode='r+'),
or writing (mode='w'). For more information on the open function, consult the
docstring.The submodulepydrobert.kaldi.io.corpuscontains useful wrappers around Kaldi
I/O to serve up batches of data to, say, a neural network:train=ShuffledData('scp:feats.scp','scp:labels.scp',batch_size=10)forfeat_batch,label_batchintrain:...Logging and CLIBy default, Kaldi error, warning, and critical messages are piped to standard
error. Thepydrobert.kaldi.loggingsubmodule provides hooks into python's
native logging interface: theloggingmodule. The :class:KaldiLoggercan
handle stack traces from Kaldi C++ code, and there are a variety of decorators
to finagle the kaldi logging patterns to python logging patterns, or vice
versa.You'd likely want to explicitly handle logging when creating new kaldi-style
commands for command line.pydrobert.kaldi.io.argparseprovides
:class:KaldiParser, an :class:ArgumentParsertailored to Kaldi
inputs/outputs. It is used by a few command-line entry points added by this
package. See theCommand-Line
Interfacepage for
details.InstallationPrepackaged binaries of tagged versions ofpydrobert-kaldiare available for
most 64-bit platforms (Windows, Glibc Linux, OSX) and most active Python
versions (3.7-3.11) on bothcondaandPyPI.To install viacondacondainstall-csdrobertpydrobert-kaldiAconda-forgeversion is TBD.To install viaPyPIpipinstallpydrobert-kaldiYou can also try building the cutting-edge version. To do so, you'll need to
first installSWIG 4.0and an appropriate C++
compiler, thenpipinstallgit+https://github.com/sdrobert/pydrobert-kaldi.gitThe current version does not require a BLAS install, though it likely will in
the future as more is wrapped.LicenseThis code is licensed under Apache 2.0.Code found under thesrc/directory has been primarily copied from Kaldi.setup.pyis also strongly influenced by Kaldi's build configuration. Kaldi is
also covered by the Apache 2.0 license; its specific license file was copied
intosrc/COPYING_Kaldi_Projectto live among its fellows.How to CitePlease see thepydrobert pagefor more
details.