зеркало из https://github.com/mozilla/kaldi.git
trunk: Adding scripts to produce combined MFCC/PLP/filterbank + pitch features.
git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@3350 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
This commit is contained in:
Родитель
76a97eab02
Коммит
58137b5b43
|
@ -0,0 +1,132 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2013 The Shenzhen Key Laboratory of Intelligent Media and Speech,
|
||||
# PKU-HKUST Shenzhen Hong Kong Institution (Author: Shi Wei)
|
||||
# Apache 2.0
|
||||
# Combine filterbank and pitch features together
|
||||
# Note: This file is based on make_fbank.sh and make_pitch_kaldi.sh
|
||||
|
||||
# Begin configuration section.
|
||||
nj=4
|
||||
cmd=run.pl
|
||||
fbank_config=conf/fbank.conf
|
||||
pitch_config=conf/pitch.conf
|
||||
pitch_postprocess_config=
|
||||
paste_length_tolerance=2
|
||||
compress=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_fbank_pitch.sh [options] <data-dir> <log-dir> <path-to-fbank-pitch-dir>";
|
||||
echo "options: "
|
||||
echo " --fbank-config <config-file> # config passed to compute-fbank-feats "
|
||||
echo " --pitch_config <pitch-config-file> # config passed to compute-kaldi-pitch-feats "
|
||||
echo " --pitch_postprocess_config <postprocess-config-file> # config passed to process-kaldi-pitch-feats "
|
||||
echo " --paste_length_tolerance <tolerance> # length tolerance passed to paste-feats"
|
||||
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
|
||||
logdir=$2
|
||||
fbank_pitch_dir=$3
|
||||
|
||||
|
||||
# make $fbank_pitch_dir an absolute pathname.
|
||||
fbank_pitch_dir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $fbank_pitch_dir ${PWD}`
|
||||
|
||||
# use "name" as part of name of the archive.
|
||||
name=`basename $data`
|
||||
|
||||
mkdir -p $fbank_pitch_dir || exit 1;
|
||||
mkdir -p $logdir || exit 1;
|
||||
|
||||
scp=$data/wav.scp
|
||||
|
||||
required="$scp $fbank_config $pitch_config"
|
||||
|
||||
for f in $required; do
|
||||
if [ ! -f $f ]; then
|
||||
echo "make_fbank_pitch.sh: no such file $f"
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -z "$pitch_postprocess_config" ]; then
|
||||
postprocess_config_opt="--config=$pitch_postprocess_config";
|
||||
else
|
||||
postprocess_config_opt=
|
||||
fi
|
||||
|
||||
# note: in general, the double-parenthesis construct in bash "((" is "C-style
|
||||
# syntax" where we can get rid of the $ for variable names, and omit spaces.
|
||||
# The "for" loop in this style is a special construct.
|
||||
|
||||
|
||||
if [ -f $data/segments ]; then
|
||||
echo "$0 [info]: segments file exists: using that."
|
||||
split_segments=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_segments="$split_segments $logdir/segments.$n"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $data/segments $split_segments || exit 1;
|
||||
rm $logdir/.error 2>/dev/null
|
||||
|
||||
fbank_feats="ark:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-fbank-feats --verbose=2 --config=$fbank_config ark:- ark:- |"
|
||||
pitch_feats="ark,s,cs:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config ark:- ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_fbank_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$fbank_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$fbank_pitch_dir/raw_fbank_pitch_$name.JOB.ark,$fbank_pitch_dir/raw_fbank_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
else
|
||||
echo "$0: [info]: no segments file exists: assuming wav.scp indexed by utterance."
|
||||
split_scps=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_scps="$split_scps $logdir/wav.$n.scp"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $scp $split_scps || exit 1;
|
||||
|
||||
fbank_feats="ark:compute-fbank-feats --verbose=2 --config=$fbank_config scp:$logdir/wav.JOB.scp ark:- |"
|
||||
pitch_feats="ark,s,cs:compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config scp:$logdir/wav.JOB.scp ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_fbank_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$fbank_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$fbank_pitch_dir/raw_fbank_pitch_$name.JOB.ark,$fbank_pitch_dir/raw_fbank_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $logdir/.error.$name ]; then
|
||||
echo "Error producing fbank & pitch features for $name:"
|
||||
tail $logdir/make_fbank_pitch_${name}.1.log
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# concatenate the .scp files together.
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
cat $fbank_pitch_dir/raw_fbank_pitch_$name.$n.scp || exit 1;
|
||||
done > $data/feats.scp
|
||||
|
||||
rm $logdir/wav.*.scp $logdir/segments.* 2>/dev/null
|
||||
|
||||
nf=`cat $data/feats.scp | wc -l`
|
||||
nu=`cat $data/utt2spk | wc -l`
|
||||
if [ $nf -ne $nu ]; then
|
||||
echo "It seems not all of the feature files were successfully processed ($nf != $nu);"
|
||||
echo "consider using utils/fix_data_dir.sh $data"
|
||||
fi
|
||||
|
||||
echo "Succeeded creating filterbank & pitch features for $name"
|
|
@ -0,0 +1,132 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2013 The Shenzhen Key Laboratory of Intelligent Media and Speech,
|
||||
# PKU-HKUST Shenzhen Hong Kong Institution (Author: Shi Wei)
|
||||
# Apache 2.0
|
||||
# Combine MFCC and pitch features together
|
||||
# Note: This file is based on make_mfcc.sh and make_pitch_kaldi.sh
|
||||
|
||||
# Begin configuration section.
|
||||
nj=4
|
||||
cmd=run.pl
|
||||
mfcc_config=conf/mfcc.conf
|
||||
pitch_config=conf/pitch.conf
|
||||
pitch_postprocess_config=
|
||||
paste_length_tolerance=2
|
||||
compress=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_mfcc_pitch.sh [options] <data-dir> <log-dir> <path-to-mfcc-pitch-dir>";
|
||||
echo "options: "
|
||||
echo " --mfcc_config <mfcc-config-file> # config passed to compute-mfcc-feats "
|
||||
echo " --pitch_config <pitch-config-file> # config passed to compute-kaldi-pitch-feats "
|
||||
echo " --pitch_postprocess_config <postprocess-config-file> # config passed to process-kaldi-pitch-feats "
|
||||
echo " --paste_length_tolerance <tolerance> # length tolerance passed to paste-feats"
|
||||
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
|
||||
logdir=$2
|
||||
mfcc_pitch_dir=$3
|
||||
|
||||
|
||||
# make $mfcc_pitch_dir an absolute pathname.
|
||||
mfcc_pitch_dir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $mfcc_pitch_dir ${PWD}`
|
||||
|
||||
# use "name" as part of name of the archive.
|
||||
name=`basename $data`
|
||||
|
||||
mkdir -p $mfcc_pitch_dir || exit 1;
|
||||
mkdir -p $logdir || exit 1;
|
||||
|
||||
scp=$data/wav.scp
|
||||
|
||||
required="$scp $mfcc_config $pitch_config"
|
||||
|
||||
for f in $required; do
|
||||
if [ ! -f $f ]; then
|
||||
echo "make_mfcc_pitch.sh: no such file $f"
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -z "$pitch_postprocess_config" ]; then
|
||||
postprocess_config_opt="--config=$pitch_postprocess_config";
|
||||
else
|
||||
postprocess_config_opt=
|
||||
fi
|
||||
|
||||
# note: in general, the double-parenthesis construct in bash "((" is "C-style
|
||||
# syntax" where we can get rid of the $ for variable names, and omit spaces.
|
||||
# The "for" loop in this style is a special construct.
|
||||
|
||||
|
||||
if [ -f $data/segments ]; then
|
||||
echo "$0 [info]: segments file exists: using that."
|
||||
split_segments=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_segments="$split_segments $logdir/segments.$n"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $data/segments $split_segments || exit 1;
|
||||
rm $logdir/.error 2>/dev/null
|
||||
|
||||
mfcc_feats="ark:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-mfcc-feats --verbose=2 --config=$mfcc_config ark:- ark:- |"
|
||||
pitch_feats="ark,s,cs:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config ark:- ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_mfcc_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$mfcc_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$mfcc_pitch_dir/raw_mfcc_pitch_$name.JOB.ark,$mfcc_pitch_dir/raw_mfcc_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
else
|
||||
echo "$0: [info]: no segments file exists: assuming wav.scp indexed by utterance."
|
||||
split_scps=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_scps="$split_scps $logdir/wav.$n.scp"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $scp $split_scps || exit 1;
|
||||
|
||||
mfcc_feats="ark:compute-mfcc-feats --verbose=2 --config=$mfcc_config scp:$logdir/wav.JOB.scp ark:- |"
|
||||
pitch_feats="ark,s,cs:compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config scp:$logdir/wav.JOB.scp ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_mfcc_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$mfcc_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$mfcc_pitch_dir/raw_mfcc_pitch_$name.JOB.ark,$mfcc_pitch_dir/raw_mfcc_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $logdir/.error.$name ]; then
|
||||
echo "Error producing mfcc & pitch features for $name:"
|
||||
tail $logdir/make_mfcc_pitch_${name}.1.log
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# concatenate the .scp files together.
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
cat $mfcc_pitch_dir/raw_mfcc_pitch_$name.$n.scp || exit 1;
|
||||
done > $data/feats.scp
|
||||
|
||||
rm $logdir/wav.*.scp $logdir/segments.* 2>/dev/null
|
||||
|
||||
nf=`cat $data/feats.scp | wc -l`
|
||||
nu=`cat $data/utt2spk | wc -l`
|
||||
if [ $nf -ne $nu ]; then
|
||||
echo "It seems not all of the feature files were successfully processed ($nf != $nu);"
|
||||
echo "consider using utils/fix_data_dir.sh $data"
|
||||
fi
|
||||
|
||||
echo "Succeeded creating MFCC & Pitch features for $name"
|
|
@ -20,7 +20,7 @@ if [ -f path.sh ]; then . ./path.sh; fi
|
|||
. parse_options.sh || exit 1;
|
||||
|
||||
if [ $# != 3 ]; then
|
||||
echo "usage: make_pitch_new.sh [options] <data-dir> <log-dir> <path-to-pitchdir>";
|
||||
echo "usage: make_pitch_kaldi.sh [options] <data-dir> <log-dir> <path-to-pitchdir>";
|
||||
echo "options: "
|
||||
echo " --pitch-config <config-file> # config passed to compute-kaldi-pitch-feats "
|
||||
echo " --postprocess-config <config-file> # config passed to process-kaldi-pitch-feats "
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2013 The Shenzhen Key Laboratory of Intelligent Media and Speech,
|
||||
# PKU-HKUST Shenzhen Hong Kong Institution (Author: Shi Wei)
|
||||
# Apache 2.0
|
||||
# Combine PLP and pitch features together
|
||||
# Note: This file is based on make_plp.sh and make_pitch_kaldi.sh
|
||||
|
||||
# Begin configuration section.
|
||||
nj=4
|
||||
cmd=run.pl
|
||||
plp_config=conf/plp.conf
|
||||
pitch_config=conf/pitch.conf
|
||||
pitch_postprocess_config=
|
||||
paste_length_tolerance=2
|
||||
compress=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_plp_pitch.sh [options] <data-dir> <log-dir> <path-to-plp-pitch-dir>";
|
||||
echo "options: "
|
||||
echo " --plp-config <config-file> # config passed to compute-plp-feats "
|
||||
echo " --pitch_config <pitch-config-file> # config passed to compute-kaldi-pitch-feats "
|
||||
echo " --pitch_postprocess_config <postprocess-config-file> # config passed to process-kaldi-pitch-feats "
|
||||
echo " --paste_length_tolerance <tolerance> # length tolerance passed to paste-feats"
|
||||
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
|
||||
logdir=$2
|
||||
plp_pitch_dir=$3
|
||||
|
||||
|
||||
# make $plp_pitch_dir an absolute pathname.
|
||||
plp_pitch_dir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $plp_pitch_dir ${PWD}`
|
||||
|
||||
# use "name" as part of name of the archive.
|
||||
name=`basename $data`
|
||||
|
||||
mkdir -p $plp_pitch_dir || exit 1;
|
||||
mkdir -p $logdir || exit 1;
|
||||
|
||||
scp=$data/wav.scp
|
||||
|
||||
required="$scp $plp_config $pitch_config"
|
||||
|
||||
for f in $required; do
|
||||
if [ ! -f $f ]; then
|
||||
echo "make_plp_pitch.sh: no such file $f"
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -z "$pitch_postprocess_config" ]; then
|
||||
postprocess_config_opt="--config=$pitch_postprocess_config";
|
||||
else
|
||||
postprocess_config_opt=
|
||||
fi
|
||||
|
||||
# note: in general, the double-parenthesis construct in bash "((" is "C-style
|
||||
# syntax" where we can get rid of the $ for variable names, and omit spaces.
|
||||
# The "for" loop in this style is a special construct.
|
||||
|
||||
|
||||
if [ -f $data/segments ]; then
|
||||
echo "$0 [info]: segments file exists: using that."
|
||||
split_segments=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_segments="$split_segments $logdir/segments.$n"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $data/segments $split_segments || exit 1;
|
||||
rm $logdir/.error 2>/dev/null
|
||||
|
||||
plp_feats="ark:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-plp-feats --verbose=2 --config=$plp_config ark:- ark:- |"
|
||||
pitch_feats="ark,s,cs:extract-segments scp:$scp $logdir/segments.JOB ark:- | compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config ark:- ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_plp_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$plp_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$plp_pitch_dir/raw_plp_pitch_$name.JOB.ark,$plp_pitch_dir/raw_plp_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
else
|
||||
echo "$0: [info]: no segments file exists: assuming wav.scp indexed by utterance."
|
||||
split_scps=""
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
split_scps="$split_scps $logdir/wav.$n.scp"
|
||||
done
|
||||
|
||||
utils/split_scp.pl $scp $split_scps || exit 1;
|
||||
|
||||
plp_feats="ark:compute-plp-feats --verbose=2 --config=$plp_config scp:$logdir/wav.JOB.scp ark:- |"
|
||||
pitch_feats="ark,s,cs:compute-kaldi-pitch-feats --verbose=2 --config=$pitch_config scp:$logdir/wav.JOB.scp ark:- | process-kaldi-pitch-feats $postprocess_config_opt ark:- ark:- |"
|
||||
|
||||
$cmd JOB=1:$nj $logdir/make_plp_pitch_${name}.JOB.log \
|
||||
paste-feats --length-tolerance=$paste_length_tolerance "$plp_feats" "$pitch_feats" ark:- \| \
|
||||
copy-feats --compress=$compress ark:- \
|
||||
ark,scp:$plp_pitch_dir/raw_plp_pitch_$name.JOB.ark,$plp_pitch_dir/raw_plp_pitch_$name.JOB.scp \
|
||||
|| exit 1;
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $logdir/.error.$name ]; then
|
||||
echo "Error producing plp & pitch features for $name:"
|
||||
tail $logdir/make_plp_pitch_${name}.1.log
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# concatenate the .scp files together.
|
||||
for ((n=1; n<=nj; n++)); do
|
||||
cat $plp_pitch_dir/raw_plp_pitch_$name.$n.scp || exit 1;
|
||||
done > $data/feats.scp
|
||||
|
||||
rm $logdir/wav.*.scp $logdir/segments.* 2>/dev/null
|
||||
|
||||
nf=`cat $data/feats.scp | wc -l`
|
||||
nu=`cat $data/utt2spk | wc -l`
|
||||
if [ $nf -ne $nu ]; then
|
||||
echo "It seems not all of the feature files were successfully processed ($nf != $nu);"
|
||||
echo "consider using utils/fix_data_dir.sh $data"
|
||||
fi
|
||||
|
||||
echo "Succeeded creating PLP & Pitch features for $name"
|
Загрузка…
Ссылка в новой задаче