trunk: adding pitch+online-nnet2 scripts for Librispeech, per user request (not tested yet).

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4868 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
This commit is contained in:
Dan Povey 2015-02-09 23:23:08 +00:00
Родитель 9e294dc260
Коммит a2893ea0eb
3 изменённых файлов: 254 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,31 @@
## This config is given by conf/make_pitch_online.sh to the program compute-and-process-kaldi-pitch-feats,
## and is copied by steps/online/nnet2/prepare_online_decoding.sh and similar scripts, to be given
## to programs like online2-wav-nnet2-latgen-faster.
## The program compute-and-process-kaldi-pitch-feats will use it to compute pitch features that
## are the same as that those which will generated in online decoding; this enables us to train
## in a way that's compatible with online decoding.
##
## most of these options relate to the post-processing rather than the pitch
## extraction itself.
--add-raw-log-pitch=true ## this is intended for input to neural nets, so our
## approach is "throw everything in and see what
## sticks".
--normalization-left-context=75
--normalization-right-context=50 # We're removing some of the right-context
# for the normalization. Would normally be 75.
#
# Note: our changes to the (left,right) context
# from the defaults of (75,75) to (75,50) will
# almost certainly worsen results, but will
# reduce latency.
--frames-per-chunk=10 ## relates to offline simulation of online decoding; 1
## would be equivalent to getting in samples one by
## one.
--simulate-first-pass-online=true ## this make the online-pitch-extraction code
## output the 'first-pass' features, which
## are less accurate than the final ones, and
## which are the only features the neural-net
## decoding would ever see (since we can't
## afford to do lattice rescoring in the
## neural-net code

Просмотреть файл

@ -0,0 +1,51 @@
#!/bin/bash
# this script contains some common (shared) parts of the run_nnet*.sh scripts.
. cmd.sh
stage=0
set -e
. cmd.sh
. ./path.sh
. ./utils/parse_options.sh
if [ $stage -le 1 ]; then
# Create high-resolution MFCC features (with 40 cepstra instead of 13).
# this shows how you can split across multiple file-systems. we'll split the
# MFCC dir across multiple locations. You might want to be careful here, if you
# have multiple copies of Kaldi checked out and run the same recipe, not to let
# them overwrite each other.
mfccdir=mfcc
if [[ $(hostname -f) == *.clsp.jhu.edu ]] && [ ! -d $mfccdir/storage ]; then
utils/create_split_dir.pl /export/b0{1,2,3,4}/$USER/kaldi-data/egs/librispeech-$(date +'%m_%d_%H_%M')/s5/$mfccdir/storage $mfccdir/storage
fi
for datadir in train_960 dev_clean dev_other; do
utils/copy_data_dir.sh data/$datadir data/${datadir}_hiresp
steps/make_mfcc_pitch_online.sh --nj 150 --mfcc-config conf/mfcc_hires.conf \
--online-pitch-config conf/online_pitch.conf \
--cmd "$train_cmd" data/${datadir}_hiresp exp/make_hiresp/$datadir $mfccdir || exit 1;
steps/compute_cmvn_stats.sh data/${datadir}_hiresp exp/make_hiresp/$datadir $mfccdir || exit 1;
# dump plain MFCC features by selecting MFCC-only part
steps/select_feats.sh 0-39 data/${datadir}_hiresp data/${datadir}_hires exp/make_hires/$datadir $mfccdir || exit 1;
steps/compute_cmvn_stats.sh data/${datadir}_hires exp/make_hires/$datadir $mfccdir || exit 1;
done
# now create some data subsets.
# mixed is the clean+other data.
# 30k is 1/10 of the data (around 100 hours), 60k is 1/5th of it (around 200 hours).
utils/subset_data_dir.sh data/train_960_hires 30000 data/train_mixed_hires_30k
utils/subset_data_dir.sh data/train_960_hires 60000 data/train_mixed_hires_60k
fi
# The stages where we build the iVector extractor are the same as the
# non-pitch system, because the features given to the iVector extractor don't use pitch.
steps/online/run_nnet2_common.sh --stage 2 || exit 1;
exit 0;

Просмотреть файл

@ -0,0 +1,172 @@
#!/bin/bash
# This is the "multi-splice" version of the online-nnet2 training script,
# with pitch.
# This hasn't been tested yet.
. cmd.sh
stage=7
train_stage=-10
use_gpu=true
dir=exp/nnet2_onlinep/nnet_ms_a
set -e
. cmd.sh
. ./path.sh
. ./utils/parse_options.sh
if $use_gpu; then
if ! cuda-compiled; then
cat <<EOF && exit 1
This script is intended to be used with GPUs but you have not compiled Kaldi with CUDA
If you want to use GPUs (and have them), go to src/, and configure and make on a machine
where "nvcc" is installed. Otherwise, call this script with --use-gpu false
EOF
fi
parallel_opts="-l gpu=1"
num_threads=1
minibatch_size=512
if [[ $(hostname -f) == *.clsp.jhu.edu ]]; then
parallel_opts="$parallel_opts --config conf/queue_no_k20.conf --allow-k20 false"
# that config is like the default config in the text of queue.pl, but adding the following lines.
# default allow_k20=true
# option allow_k20=true
# option allow_k20=false -l 'hostname=!g01&!g02&!b06'
# It's a workaround for an NVidia CUDA library bug for our currently installed version
# of the CUDA toolkit, that only shows up on k20's
fi
# the _a is in case I want to change the parameters.
else
# Use 4 nnet jobs just like run_4d_gpu.sh so the results should be
# almost the same, but this may be a little bit slow.
num_threads=16
minibatch_size=128
parallel_opts="-pe smp $num_threads"
fi
# do the common parts of the script.
local/online/run_nnet2_common.sh --stage $stage
if [ $stage -le 7 ]; then
if [[ $(hostname -f) == *.clsp.jhu.edu ]] && [ ! -d $dir/egs/storage ]; then
utils/create_split_dir.pl \
/export/b0{3,4,5,6}/$USER/kaldi-data/egs/librispeech-$(date +'%m_%d_%H_%M')/s5/$dir/egs/storage $dir/egs/storage
fi
# The size of the system is kept rather smaller than the run_7a_960.sh system:
# this is because we want it to be small enough that we could plausibly run it
# in real-time.
steps/nnet2/train_multisplice_accel2.sh --stage $train_stage \
--num-epochs 8 --num-jobs-initial 3 --num-jobs-final 18 \
--num-hidden-layers 6 --splice-indexes "layer0/-2:-1:0:1:2 layer1/-1:2 layer3/-3:3 layer4/-7:2" \
--feat-type raw \
--online-ivector-dir exp/nnet2_online/ivectors_train_960_hires \
--cmvn-opts "--norm-means=false --norm-vars=false" \
--num-threads "$num_threads" \
--minibatch-size "$minibatch_size" \
--parallel-opts "$parallel_opts" \
--io-opts "--max-jobs-run 12" \
--initial-effective-lrate 0.0015 --final-effective-lrate 0.00015 \
--cmd "$decode_cmd" \
--pnorm-input-dim 3500 \
--pnorm-output-dim 350 \
--mix-up 12000 \
data/train_960_hiresp data/lang exp/tri6b $dir || exit 1;
fi
if [ $stage -le 8 ]; then
# dump iVectors for the testing data.
for test in dev_clean dev_other; do
steps/online/nnet2/extract_ivectors_online.sh --cmd "$train_cmd" --nj 20 \
data/${test}_hires exp/nnet2_online/extractor exp/nnet2_online/ivectors_$test || exit 1;
done
fi
if [ $stage -le 9 ]; then
# this does offline decoding that should give about the same results as the
# real online decoding (the one with --per-utt true)
for test in dev_clean dev_other; do
steps/nnet2/decode.sh --nj 30 --cmd "$decode_cmd" --config conf/decode.config \
--online-ivector-dir exp/nnet2_online/ivectors_${test} \
exp/tri6b/graph_pp_tgsmall data/${test}_hiresp $dir/decode_pp_${test}_tgsmall || exit 1;
steps/lmrescore.sh --cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tgmed} \
data/${test}_hiresp $dir/decode_pp_${test}_{tgsmall,tgmed} || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tglarge} \
data/$test $dir/decode_pp_${test}_{tgsmall,tglarge} || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,fglarge} \
data/$test $dir/decode_pp_${test}_{tgsmall,fglarge} || exit 1;
done
fi
if [ $stage -le 10 ]; then
# If this setup used PLP features, we'd have to give the option --feature-type plp
# to the script below.
steps/online/nnet2/prepare_online_decoding.sh --mfcc-config conf/mfcc_hires.conf \
--online-pitch-config conf/online_pitch.conf --add-pitch true \
data/lang exp/nnet2_online/extractor "$dir" ${dir}_online || exit 1;
fi
if [ $stage -le 11 ]; then
# do the actual online decoding with iVectors, carrying info forward from
# previous utterances of the same speaker.
for test in dev_clean dev_other; do
steps/online/nnet2/decode.sh --config conf/decode.config --cmd "$decode_cmd" --nj 30 \
exp/tri6b/graph_pp_tgsmall data/$test ${dir}_online/decode_pp_${test}_tgsmall || exit 1;
steps/lmrescore.sh --cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tgmed} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tgmed} || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tglarge} || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,fglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,fglarge} || exit 1;
done
fi
if [ $stage -le 12 ]; then
# this version of the decoding treats each utterance separately
# without carrying forward speaker information.
for test in dev_clean dev_other; do
steps/online/nnet2/decode.sh --config conf/decode.config --cmd "$decode_cmd" --nj 30 \
--per-utt true exp/tri6b/graph_pp_tgsmall data/$test ${dir}_online/decode_pp_${test}_tgsmall_utt || exit 1;
steps/lmrescore.sh --cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tgmed} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tgmed}_utt || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tglarge}_utt || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,fglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,fglarge}_utt || exit 1;
done
fi
if [ $stage -le 13 ]; then
# this version of the decoding treats each utterance separately
# without carrying forward speaker information, but looks to the end
# of the utterance while computing the iVector (--online false)
for test in test_clean test_other dev_clean dev_other; do
steps/online/nnet2/decode.sh --config conf/decode.config --cmd "$decode_cmd" --nj 30 \
--per-utt true --online false exp/tri6b/graph_pp_tgsmall data/$test \
${dir}_online/decode_pp_${test}_tgsmall_utt_offline || exit 1;
steps/lmrescore.sh --cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tgmed} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tgmed}_utt_offline || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,tglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,tglarge}_utt_offline || exit 1;
steps/lmrescore_const_arpa.sh \
--cmd "$decode_cmd" data/lang_pp_test_{tgsmall,fglarge} \
data/$test ${dir}_online/decode_pp_${test}_{tgsmall,fglarge}_utt_offline || exit 1;
done
fi
exit 0;