Commit 8ed96ecb authored by Dan Povey's avatar Dan Povey
Browse files

sandbox/dan2: script improvements RE nnet training; merge changes from trunk.

git-svn-id: https://svn.code.sf.net/p/kaldi/code/sandbox/dan2@2826 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parents d13a8ae8 0f7b0c36
#!/bin/bash
# Copyright 2012-2013 Johns Hopkins University (Author: Daniel Povey)
# Bagher BabaAli
# Apache 2.0
# To be run from .. (one directory up from here)
# This makes seven-dimension fundamental frequency variation features for some data/ directory.
# Begin configuration section.
nj=4
cmd=run.pl
stage=0
frame_len=0.01
sample_freq=8000
cleanup=true
# End configuration section.
echo "$0 $@" # Print the command line for logging
if [ -f path.sh ]; then . ./path.sh; fi
. parse_options.sh || exit 1;
if [ $# != 3 ]; then
echo "Usage: make_ffv.sh [options] <data-dir> <exp-dir> <path-to-ffvdir>";
echo "Makes seven dimensional features, based on fundumental frequency"
echo "variation extractor."
echo "E.g.: make_ffv.sh data/train_ffv exp/make_ffv_train plp/"
echo "Options: "
echo " --frame_len 0.01 # frame length "
echo " --sample_freq 8000 # sampling frequency "
echo " --nj <nj> # number of parallel jobs"
echo " --cmd (utils/run.pl|utils/queue.pl <queue opts>) # how to run jobs."
exit 1;
fi
data=$1
expdir=$2
ffvdir=$3
# make $ffvdir an absolute pathname.
ffvdir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $ffvdir ${PWD}`
# make $expdir an absolute pathname.
expdir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $expdir ${PWD}`
# use "name" as part of name of the archive.
name=`basename $data`
mkdir -p $ffvdir || exit 1;
mkdir -p $expdir/log || exit 1;
scp=$data/wav.scp
[ -s $KALDI_ROOT ] && KALDI_ROOT=../../..
ffv_pkg_dir=$KALDI_ROOT/tools/pitch_trackers/ffv-1.0.1
# make $ffv_pkg_dir an absolute pathname.
ffv_pkg_dir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:)\
{ $dir = "$pwd/$dir"; } print $dir; ' $ffv_pkg_dir ${PWD}`
ffv_script=$ffv_pkg_dir/run_ffv.sh
if [ ! -f $ffv_pkg_dir/ffv ]; then
echo "*Expecting the file $KALDI_ROOT/tools/pitch_trackers/ffv-1.0.1/ffv to exist"
echo "*cd to $KALDI_ROOT/tools/, and run extras/install_ffv.sh"
exit 1;
fi
basename=`basename $data`
wavdir=$ffvdir/temp_wav_$basename
mkdir -p $wavdir
if [ -f $data/segments ] || grep '|' $data/wav.scp >/dev/null; then
wav_scp=$expdir/wav.scp
cat $data/segments | awk -v dir=$wavdir \
'{key=$1; printf("%s %s/%s.wav\n", key, dir, key);}' \
> $wav_scp || exit 1;
if [ -f $data/segments ]; then
echo "$0 [info]: segments file exists: creating temporary wav files in $wavdir"
segments=$data/segments
else
# create a fake segments file that takes the whole file; this is an easy way
# to copy to static wav files. Note: probably this has not been tested.
cat $data/wav.scp | awk '{print $1, $1, 0.0, -1.0}' > $expdir/fake_segments
segments=$expdir/fake_segments
fi
if [ $stage -le 0 ]; then
echo "Extracting wav-file segments (or just converting to wav format)"
extract-segments scp:$data/wav.scp $segments scp:$wav_scp || exit 1;
fi
else
echo "No segments file exists, and wav scp is plain: using wav files as input."
wav_scp=$data/wav.scp
fi
wav_checked_scp=$expdir/wav_checked.scp
cat $wav_scp | \
perl -ane '@A=split; if (-f $A[1]) { print; }' >$wav_checked_scp
nl_orig=`cat $wav_scp | wc -l`
nl_new=`cat $wav_checked_scp | wc -l`
echo "After removing non-existent files, number of utterances decreased from $nl_orig to $nl_new";
[ $nl_new -eq 0 ] && exit 1;
# now $wav_scp is an scp file for the per-utterance wav files.
# Split up the wav files into multiple lists.
split_wavs=""
for ((n=1; n<=nj; n++)); do
split_wavs="$split_wavs $expdir/split_wavs.$n.scp"
done
utils/split_scp.pl $wav_checked_scp $split_wavs || exit 1;
# For each wav file, create corresponding temporary ffv file, in the
# format the ffv outputs: [ffv[0] ffv[1] ... ffv[6]]
temp_ffvdir=$ffvdir/temp_ffv_$basename
mkdir -p $temp_ffvdir
for ((n=1; n<=nj; n++)); do
mkdir -p $temp_ffvdir/$n
cat $expdir/split_wavs.$n.scp | awk -v pdir=$temp_ffvdir -v n=$n \
'{key=$1; wavfile=$2; printf("%s,%s/%s/%s.ffv\n", wavfile, pdir, n, key);}' \
> $expdir/ffv_flist.$n || exit 1
done
cat <<'EOF' > $ffv_script
#!/bin/bash
# script for execution of ffv
flen=0.01
sfreq=8000
. parse_options.sh || exit 1;
flist=$1
ffv_pkg_dir=$2
[ $# -ne 2 ] && echo "Usage: ffv.sh <ffv-flist-in> <ffv_pkg_dir>" && exit 1;
echo $flist
echo start running ffv
for wavefile in `cat $flist`; do
echo wavefile : $wavefile
input=`echo $wavefile | cut -f1 -d ','`
output=`echo $wavefile | cut -f2 -d ','`
echo input : $input and output : $output
if [ ! -f $output ]; then
echo "no such file $output"
fi
if [ ! -f $3/$basename.out ]; then
$ffv_pkg_dir/ffv --tfra $flen --fs $sfreq $input $output
fi
done
EOF
chmod +x $ffv_script
if [ $stage -le 1 ]; then
# Need to do this in director $ffv_pkg_dir as some of the things in its config
# are relative pathnames.
$cmd JOB=1:$nj $d/$expdir/log/ffv.JOB.log \
$ffv_script --flen=$frame_len --sfreq=$sample_freq \
$expdir/ffv_flist.JOB $ffv_pkg_dir || exit 1;
fi
# I don't want to put a separate script in svn just for this, so creating a temporary
# script file in the experimental directory. Quotes around 'EOF' disable any
# interpretation in the here-doc.
cat <<'EOF' > $expdir/convert.sh
#!/bin/bash
ffv_flist=$1
scpfile=$2
[ $# -ne 2 ] && echo "Usage: convert.sh <ffv-flist-in> <scpfile-out>" && exit 1;
for f in `cat $ffv_flist | cut -d, -f2`; do
g=`echo $f | sed s:.ffv$:.mat:`
if [ -f $f ]; then
cat $f | awk 'BEGIN{printf("[ "); } {print $1, $2, $3, $4, $5, $6, $7;} END{ print "]"; }' > $g
fi
done
cat $ffv_flist | cut -d, -f2 | \
perl -ane 'm:/([^/]+)\.ffv: || die "Bad line $_"; $key=$1; s/\.ffv$/\.mat/; print "$key $_";' > $scpfile
EOF
chmod +x $expdir/convert.sh
if [ $stage -le 2 ]; then
echo "Converting format from .ffv to .mat (kaldi-readable format)"
$cmd JOB=1:$nj $expdir/log/convert.JOB.log \
$expdir/convert.sh $expdir/ffv_flist.JOB $expdir/mat.scp.JOB || exit 1;
fi
if [ $stage -le 3 ]; then
echo "Doing final processing (interpolation, smoothing, etc.) on pitch features"
$cmd JOB=1:$nj $expdir/log/process.JOB.log \
copy-matrix scp,p:$expdir/mat.scp.JOB \
ark,scp:$ffvdir/${basename}_ffv.JOB.ark,$ffvdir/${basename}_ffv.JOB.scp || exit 1;
fi
echo "Creating $data/feats.scp"
for ((n=1; n<=nj; n++)); do cat $ffvdir/${basename}_ffv.$n.scp; done > $data/feats.scp
if $cleanup; then
echo "Removing temporary files"
rm -r $wavdir $temp_ffvdir
fi
echo "Finished extracting ffv features for $basename"
exit 0;
......@@ -126,16 +126,35 @@ fi
echo ---------------------------------------------------------------------
echo "Starting plp feature extraction for data/train in plp on" `date`
echo ---------------------------------------------------------------------
use_pitch=false
use_ffv=false
if [ ! -f data/train/.plp.done ]; then
if ! "$use_pitch"; then
steps/make_plp.sh --cmd "$train_cmd" --nj $decode_nj data/train exp/make_plp/train plp
else
if [ "$use_pitch" = "false" ] && [ "$use_ffv" = "false" ]; then
steps/make_plp.sh --cmd "$train_cmd" --nj $decode_nj data/train exp/make_plp/train plp
elif [ "$use_pitch" = "true" ] && [ "$use_ffv" = "true" ]; then
cp -rT data/train data/train_plp; cp -rT data/train data/train_pitch; cp -rT data/train data/train_ffv
steps/make_plp.sh --cmd "$train_cmd" --nj $decode_nj data/train_plp exp/make_plp/train plp_tmp_train
local/make_pitch.sh --cmd "$train_cmd" --nj $decode_nj data/train_pitch exp/make_pitch/train pitch_tmp_train
local/make_ffv.sh --cmd "$train_cmd" --nj $decode_nj data/train_ffv exp/make_ffv/train ffv_tmp_train
steps/append_feats.sh --cmd "$train_cmd" --nj $decode_nj data/train{_plp,_pitch,_plp_pitch} exp/make_pitch/append_train_pitch plp_tmp_train
steps/append_feats.sh --cmd "$train_cmd" --nj $decode_nj data/train{_plp_pitch,_ffv,} exp/make_ffv/append_train_pitch_ffv plp
rm -rf {plp,pitch,ffv}_tmp_train data/train_{plp,pitch,plp_pitch}
elif [ "$use_pitch" = "true" ]; then
cp -rT data/train data/train_plp; cp -rT data/train data/train_pitch
steps/make_plp.sh --cmd "$train_cmd" --nj $decode_nj data/train_plp exp/make_plp/train plp_tmp_train
local/make_pitch.sh --cmd "$train_cmd" --nj $decode_nj data/train_pitch exp/make_pitch/train plp_tmp_train
local/make_pitch.sh --cmd "$train_cmd" --nj $decode_nj data/train_pitch exp/make_pitch/train pitch_tmp_train
steps/append_feats.sh --cmd "$train_cmd" --nj $decode_nj data/train{_plp,_pitch,} exp/make_pitch/append_train plp
rm -rf plp_tmp_train data/train_{plp,pitch}
rm -rf {plp,pitch}_tmp_train data/train_{plp,pitch}
elif [ "$use_ffv" = "true" ]; then
cp -rT data/train data/train_plp; cp -rT data/train data/train_ffv
steps/make_plp.sh --cmd "$train_cmd" --nj $decode_nj data/train_plp exp/make_plp/train plp_tmp_train
local/make_ffv.sh --cmd "$train_cmd" --nj $decode_nj data/train_ffv exp/make_ffv/train ffv_tmp_train
steps/append_feats.sh --cmd "$train_cmd" --nj $decode_nj data/train{_plp,_ffv,} exp/make_ffv/append_train plp
rm -rf {plp,ffv}_tmp_train data/train_{plp,ffv}
fi
steps/compute_cmvn_stats.sh \
data/train exp/make_plp/train plp
# In case plp or pitch extraction failed on some utterances, delist them
......
......@@ -36,14 +36,31 @@ fi
function make_plp {
t=$1
if ! "$use_pitch"; then
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t} exp/make_plp/${t} plp
else
use_pitch=false
use_ffv=false
if [ "$use_pitch" = "false" ] && [ "$use_ffv" = "false" ]; then
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t} exp/make_plp/${t} plp
elif [ "$use_pitch" = "true" ] && [ "$use_ffv" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_pitch; cp -rT data/${t} data/${t}_ffv
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} pitch_tmp_${t}
local/make_ffv.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_ffv exp/make_ffv/${t} ffv_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_pitch,_plp_pitch} exp/make_pitch/append_${t}_pitch plp_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp_pitch,_ffv,} exp/make_ffv/append_${t}_pitch_ffv plp
rm -rf {plp,pitch,ffv}_tmp_${t} data/${t}_{plp,pitch,plp_pitch}
elif [ "$use_pitch" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_pitch
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} pitch_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_pitch,} exp/make_pitch/append_${t} plp
rm -rf plp_tmp_${t} data/${t}_{plp,pitch}
rm -rf {plp,pitch}_tmp_${t} data/${t}_{plp,pitch}
elif [ "$use_ffv" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_ffv
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_ffv.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_ffv exp/make_ffv/${t} ffv_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_ffv,} exp/make_ffv/append_${t} plp
rm -rf {plp,ffv}_tmp_${t} data/${t}_{plp,ffv}
fi
steps/compute_cmvn_stats.sh data/${t} exp/make_plp/${t} plp
utils/fix_data_dir.sh data/${t}
......
......@@ -36,15 +36,33 @@ fi
function make_plp {
t=$1
if ! "$use_pitch"; then
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t} exp/make_plp/${t} plp
else
use_pitch=false
use_ffv=false
if [ "$use_pitch" = "false" ] && [ "$use_ffv" = "false" ]; then
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t} exp/make_plp/${t} plp
elif [ "$use_pitch" = "true" ] && [ "$use_ffv" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_pitch; cp -rT data/${t} data/${t}_ffv
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} pitch_tmp_${t}
local/make_ffv.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_ffv exp/make_ffv/${t} ffv_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_pitch,_plp_pitch} exp/make_pitch/append_${t}_pitch plp_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp_pitch,_ffv,} exp/make_ffv/append_${t}_pitch_ffv plp
rm -rf {plp,pitch,ffv}_tmp_${t} data/${t}_{plp,pitch,plp_pitch}
elif [ "$use_pitch" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_pitch
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} plp_tmp_${t}
local/make_pitch.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_pitch exp/make_pitch/${t} pitch_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_pitch,} exp/make_pitch/append_${t} plp
rm -rf plp_tmp_${t} data/${t}_{plp,pitch}
rm -rf {plp,pitch}_tmp_${t} data/${t}_{plp,pitch}
elif [ "$use_ffv" = "true" ]; then
cp -rT data/${t} data/${t}_plp; cp -rT data/${t} data/${t}_ffv
steps/make_plp.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_plp exp/make_plp/${t} plp_tmp_${t}
local/make_ffv.sh --cmd "$decode_cmd" --nj $my_nj data/${t}_ffv exp/make_ffv/${t} ffv_tmp_${t}
steps/append_feats.sh --cmd "$decode_cmd" --nj $my_nj data/${t}{_plp,_ffv,} exp/make_ffv/append_${t} plp
rm -rf {plp,ffv}_tmp_${t} data/${t}_{plp,ffv}
fi
steps/compute_cmvn_stats.sh data/${t} exp/make_plp/${t} plp
utils/fix_data_dir.sh data/${t}
}
......
#!/usr/bin/perl
# Copyright Hong Kong University of Science and Technology (Author: Ricky Chan) 2013.
# Copyright 2013 Hong Kong University of Science and Technology (Author: Ricky Chan Ho Yin)
#
# Apache 2.0.
#
# A script to convert Kaldi Chinese word transcription to Chinese character transcription using a word2char mapping (e.g. a word2char_map likes "195k_chinese_word2char_map")
# This is helpful for Chinese character word error rate scoring
# A script to convert Kaldi Chinese words transcription to Chinese characters transcription.
# This is helpful for Chinese character error rate scoring.
#
# If no option is applied, by default the script converts the Chinese words transcription to Chinese characters transcription \
# by assuming the input Chinese words/characters are 3 bytes UTF8 code.
# Continuous English/ASCII characters without space are treated as single token.
#
# When --useword2charmap option is applied, an input Chinese words to Chinese characters mapping table \
# (e.g. a word2char_map likes "195k_chinese_word2char_map") is used for converting the corresponding Chinese words \
# to seperate Chinese characters.
#
# When --encodeoutput option is applied, the script runs like default mode w/o applying option except the \
# output Chinese characters are in readable encoded format. The output Chinese characters are encoded in a way \
# the same as the opensource HTK toolkit from the Cambridge University Engineering Department.
use POSIX();
if($#ARGV+1 != 2) {
print "usage: perl hkust_word2char_tran.pl chinese_word2char_map tran_file \n";
sub printUsage {
print "usage: perl hkust_word2ch_tran.pl [--useword2charmap chinese_word2char_map|--encodeoutput] tran_file \n";
print "e.g. perl hkust_word2ch_tran.pl tran_file \n";
print "e.g. perl hkust_word2ch_tran.pl --useword2charmap 195k_chinese_word2char_map tran_file \n";
print "e.g. perl hkust_word2ch_tran.pl --encodeoutput tran_file \n";
exit;
}
sub encodeByteCharacter {
$enbc = "\\";
$uchar = ord($_[0]);
$encrypt1 = (($uchar>>6)&7)+'0';
$encrypt2 = (($uchar>>3)&7)+'0';
$encrypt3 = ($uchar&7)+'0';
$enbc = $enbc."$encrypt1"."$encrypt2"."$encrypt3";
return $enbc;
}
if(@ARGV < 1 || @ARGV > 3 ) {
printUsage();
}
$word2charfile=$ARGV[0];
$tranfile=$ARGV[1];
$useMapping=0;
$useEncodeoutput=0;
%word2charlist=();
open(INFILE, $word2charfile) || die("Can't open chinese word to char map: ".$word2charfile."\n");
while(<INFILE>){
chomp;
@line=split(/\s+/);
$a=$line[0];
$b="";
for($i=1; $i<scalar(@line); $i++) {
$b=$b . " " . $line[$i];
if(@ARGV == 2) {
if($ARGV[0] ne "--encodeoutput") {
printUsage();
}
$word2charlist{$a}=$b;
$useEncodeoutput=1;
$tranfile=$ARGV[1];
}
elsif(@ARGV == 3) {
if($ARGV[0] ne "--useword2charmap") {
printUsage();
}
$useMapping=1;
$word2charfile=$ARGV[1];
$tranfile=$ARGV[2];
}
else {
$tranfile=$ARGV[0];
}
close(INFILE);
# if Chinese word to character map is provided, read it
if($useMapping) {
%word2charlist=();
open(INFILE, $word2charfile) || die("Can't open Chinese word to char map: ".$word2charfile."\n");
while(<INFILE>){
chomp;
@line=split(/\s+/);
$a=$line[0];
$b="";
for($i=1; $i<scalar(@line); $i++) {
$b=$b . " " . $line[$i];
}
$word2charlist{$a}=$b;
}
close(INFILE);
}
# process kaldi transcription
open(INFILE, $tranfile) || die("Can't open transcription file ".$tranfile."\n");
while(<INFILE>) {
chomp;
......@@ -34,13 +89,49 @@ while(<INFILE>) {
## utt_id
print $line[0];
## utt_character_word
for($i=1; $i<scalar(@line); $i++) {
if(!exists($word2charlist{$line[$i]})) {
print " ".$line[$i];
if($useMapping) {
if(!exists($word2charlist{$line[$i]})) {
print " ".$line[$i];
}
else {
print $word2charlist{$line[$i]};
}
}
else {
print $word2charlist{$line[$i]};
@carray = split(//, $line[$i]);
$wspace=0;
$l=0;
while($l<@carray) {
$c = $carray[$l];
if(POSIX::isprint($c)) {
if($wspace) {
print $c;
}
else {
print " ".$c;
$wspace=1;
}
$l=$l+1;
}
else { ## here we find chinese character
if(!$useEncodeoutput) {
## print utf8 chinese character, which should be 3 bytes
print " ".$carray[$l].$carray[$l+1].$carray[$l+2];
}
else {
## print 3 bytes utf8 chinese character in readable encoded format
$enbc1 = encodeByteCharacter($carray[$l]);
$enbc2 = encodeByteCharacter($carray[$l+1]);
$enbc3 = encodeByteCharacter($carray[$l+2]);
print " ".$enbc1.$enbc2.$enbc3;
}
$l=$l+3;
$wspace=0;
}
}
}
}
print "\n";
......
......@@ -14,7 +14,7 @@ max_lmwt=20
. parse_options.sh || exit 1;
if [ $# -ne 3 ]; then
echo "Usage: local/score_basic.sh [--cmd (run.pl|queue.pl...)] <data-dir> <lang-dir|graph-dir> <decode-dir>"
echo "Usage: local/score_basic_ext.sh [--cmd (run.pl|queue.pl...)] <data-dir> <lang-dir|graph-dir> <decode-dir>"
echo " Options:"
echo " --cmd (run.pl|queue.pl...) # specify how to run the sub-processes."
echo " --min_lmwt <int> # minumum LM-weight for lattice rescoring "
......@@ -61,10 +61,14 @@ filter_text <$data/text >$dir/scoring/text.filt
unset LC_ALL
#for Chinese character error rate
perl local/ext/hkust_word2ch_tran.pl local/ext/195k_chinese_word2char_map $dir/scoring/text.filt > $dir/scoring/cchar.filt
perl local/ext/hkust_word2ch_tran.pl $dir/scoring/text.filt > $dir/scoring/cchar.filt
# perl local/ext/hkust_word2ch_tran.pl --useword2charmap local/ext/195k_chinese_word2char_map $dir/scoring/text.filt > $dir/scoring/cchar.filt
# perl local/ext/hkust_word2ch_tran.pl --encodeoutput $dir/scoring/text.filt > $dir/scoring/cchar.filt
for lmwt in `seq $min_lmwt $max_lmwt`; do
perl local/ext/hkust_word2ch_tran.pl local/ext/195k_chinese_word2char_map $dir/scoring/$lmwt.txt > $dir/scoring/${lmwt}.cchar
perl local/ext/hkust_word2ch_tran.pl $dir/scoring/$lmwt.txt > $dir/scoring/${lmwt}.cchar
# perl local/ext/hkust_word2ch_tran.pl --useword2charmap local/ext/195k_chinese_word2char_map $dir/scoring/$lmwt.txt > $dir/scoring/${lmwt}.cchar
# perl local/ext/hkust_word2ch_tran.pl --encodeoutput $dir/scoring/$lmwt.txt > $dir/scoring/${lmwt}.cchar
done
export LC_ALL=C
......
......@@ -16,52 +16,25 @@ train_stage=-100
set -e
if [ $stage -le 0 ]; then
# Create the training data.
if [ $stage -le 0 ]; then
# Create the training data.
featdir=`pwd`/mfcc/nnet4b; mkdir -p $featdir
mkdir -p conf/nnet4b
all_fbankdirs=""
all_mfccdirs=""
pairs="1.1-1.0 1.05-1.2 1.0-0.8 0.95-1.1 0.9-0.9"
for pair in $pairs; do
vtln_warp=`echo $pair | cut -d- -f1`
time_warp=`echo $pair | cut -d- -f2`
fs=`perl -e "print ($time_warp*10);"`
fbank_conf=conf/nnet4b/fbank_vtln${vtln_warp}_time${time_warp}.conf
( echo "--num-mel-bins=40"; echo "--frame-shift=$fs"; echo "--vtln-warp=$vtln_warp" ) > $fbank_conf
echo "Making filterbank features for $pair"
fbank_data=data/nnet4b/train_fbank_vtln${vtln_warp}_time${time_warp}
all_fbankdirs="$all_fbankdirs $fbank_data"
utils/copy_data_dir.sh --spk-prefix ${pair}- --utt-prefix ${pair}- data/train $fbank_data
steps/make_fbank.sh --fbank-config $fbank_conf --nj 8 --cmd "run.pl" $fbank_data exp/nnet4b/make_mfcc/mfcc_$pair $featdir
steps/compute_cmvn_stats.sh $fbank_data exp/nnet4b/fbank_$pair $featdir
echo "Making MFCC features for $pair"
mfcc_data=data/nnet4b/train_mfcc_vtln${vtln_warp}_time${time_warp}
mfcc_conf=conf/nnet4b/mfcc_vtln${vtln_warp}_time${time_warp}.conf
( echo "--use-energy=false"; echo "--frame-shift=$fs" ; echo "--vtln-warp=$vtln_warp" ) > $mfcc_conf
utils/copy_data_dir.sh --spk-prefix ${pair}- --utt-prefix ${pair}- data/train $mfcc_data
steps/make_mfcc.sh --mfcc-config $mfcc_conf --nj 8 --cmd "run.pl" $mfcc_data exp/nnet4b/make_mfcc/mfcc_$pair $featdir
steps/compute_cmvn_stats.sh $mfcc_data exp/nnet4b/mfcc_$pair $featdir
all_mfccdirs="$all_mfccdirs $mfcc_data"
done
utils/combine_data.sh data/nnet4b/train_fbank_all $all_fbankdirs
utils/combine_data.sh data/nnet4b/train_mfcc_all $all_mfccdirs
steps/align_fmllr.sh --nj 8 --cmd "$train_cmd" \
data/nnet4b/train_mfcc_all data/lang exp/tri3b exp/tri3b_ali_nnet4b
# In the combined filterbank directory, create a file utt2uniq which maps
# our extended utterance-ids to "unique utterances". This enables the
# script steps/nnet2/get_egs.sh to hold out data in a more proper way.
cat data/nnet4b/train_fbank_all/utt2spk | awk '{print $1;}' | \
perl -ane ' chop; $utt = $_; s/[-0-9\.]+-[-0-9\.]+-//; print "$utt $_\n"; ' \
> data/nnet4b/train_fbank_all/utt2uniq
fbank_conf=conf/fbank_40.conf
echo "--num-mel-bins=40" > $fbank_conf
steps/nnet2/get_perturbed_feats.sh --cmd "$train_cmd" \
$fbank_conf $featdir exp/perturbed_fbanks data/train data/train_perturbed_fbank &
steps/nnet2/get_perturbed_feats.sh --cmd "$train_cmd" --feature-type mfcc \
conf/mfcc.conf $featdir exp/perturbed_mfcc data/train data/train_perturbed_mfcc &
wait
fi
if [ $stage -le 1 ]; then
steps/align_fmllr.sh --nj 30 --cmd "$train_cmd" \
data/train_perturbed_mfcc data/lang exp/tri3b exp/tri3b_ali_perturbed_mfcc
fi
if [ $stage -le 2 ]; then
steps/nnet2/train_block.sh --stage "$train_stage" \
--bias-stddev 0.5 --splice-width 7 --egs-opts "--feat-type raw" \
--softmax-learning-rate-factor 0.5 --cleanup false \
......@@ -70,11 +43,11 @@ if [ $stage -le 1 ]; then
--mix-up 4000 \
--cmd "$decode_cmd" \
--hidden-layer-dim 450 \
data/nnet4b/train_fbank_all data/lang exp/tri3b_ali_nnet4b exp/nnet4b || exit 1
data/nnet4b/train_perturbed_fbank data/lang exp/tri3b_ali_perturbed_mfcc exp/nnet4b || exit 1
fi
if [ $stage -le 2 ]; then
if [ $stage -le 3 ]; then
# Create the testing data.
featdir=`pwd`/mfcc
mkdir -p $featdir
......@@ -91,7 +64,7 @@ if [ $stage -le 2 ]; then
steps/compute_cmvn_stats.sh data/test_fbank exp/make_fbank/test $featdir
fi
if [ $stage -le 3 ]; then
if [ $stage -le 4 ]; then
steps/nnet2/decode.sh --config conf/decode.config --cmd "$decode_cmd" --nj 20 --feat-type raw \