Skip to content

Instantly share code, notes, and snippets.

@oplatek
Last active August 1, 2017 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oplatek/7180425 to your computer and use it in GitHub Desktop.
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
#!/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
@byjangkr
Copy link

byjangkr commented Aug 1, 2017

Thank you. Your script has been a great help to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment