kaldi-io-for-python
kaldi-io-for-python copied to clipboard
Reading target (alignment) files
Hi, I was trying to use kaldi_io to import alignment files, but I could not find out how to do it, and if it's possible.
I ran the timit recipe and ended up with a number of ali.<n>.gz
files for example under the exp/mono_ali/
directory. I can convert those files from transition model IDs to PDF IDs with the command (for example):
ali-to-pdf exp/mono_ali/final.mdl "ark:gunzip -c exp/mono_ali/ali.1.gz|" ark,t:mono_ali.1.pdf.txt
The resulting file contains a line for each utterance, with utterance ID (for example faem0_si1392
) and then a list of integer identifiers of the states in the model for each frame in that utterance.
- Is there a way to import this file into python using kaldi_io?
- Is there a way to pipe the
ali-to-pdf
command when opening theali.1.gz
file, so that I don't need to run it separately?
Thank you! Giampiero
Dear Giampiero Salvi; Did you find a solution to this problem, because I face the same problem now.
Hi,
the solution is:
kaldi_io.read_ali_ark('ali-to-pdf exp/mono_ali/final.mdl "ark:gunzip -c exp/mono_ali/ali.1.gz|" ark:- |')
This will convert the alignment to PDF-id format and dump it in binary format to be read by your python on-the-fly...
If you already dumped the 'ASCII-text' alingments, this is your command:
kaldi_io.read_ali_ark('mono_ali.1.pdf.txt')
Let me know, if you experience any problems... Karel
Those will return generators that return (key, value)
tuples...
Dear Karel;
Thanks for your reply and your help. I will try and if I have any issues I will back to you if you don't mind.
Thanks a lot
On Tue, Feb 25, 2020 at 7:35 PM Karel Vesely [email protected] wrote:
Those will return generators that return (key, value) tuples...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vesis84/kaldi-io-for-python/issues/36?email_source=notifications&email_token=ANWBGBHFWZQ3PLVDQIK3XSLREVQG3A5CNFSM4I4WCOUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM47ROY#issuecomment-591001787, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWBGBBEVJBVN4PNFL4ZRETREVQG3ANCNFSM4I4WCOUA .
-- Mohamed Nabih Ali *Assistant **Lecturer * *Faculty of Computers and IT * Egyptian E-Learning University Ain Shams Center *Mail: [email protected] [email protected] * Mobile: +201285659213
Work: 02-33318417
@mnabihali
Maybe you are interested in kaldi pybind for the next generation kaldi.
We have wrapped kaldi io to Python. For example, to read alignment information,
you can use kaldi.read_vec_int
.
You can find an example usage here: https://github.com/kaldi-asr/kaldi/blob/pybind11/src/pybind/tests/test_io_util.py#L21
Note that it is on the pybind11
branch instead of the master
branch.
Thanks all, but another problem I want to read the kaldi featuers (feat.scp) and apply cmvn, utt2speak and delta features how can I do this with kaldi_io
Hi, you can do this by reading from a pipeline with "apply-cmvn" and "add-deltas" binaries in it. Look into GMM training scripts to see how the 'pipeline-string' looks like. Then you use this as filename when reading with 'kaldi-io-for-python'. Make sure that the 'pipeline-string' has '|' at the end.
Thanks Karel But when I run the full timit kaldi recipe I generate the fmllr features but its cmvn.ark files is not generated do you know why this happens?
On Thu, Mar 19, 2020, 12:10 Karel Vesely [email protected] wrote:
Hi, you can do this by reading from a pipeline with "apply-cmvn" and "add-deltas" binaries in it. Look into GMM training scripts to see how the 'pipeline-string' looks like. Then you use this as filename when reading with 'kaldi-io-for-python'. Make sure that the 'pipeline-string' has '|' at the end.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vesis84/kaldi-io-for-python/issues/36#issuecomment-601121429, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWBGBCPG5LUFAJ4ZS4Z7XTRIH4TLANCNFSM4I4WCOUA .
Hi, this happens because 'fmllr' features are already normalized from earlier stage of processing. So we don't do CMVN on top of them... (actually the 'power' of cmvn is already contained in 'fmllr', both are affine transforms of feature spaces: cmvn has a diagonal matrix, fmllr has a full matrix. however the way these two are estimated is very different...) K.