Last active
August 1, 2017 05:32
-
-
Save oplatek/7180425 to your computer and use it in GitHub Desktop.
DEPRECATED: There is show_lattice.sh based on this script
http://sourceforge.net/p/kaldi/code/HEAD/tree/trunk/egs/wsj/s5/utils/show_lattice.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# source: https://gist.github.com/oplatek/7180425 | |
# DEPRECATED: There is show_lattice.sh based on this script | |
# http://sourceforge.net/p/kaldi/code/HEAD/tree/trunk/egs/wsj/s5/utils/show_lattice.sh | |
# Kaldi recipes creates and stores lattices for several utterances into lat.1.gz files typically in #`exp/acoustic_model_name/decode` directory e.g. | |
#`exp/tri1/decode/lat1.gz`. | |
#This script takes two parameters: a) The gunzipped file b) the word symbol table (WST) typically stored in #`exp/acoustic_model_name/graph/words.txt` e.g. `exp/tri1/graph/words.txt` | |
# The script creates a pdf files displaying the words lattice for each of decoded utterance. | |
lat_gz=$1 | |
wst=$1 # word symbol table e.g. exp_name/graph/words.txt | |
format=svg # pdf ps | |
gunzip -c $lat_gz | lattice-copy ark:- ark,scp:foo.ark,foo.scp; cat foo.scp | \ | |
cut -d' ' -f2 | \ | |
while read ark ; do | |
echo dummy_id $ark | lattice-copy scp:- "scp:echo dummy_id $ark.lat|" | |
sed -i '1s/^/dummy_id /' $ark.lat | |
lattice-to-fst ark:$ark.lat ark:$ark.fst | |
sed -i '1s/^dummy_id //' $ark.fst | |
fstdraw --portrait=true --osymbols=$wst $ark.fst | \ | |
dot -T${format} > $ark.${format} ; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. Your script has been a great help to me.