Skip to content

Commit

Permalink
[scripts] Fix to analyze_alignments/lats.sh (double-counting) (#2573)
Browse files Browse the repository at this point in the history
If a single phoneme is aligned to the whole utterance, it is counted both as
`begin` and `end`, but is added to the total only once. This caused
`assert count >= 0` in analyze_phone_length_stats.py to fail. Now only the
`begin` is counted in that case.
  • Loading branch information
eginhard authored and danpovey committed Jul 25, 2018
1 parent 06604a8 commit 1616653
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion egs/wsj/s5/steps/diagnostic/analyze_alignments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $cmd JOB=1:$num_jobs $dir/log/get_phone_alignments.JOB.log \
set -o pipefail '&&' ali-to-phones --write-lengths=true "$model" \
"ark:gunzip -c $dir/ali.JOB.gz|" ark,t:- \| \
sed -E 's/^[^ ]+ //' \| \
awk 'BEGIN{FS=" ; "; OFS="\n";} {print "begin " $1; print "end " $NF; for (n=1;n<=NF;n++) print "all " $n; }' \| \
awk 'BEGIN{FS=" ; "; OFS="\n";} {print "begin " $1; if (NF>1) print "end " $NF; for (n=1;n<=NF;n++) print "all " $n; }' \| \
sort \| uniq -c \| gzip -c '>' $dir/phone_stats.JOB.gz || exit 1

if ! $cmd $dir/log/analyze_alignments.log \
Expand Down
2 changes: 1 addition & 1 deletion egs/wsj/s5/steps/diagnostic/analyze_lats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $cmd JOB=1:$num_jobs $dir/log/lattice_best_path.JOB.log \
$cmd JOB=1:$num_jobs $dir/log/get_lattice_stats.JOB.log \
ali-to-phones --write-lengths=true "$model" "ark:gunzip -c $dir/ali_tmp.JOB.gz|" ark,t:- \| \
sed -E 's/^[^ ]+ //' \| \
awk 'BEGIN{FS=" ; "; OFS="\n";} {print "begin " $1; print "end " $NF; for (n=1;n<=NF;n++) print "all " $n; }' \| \
awk 'BEGIN{FS=" ; "; OFS="\n";} {print "begin " $1; if (NF>1) print "end " $NF; for (n=1;n<=NF;n++) print "all " $n; }' \| \
sort \| uniq -c \| gzip -c '>' $dir/phone_stats.JOB.gz || exit 1


Expand Down

0 comments on commit 1616653

Please sign in to comment.