Commit 2bfc6292 authored by Dan Povey's avatar Dan Povey
Browse files

Various minor script fixes and extensions; minor code fixes; make...

Various minor script fixes and extensions; minor code fixes; make sgmm-latgen-faster accept FST input for lattice rescoring.

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@626 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent b2cf6f18
......@@ -116,7 +116,7 @@ steps/train_lda_mllt_sat.sh --num-jobs 30 --cmd "$train_cmd" \
4000 150000 data/train_nodup data/lang exp/tri4a_ali_all_nodup exp/tri5a
scripts/mkgraph.sh data/lang_test exp/tri5a exp/tri5a/graph
scripts/decode.sh -l data/lang_test --num-jobs 10 --cmd "$decode_cmd" \
scripts/decode.sh -l data/lang_test --num-jobs 30 --cmd "$decode_cmd" \
steps/decode_lda_mllt_sat.sh exp/tri5a/graph data/eval2000 exp/tri5a/decode_eval2000
# Align the 5a system; we'll train an SGMM system on top of
......@@ -128,10 +128,19 @@ steps/train_ubm_lda_etc.sh --num-jobs 30 --cmd "$train_cmd" \
700 data/train_nodup data/lang exp/tri5a_ali_all_nodup exp/ubm6a
steps/train_sgmm_lda_etc.sh --num-jobs 30 --cmd "$train_cmd" \
4500 40000 41 40 data/train_nodup data/lang exp/tri5a_ali_all_nodup exp/ubm6a/final.ubm exp/sgmm6a
scripts/mkgraph.sh data/lang_test_tgpr exp/sgmm6a exp/sgmm6a/graph_tgpr
scripts/mkgraph.sh data/lang_test exp/sgmm6a exp/sgmm6a/graph
# have to match num-jobs with 5a decode.
scripts/decode.sh --num-jobs 10 --cmd "$decode_cmd" steps/decode_sgmm_lda_etc.sh \
exp/sgmm6a/graph_tgpr data/eval2000 exp/sgmm6a/decode_eval2000 exp/tri5a/decode_eval2000
scripts/decode.sh -l data/lang_test --num-jobs 30 --cmd "$decode_cmd" steps/decode_sgmm_lda_etc.sh \
exp/sgmm6a/graph data/eval2000 exp/sgmm6a/decode_eval2000 exp/tri5a/decode_eval2000
# with wider beams [didn't help]... this script not in repository
#scripts/decode.sh -l data/lang_test --num-jobs 30 --cmd "$decode_cmd" steps/decode_sgmm_lda_etc_w.sh \
# exp/sgmm6a/graph data/eval2000 exp/sgmm6a/decode_eval2000_w exp/tri5a/decode_eval2000
# This decoding script doesn't do a full re-decoding but is limited to the lattices
# from the baseline decoding.
scripts/decode.sh -l data/lang_test --num-jobs 30 --cmd "$decode_cmd" steps/decode_sgmm_lda_etc_fromlats.sh \
data/lang_test data/eval2000 exp/sgmm6a/decode_eval2000_fromlats exp/tri5a/decode_eval2000
for x in exp/*/decode_*; do [ -d $x ] && grep Mean $x/score_*/*.sys | scripts/best_wer.sh; done
\ No newline at end of file
for x in exp/*/decode_*; do [ -d $x ] && grep Mean $x/score_*/*.sys | scripts/best_wer.sh; done
......@@ -148,6 +148,9 @@ scripts/lmrescore.sh --cmd "$decode_cmd" data/lang_test_tgpr/ data/lang_test_tg/
# with the experiments above we do it with the pruned one.
scripts/decode.sh --cmd "$decode_cmd" steps/decode_lda_mllt_fromlats.sh data/lang_test_tgpr data/test_dev93 exp/tri2b/decode_tgpr_dev93_fromlats exp/tri2a/decode_tgpr_dev93
#Try with no transition probs-- this seemed to help for Swbd. Helps ~0.1% here. Script not checked in.
#scripts/decode.sh --cmd "$decode_cmd" steps/decode_lda_mllt_fromlats_notrans.sh data/lang_test_tgpr data/test_dev93 exp/tri2b/decode_tgpr_dev93_fromlats_notrans exp/tri2a/decode_tgpr_dev93
# Align tri2b system with si84 data.
steps/align_lda_mllt.sh --num-jobs 10 --cmd "$train_cmd" \
--use-graphs data/train_si84 data/lang exp/tri2b exp/tri2b_ali_si84
......@@ -228,7 +231,11 @@ steps/train_ubm_lda_etc.sh --num-jobs 10 --cmd "$train_cmd" \
steps/train_sgmm_lda_etc.sh --num-jobs 10 --cmd "$train_cmd" \
3500 10000 41 40 data/train_si84 data/lang exp/tri2b_ali_si84 exp/ubm3c/final.ubm exp/sgmm3c
scripts/mkgraph.sh data/lang_test_tgpr exp/sgmm3c exp/sgmm3c/graph_tgpr
scripts/decode.sh --cmd "$decode_cmd" steps/decode_sgmm_lda_etc.sh exp/sgmm3c/graph_tgpr data/test_dev93 exp/sgmm3c/decode_tgpr_dev93
scripts/decode.sh --cmd "$decode_cmd" steps/decode_sgmm_lda_etc.sh exp/sgmm3c/graph_tgpr \
data/test_dev93 exp/sgmm3c/decode_tgpr_dev93
# Decoding via lattice rescoring of lats from regular model. [ a bit worse].
scripts/decode.sh --cmd "$decode_cmd" steps/decode_sgmm_lda_etc_fromlats.sh data/lang_test_tgpr \
data/test_dev93 exp/sgmm3c/decode_tgpr_dev93_fromlats exp/tri2b/decode_tgpr_dev93
# Train SGMM system on top of LDA+MLLT+SAT.
......@@ -283,8 +290,14 @@ scripts/lmrescore.sh --cmd "$decode_cmd" data/lang_test_bd_tgpr data/lang_test_b
scripts/lmrescore.sh --cmd "$decode_cmd" data/lang_test_bd_tgpr data/lang_test_bd_tg \
data/test_eval92 exp/sgmm4c/decode_bd_tgpr_eval92 exp/sgmm4c/decode_bd_tgpr_eval92_tg
# Decode sgmm4c with the "big-dict" decoding graph; here, we avoid doing a full
# re-decoding but limit ourselves from the lattices from the "big-dict" decoding
# of exp/tri3b. Note that these results are not quite comparable to those
# above because we use the better, "big-dict" decoding of tri3b. We go direct to
# 4-gram.
scripts/decode.sh --cmd "$decode_cmd" steps/decode_sgmm_lda_etc_fromlats.sh \
data/lang_test_bd_fg data/test_eval92 exp/sgmm4c/decode_bd_fg_eval92_fromlats \
exp/tri3b/decode_bd_tgpr_eval92
# Getting results:
# for x in exp/*/decode*; do [ -d $x ] && grep WER $x/wer_* | scripts/best_wer.sh; done
......@@ -112,11 +112,19 @@ if ($errmsgs =~ m/containes/) { # the error message "range_list containes no ele
}
print STDERR "Command writing to $logfile failed; trying again\n";
system "mv $logfile $logfile.bak";
system "mv $logfile $logfile.bak.1";
system "$qsub_cmd";
if ($? == 0) {
exit(0);
} else {
print STDERR "Command writing to $logfile failed second time. Command is in $shfile\n";
exit(1);
}
print STDERR "Command writing to $logfile failed; trying one last time\n";
system "mv $logfile $logfile.bak.2";
system "$qsub_cmd";
if ($? == 0) {
exit(0);
}
print STDERR "Command writing to $logfile failed on the third time. Command is in $shfile\n";
exit(1);
......@@ -54,7 +54,7 @@ for group in "9 10 11" "12 13 14" "15 16"; do # do the rescoring in batches of u
prons-to-wordali ark:- \
"ark:ali-to-phones --write-lengths $model 'ark:gunzip -c $dir/score_${inv_acwt}/ali.gz|' ark,t:- |" ark,t:- | \
scripts/wali_to_ctm.sh - $lang/words.txt $data/segments | grep -v -E '\[NOISE|LAUGHTER|VOCALIZED-NOISE\]' | \
grep -v -E '<UNK>' ) > $dir/score_${inv_acwt}/$name.ctm 2>$dir/score_${inv_acwt}/log && \
grep -v -E '<UNK>|%HESITATION' ) > $dir/score_${inv_acwt}/$name.ctm 2>$dir/score_${inv_acwt}/log && \
echo "score_lats_ctm.sh: error generating ctm, see $dir/score_${inv_acwt}/log" && exit 1;
! $hubscr -V -l english -h hub5 -g $data/glm -r $data/stm $dir/score_${inv_acwt}/${name}.ctm \
......
......@@ -30,10 +30,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 3 ]; then
......
......@@ -33,10 +33,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 3 ]; then
......
......@@ -33,10 +33,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 3 ]; then
......
......@@ -28,10 +28,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 4 ]; then
......
......@@ -30,10 +30,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 3 ]; then
......
......@@ -30,10 +30,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 5 ]; then
......
......@@ -30,10 +30,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 5 ]; then
......
......@@ -49,10 +49,6 @@ if [ "$1" == "-j" ]; then
numjobs=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $numjobs ]; then
echo "Invalid job number, $jobid >= $numjobs";
exit 1;
fi
fi
if [ $# != 4 ]; then
......@@ -90,14 +86,15 @@ done
# CMVN stats-- we make them part of a pipe.
feats="ark:compute-cmvn-stats --spk2utt=ark:$mydata/spk2utt scp:$mydata/feats.scp ark:- | apply-cmvn --norm-vars=false --utt2spk=ark:$mydata/utt2spk ark:- scp:$mydata/feats.scp ark:- | splice-feats ark:- ark:- | transform-feats $srcdir/final.mat ark:- ark:- |"
grep \# $lang/phones_disambig.txt | awk '{print $2}' > $dir/disambig.list
# Note: we limit the batch-size to 75 to prevent memory blowup.
# In the normal decoding scripts there are only about 50 utterances
# per batch anyway.
( lattice-to-fst "ark:gunzip -c $olddir/lat.$jobid.gz|" ark:- | \
fsttablecompose "fstproject --project_output=true $lang/G.fst | fstarcsort |" ark:- ark:- | \
fstdeterminizestar ark:- ark:- | \
compile-train-graphs-fsts --read-disambig-syms=$dir/disambig.list $scale_opts \
$srcdir/tree $srcdir/final.mdl $lang/L_disambig.fst ark:- ark:- | \
compile-train-graphs-fsts --read-disambig-syms="grep \# $lang/phones_disambig.txt | awk '{print \$2}'|" \
--batch-size=75 $scale_opts $srcdir/tree $srcdir/final.mdl $lang/L_disambig.fst ark:- ark:- | \
gmm-latgen-faster --max-active=7000 --beam=20.0 --lattice-beam=7.0 --acoustic-scale=0.083333 \
--allow-partial=true --word-symbol-table=$lang/words.txt \
$srcdir/final.mdl ark:- "$feats" "ark:|gzip -c > $dir/lat.$jobid.gz" ) \
......
......@@ -16,7 +16,7 @@
# limitations under the License.
# Decoding script that works with an SGMM model... note: this script
# assumes you have speaker vectors [for no vectors, see decode_sgmm_novec_lda_etc.sh,
# assumes you are using speaker vectors [for no vectors, see decode_sgmm_novec_lda_etc.sh,
# if it exists already].
# It works on top of LDA + [something] features; if this includes
# speaker-specific transforms, you have to provide an "old" decoding directory
......@@ -32,10 +32,6 @@ if [ "$1" == "-j" ]; then
nj=$1;
jobid=$2;
shift; shift;
if [ $jobid -ge $nj ]; then
echo "Invalid job number, $jobid >= $nj";
exit 1;
fi
fi
if [ $# -lt 3 -o $# -gt 4 ]; then
......@@ -50,7 +46,7 @@ data=$2
dir=$3
olddir=$4
acwt=0.1 # Just a default value, used for adaptation and beam-pruning..
silphonelist=`cat $graphdir/silphones.csl`
silphonelist=`cat $graphdir/silphones.csl` || exit 1
srcdir=`dirname $dir`; # Assume model directory one level up from decoding directory.
......
#!/bin/bash
# Decoding script that works with an SGMM model; uses the word information in
# the lattices in the base decoding directory, which must be provided
# [note: if this directory contains transforms, we'll use this: thus, for
# system where the SGMM is built on top of speaker adapted features,
# the command-line syntax would be the same as decode_sgmm_lda_etc.sh, which
# looks for the transforms in that directory, if you provide it.
# This script works on top of LDA + [something] features.
# Note: the num-jobs in the base-directory must be the same as in this one.
if [ -f ./path.sh ]; then . ./path.sh; fi
nj=1
jobid=0
scale_opts="--transition-scale=1.0 --self-loop-scale=0.1"
if [ "$1" == "-j" ]; then
shift;
nj=$1;
jobid=$2;
shift; shift;
fi
if [ $# -ne 4 ]; then
echo "Usage: steps/decode_sgmm_lda_etc_fromlats.sh [-j num-jobs job-number] <lang-dir> <data-dir> <decode-dir> <old-decode-dir>"
echo " e.g.: steps/decode_sgmm_lda_etc_fromlats.sh -j 10 0 data/lang_test_tgpr data/test_dev93 exp/sgmm3c/decode_dev93_tgpr_fromlats exp/tri2b/decode_dev93_tgpr"
exit 1;
fi
lang=$1
data=$2
dir=$3
olddir=$4
acwt=0.1 # Just a default value, used for adaptation and beam-pruning..
silphonelist=`cat $lang/silphones.csl` || exit 1
srcdir=`dirname $dir`; # Assume model directory one level up from decoding directory.
mkdir -p $dir
if [ $nj -gt 1 ]; then
mydata=$data/split$nj/$jobid
else
mydata=$data
fi
requirements="$mydata/feats.scp $srcdir/final.mdl $srcdir/final.mat $srcdir/final.alimdl $lang/G.fst $lang/L_disambig.fst $lang/phones_disambig.txt"
for f in $requirements; do
if [ ! -f $f ]; then
echo "decode_sgmm_lda_etc.sh: no such file $f";
exit 1;
fi
done
[ ! -d "$olddir" ] && echo "Expected $olddir to be a directory" && exit 1;
[ ! -f $olddir/lat.$jobid.gz ] && echo No such file $olddir/lat.$jobid.gz && exit 1;
feats="ark:compute-cmvn-stats --spk2utt=ark:$mydata/spk2utt scp:$mydata/feats.scp ark:- | apply-cmvn --norm-vars=false --utt2spk=ark:$mydata/utt2spk ark:- scp:$mydata/feats.scp ark:- | splice-feats ark:- ark:- | transform-feats $srcdir/final.mat ark:- ark:- |"
[ -f $olddir/$jobid.trans ] && feats="$feats transform-feats --utt2spk=ark:$mydata/utt2spk ark:$olddir/$jobid.trans ark:- ark:- |"
# Do Gaussian selection, since we'll have two decoding passes and don't want to redo this.
# Note: it doesn't make a difference if we use final.mdl or final.alimdl, they have the
# same UBM.
sgmm-gselect $srcdir/final.mdl "$feats" "ark:|gzip -c > $dir/$jobid.gselect.gz" \
2>$dir/gselect$jobid.log || exit 1;
gselect_opt="--gselect=ark:gunzip -c $dir/$jobid.gselect.gz|"
# Generate FSTs to search, based on the word sequences in the lattices in the base
# directory, and then decode these to make state-level lattices.
#grep \# $lang/phones_disambig.txt | awk '{print $2}' > $dir/disambig.list
# Generate a state-level lattice for rescoring, with the alignment model and no speaker
# vectors. Instead of using the decoding graph, we create lattices and rescore them.
( lattice-to-fst "ark:gunzip -c $olddir/lat.$jobid.gz|" ark:- | \
fsttablecompose "fstproject --project_output=true $lang/G.fst | fstarcsort |" ark:- ark:- | \
fstdeterminizestar ark:- ark:- | \
compile-train-graphs-fsts --read-disambig-syms="grep \# $lang/phones_disambig.txt | awk '{print \$2}'|" \
$scale_opts $srcdir/tree $srcdir/final.mdl $lang/L_disambig.fst ark:- ark:- | \
sgmm-latgen-faster --max-active=7000 --beam=25.0 --lattice-beam=7.0 --acoustic-scale=$acwt \
--determinize-lattice=false --allow-partial=true --word-symbol-table=$lang/words.txt \
"$gselect_opt" $srcdir/final.alimdl ark:- "$feats" "ark:|gzip -c > $dir/pre_lat.$jobid.gz" ) \
2> $dir/decode_pass1.$jobid.log || exit 1;
( lattice-determinize --acoustic-scale=$acwt --prune=true --beam=4.0 \
"ark:gunzip -c $dir/pre_lat.$jobid.gz|" ark:- | \
lattice-to-post --acoustic-scale=$acwt ark:- ark:- | \
weight-silence-post 0.0 $silphonelist $srcdir/final.alimdl ark:- ark:- | \
sgmm-post-to-gpost "$gselect_opt" $srcdir/final.alimdl "$feats" ark:- ark:- | \
sgmm-est-spkvecs-gpost --spk2utt=ark:$mydata/spk2utt \
$srcdir/final.mdl "$feats" ark:- "ark:$dir/$jobid.vecs" ) \
2> $dir/vecs.$jobid.log || exit 1;
# Now rescore the state-level lattices with the adapted features and the
# corresponding model. Prune and determinize the lattices to limit
# their size.
sgmm-rescore-lattice "$gselect_opt" --utt2spk=ark:$mydata/utt2spk --spk-vecs=ark:$dir/$jobid.vecs \
$srcdir/final.mdl "ark:gunzip -c $dir/pre_lat.$jobid.gz|" "$feats" \
"ark:|lattice-determinize --acoustic-scale=$acwt --prune=true --beam=6.0 ark:- ark:- | gzip -c > $dir/lat.$jobid.gz" \
2>$dir/rescore.$jobid.log || exit 1;
rm $dir/pre_lat.$jobid.gz
# The top-level decoding script will rescore "lat.$jobid.gz" to get the final output.
......@@ -16,7 +16,8 @@
nj=4
cmd=scripts/run.pl
for x in 1 2; do
stage=-5
for x in `seq 3`; do
if [ $1 == "--num-jobs" ]; then
shift
nj=$1
......@@ -27,6 +28,11 @@ for x in 1 2; do
cmd=$1
shift
fi
if [ $1 == "--stage" ]; then # stage to start training from, typically same as the iter you have a .mdl file;
shift # in case it failed part-way.
stage=$1
shift
fi
done
# Trains SGMM on top of LDA plus [something] features, where the [something]
......@@ -103,100 +109,113 @@ if [ ! -f $ubm ]; then
exit 1;
fi
# Get stats to build the tree.
echo "Accumulating tree stats"
$cmd $dir/log/acc_tree.log \
acc-tree-stats --ci-phones=$silphonelist $alidir/final.mdl "$feats" "ark:gunzip -c $alidir/*ali.gz|" \
$dir/treeacc || exit 1;
if [ $stage -le -5 ]; then
# Get stats to build the tree.
echo "Accumulating tree stats"
$cmd $dir/log/acc_tree.log \
acc-tree-stats --ci-phones=$silphonelist $alidir/final.mdl "$feats" "ark:gunzip -c $alidir/*ali.gz|" \
$dir/treeacc || exit 1;
fi
echo "Computing questions for tree clustering"
# preparing questions, roots file...
sym2int.pl $lang/phones.txt $lang/phonesets_cluster.txt > $dir/phonesets.txt || exit 1;
cluster-phones $dir/treeacc $dir/phonesets.txt $dir/questions.txt 2> $dir/log/questions.log || exit 1;
sym2int.pl $lang/phones.txt $lang/extra_questions.txt >> $dir/questions.txt
compile-questions $lang/topo $dir/questions.txt $dir/questions.qst 2>$dir/log/compile_questions.log || exit 1;
sym2int.pl --ignore-oov $lang/phones.txt $lang/roots.txt > $dir/roots.txt
echo "Building tree"
$cmd $dir/log/train_tree.log \
build-tree --verbose=1 --max-leaves=$numleaves \
$dir/treeacc $dir/roots.txt \
$dir/questions.qst $lang/topo $dir/tree || exit 1;
if [ $stage -le -4 ]; then
echo "Computing questions for tree clustering"
# preparing questions, roots file...
sym2int.pl $lang/phones.txt $lang/phonesets_cluster.txt > $dir/phonesets.txt || exit 1;
cluster-phones $dir/treeacc $dir/phonesets.txt $dir/questions.txt 2> $dir/log/questions.log || exit 1;
sym2int.pl $lang/phones.txt $lang/extra_questions.txt >> $dir/questions.txt
compile-questions $lang/topo $dir/questions.txt $dir/questions.qst 2>$dir/log/compile_questions.log || exit 1;
sym2int.pl --ignore-oov $lang/phones.txt $lang/roots.txt > $dir/roots.txt
echo "Building tree"
$cmd $dir/log/train_tree.log \
build-tree --verbose=1 --max-leaves=$numleaves \
$dir/treeacc $dir/roots.txt \
$dir/questions.qst $lang/topo $dir/tree || exit 1;
# the sgmm-init program accepts a GMM, so we just create a temporary GMM "0.gmm"
# the sgmm-init program accepts a GMM, so we just create a temporary GMM "0.gmm"
$cmd $dir/log/init_gmm.log \
gmm-init-model --write-occs=$dir/0.occs \
$dir/tree $dir/treeacc $lang/topo $dir/0.gmm || exit 1;
$cmd $dir/log/init_gmm.log \
gmm-init-model --write-occs=$dir/0.occs \
$dir/tree $dir/treeacc $lang/topo $dir/0.gmm || exit 1;
# The next line is a bit of a hack to work out the feature dim. The program
# feat-to-len returns the #rows of each matrix, which for the transform matrix,
# is the feature dim.
featdim=`feat-to-len "scp:echo foo $alidir/final.mat|" ark,t:- 2>/dev/null | awk '{print $2}'`
# The next line is a bit of a hack to work out the feature dim. The program
# feat-to-len returns the #rows of each matrix, which for the transform matrix,
# is the feature dim.
featdim=`feat-to-len "scp:echo foo $alidir/final.mat|" ark,t:- 2>/dev/null | awk '{print $2}'`
# Note: if phndim and/or spkdim are higher than you can initialize with,
# sgmm-init will just make them as high as it can (later we'll increase)
$cmd $dir/log/init_sgmm.log \
sgmm-init --phn-space-dim=$phndim --spk-space-dim=$spkdim $lang/topo $dir/tree $ubm \
$dir/0.mdl || exit 1;
fi
# Note: if phndim and/or spkdim are higher than you can initialize with,
# sgmm-init will just make them as high as it can (later we'll increase)
rm $dir/.error 2>/dev/null
$cmd $dir/log/init_sgmm.log \
sgmm-init --phn-space-dim=$phndim --spk-space-dim=$spkdim $lang/topo $dir/tree $ubm \
$dir/0.mdl || exit 1;
if [ $stage -le -3 ]; then
echo "Doing Gaussian selection"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/gselect$n.log \
sgmm-gselect $dir/0.mdl "${featspart[$n]}" "ark,t:|gzip -c > $dir/$n.gselect.gz" \
|| touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error doing Gaussian selection" && exit 1;
fi
rm $dir/.error 2>/dev/null
echo "Doing Gaussian selection"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/gselect$n.log \
sgmm-gselect $dir/0.mdl "${featspart[$n]}" "ark,t:|gzip -c > $dir/$n.gselect.gz" \
|| touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error doing Gaussian selection" && exit 1;
echo "Converting alignments" # don't bother parallelizing; very fast.
for n in `get_splits.pl $nj`; do
convert-ali $alidir/final.mdl $dir/0.mdl $dir/tree "ark:gunzip -c $alidir/$n.ali.gz|" \
"ark:|gzip -c >$dir/$n.ali.gz" 2>$dir/log/convert$n.log
done
if [ $stage -le -2 ]; then
echo "Converting alignments" # don't bother parallelizing; very fast.
for n in `get_splits.pl $nj`; do
convert-ali $alidir/final.mdl $dir/0.mdl $dir/tree "ark:gunzip -c $alidir/$n.ali.gz|" \
"ark:|gzip -c >$dir/$n.ali.gz" 2>$dir/log/convert$n.log
done
fi
echo "Compiling training graphs"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/compile_graphs$n.log \
compile-train-graphs $dir/tree $dir/0.mdl $lang/L.fst \
"ark:sym2int.pl --map-oov \"$oov_sym\" --ignore-first-field $lang/words.txt < $data/split$nj/$n/text |" \
"ark:|gzip -c >$dir/$n.fsts.gz" || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error compiling training graphs" && exit 1;
if [ $stage -le -1 ]; then
echo "Compiling training graphs"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/compile_graphs$n.log \
compile-train-graphs $dir/tree $dir/0.mdl $lang/L.fst \
"ark:sym2int.pl --map-oov \"$oov_sym\" --ignore-first-field $lang/words.txt < $data/split$nj/$n/text |" \
"ark:|gzip -c >$dir/$n.fsts.gz" || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error compiling training graphs" && exit 1;
fi
x=0
while [ $x -lt $numiters ]; do
echo "Pass $x ... "
if echo $realign_iters | grep -w $x >/dev/null; then
echo "Aligning data"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/align.$x.$n.log \
sgmm-align-compiled ${spkvecs_opt[$n]} $scale_opts "${gselect_opt[$n]}" \
--utt2spk=ark:$data/split$nj/$n/utt2spk --beam=8 --retry-beam=40 \
$dir/$x.mdl "ark:gunzip -c $dir/$n.fsts.gz|" "${featspart[$n]}" \
"ark:|gzip -c >$dir/$n.ali.gz" || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error realigning data on iter $x" && exit 1;
if [ $stage -le $x ]; then
echo "Aligning data"
for n in `get_splits.pl $nj`; do
$cmd $dir/log/align.$x.$n.log \
sgmm-align-compiled ${spkvecs_opt[$n]} $scale_opts "${gselect_opt[$n]}" \
--utt2spk=ark:$data/split$nj/$n/utt2spk --beam=8 --retry-beam=40 \
$dir/$x.mdl "ark:gunzip -c $dir/$n.fsts.gz|" "${featspart[$n]}" \
"ark:|gzip -c >$dir/$n.ali.gz" || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error realigning data on iter $x" && exit 1;
fi
fi
if [ $spkdim -gt 0 ] && echo $spkvec_iters | grep -w $x >/dev/null; then
for n in `get_splits.pl $nj`; do
$cmd $dir/log/spkvecs.$x.$n.log \
ali-to-post "ark:gunzip -c $dir/$n.ali.gz|" ark:- \| \
weight-silence-post 0.01 $silphonelist $dir/$x.mdl ark:- ark:- \| \
sgmm-est-spkvecs --spk2utt=ark:$data/split$nj/$n/spk2utt \
${spkvecs_opt[$n]} "${gselect_opt[$n]}" \
--rand-prune=$randprune $dir/$x.mdl \
"${featspart[$n]}" ark,s,cs:- ark:$dir/tmp$n.vecs \
&& mv $dir/tmp$n.vecs $dir/$n.vecs || touch $dir/.error &
if [ $stage -le $x ]; then
$cmd $dir/log/spkvecs.$x.$n.log \
ali-to-post "ark:gunzip -c $dir/$n.ali.gz|" ark:- \| \
weight-silence-post 0.01 $silphonelist $dir/$x.mdl ark:- ark:- \| \
sgmm-est-spkvecs --spk2utt=ark:$data/split$nj/$n/spk2utt \
${spkvecs_opt[$n]} "${gselect_opt[$n]}" \
--rand-prune=$randprune $dir/$x.mdl \
"${featspart[$n]}" ark,s,cs:- ark:$dir/tmp$n.vecs \
&& mv $dir/tmp$n.vecs $dir/$n.vecs || touch $dir/.error &
fi
spkvecs_opt[$n]="--spk-vecs=ark:$dir/$n.vecs"
done
wait;
......@@ -211,28 +230,32 @@ while [ $x -lt $numiters ]; do
flags=vMwcS
fi
for n in `get_splits.pl $nj`; do
$cmd $dir/log/acc.$x.$n.log \
sgmm-acc-stats ${spkvecs_opt[$n]} --utt2spk=ark:$data/split$nj/$n/utt2spk \
--update-flags=$flags "${gselect_opt[$n]}" --rand-prune=$randprune \
$dir/$x.mdl "${featspart[$n]}" "ark,s,cs:ali-to-post 'ark:gunzip -c $dir/$n.ali.gz|' ark:-|" \
$dir/$x.$n.acc || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error accumulating stats on iter $x" && exit 1;
if [ $stage -le $x ]; then
for n in `get_splits.pl $nj`; do
$cmd $dir/log/acc.$x.$n.log \
sgmm-acc-stats ${spkvecs_opt[$n]} --utt2spk=ark:$data/split$nj/$n/utt2spk \
--update-flags=$flags "${gselect_opt[$n]}" --rand-prune=$randprune \
$dir/$x.mdl "${featspart[$n]}" "ark,s,cs:ali-to-post 'ark:gunzip -c $dir/$n.ali.gz|' ark:-|" \
$dir/$x.$n.acc || touch $dir/.error &
done
wait;
[ -f $dir/.error ] && echo "Error accumulating stats on iter $x" && exit 1;
fi
add_dim_opts=
if echo $add_dim_iters | grep -w $x >/dev/null; then
add_dim_opts="--increase-phn-dim=$phndim --increase-spk-dim=$spkdim"
fi