How to convert python numpy matrix to kaldi IO?

634 views
Skip to first unread message

xinq...@gmail.com

unread,
Feb 13, 2017, 6:37:59 AM2/13/17
to kaldi-help
Hi all,

    I've trained a CTC model with keras and language model(TLG.fst, which is like the miao's work). Now I wanna use python script to calculate the output of the LSTM net, and then decode with latgen_faster_mapped (or latgen_faster from miao' project).

   The problem is how to convert the numpy matrix from python script to the kaldi IO for the latgen_faster_mapped.


   with the reference of keras-kaldi, my shell script is as following:


   feats="ark,s,cs:nnet-forward.py exp/data/test_corpus.json exp/data/train_corpus.json exp/model_R7T9 |"

  $cmd JOB=1:$nj $dir/log/decode.JOB.log \
      latgen-faster --max-active=$max_active --beam=$beam --lattice-beam=$latbeam --acoustic-scale=$acwt --allow-partial=true --word-symbol-table=$graphdir/words.txt $graphdir/TLG.fst "$feats" "ark:|gzip -c > $dir/lat.JOB.gz" || exit 1;


  for the nnet-forward.py:(with python 2.7)

    arkOut = sys.stdout
    encoding = sys.getdefaultencoding()
    signal (SIGPIPE, SIG_DFL)
    ... ...
    for audio_file in datagen.test_audio_paths:
        uttId = audio_file.split("/")[-1]
        uttId = uttId.split(".")[0]
        featmat = datagen.featurize(audio_file)
        featmat = datagen.normalize(featmat)
        kaldiIO.writeUtterance(uttId, featmat, arkOut, encoding)


   but with the code above, it lets to no ending running. How can I fixed it?


Many thanks
Xin.q.

xinq...@gmail.com

unread,
Feb 13, 2017, 6:43:17 AM2/13/17
to kaldi-help
The kaldiIO.py is attached.

在 2017年2月13日星期一 UTC+8下午7:37:59,xinq...@gmail.com写道:
kaldiIO.py

Daniel Povey

unread,
Feb 13, 2017, 2:30:29 PM2/13/17
to kaldi-help
Firstly, I and others have spent a lot of time trying to get CTC to work, and the performance has always been quite a bit worse than the regular models.  Even Google is no longer claiming that CTC is better than regular models; they are getting better results with a 1-state topology and lower frame rate for regular models.

I'm not sure about the answer to your specific question as I don't use those specific libraries, but the kaldi text-form archive format for matrices is very simple and matlab-like; it's

utt1 [ 1 2 3
4 5 6
7 8 9 ]
utt2 [ 8 7 4
 ...


ans so on.  and kaldi programs can read this.


Dan


--
Go to http://kaldi-asr.org/forums.html find out how to join
---
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xinq...@gmail.com

unread,
Feb 13, 2017, 9:22:28 PM2/13/17
to kaldi-help, dpo...@gmail.com
Thanks Dan.
For so many papers about End-to-End ASR, we wanna compare the performance between end-to-end  and hybrid-system with own corpus.



在 2017年2月14日星期二 UTC+8上午3:30:29,Dan Povey写道:
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages