run_wpe.sh
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Copyright 2018 Johns Hopkins University (Author: Aswin Shanmugam Subramanian)
# Apache 2.0
. ./cmd.sh
. ./path.sh
# Config:
nj=4
cmd=run.pl
. utils/parse_options.sh || exit 1;
if [ $# != 3 ]; then
echo "Wrong #arguments ($#, expected 3)"
echo "Usage: local/run_wpe.sh [options] <wav-in-dir> <wav-out-dir> <array-id>"
echo "main options (for others, see top of script file)"
echo " --cmd <cmd> # Command to run in parallel with"
echo " --nj 50 # number of jobs for parallel processing"
exit 1;
fi
sdir=$1
odir=$2
array=$3
task=`basename $sdir`
expdir=exp/wpe/${task}_${array}
# Set bash to 'debug' mode, it will exit on :
# -e 'error', -u 'undefined variable', -o ... 'error in pipeline', -x 'print commands',
set -e
set -u
set -o pipefail
miniconda_dir=$HOME/miniconda3/
if [ ! -d $miniconda_dir ]; then
echo "$miniconda_dir does not exist. Please run '../../../tools/extras/install_miniconda.sh' and '../../../tools/extras/install_wpe.sh';"
fi
# check if WPE is installed
result=`$miniconda_dir/bin/python -c "\
try:
import nara_wpe
print('1')
except ImportError:
print('0')"`
if [ "$result" == "1" ]; then
echo "WPE is installed"
else
echo "WPE is not installed. Please run ../../../tools/extras/install_wpe.sh"
exit 1
fi
mkdir -p $odir
mkdir -p $expdir/log
# wavfiles.list can be used as the name of the output files
output_wavfiles=$expdir/wavfiles.list
find -L ${sdir} | grep -i ${array} > $expdir/channels_input
cat $expdir/channels_input | awk -F '/' '{print $NF}' | sed "s@S@$odir\/S@g" > $expdir/channels_output
paste -d" " $expdir/channels_input $expdir/channels_output > $output_wavfiles
# split the list for parallel processing
split_wavfiles=""
for n in `seq $nj`; do
split_wavfiles="$split_wavfiles $output_wavfiles.$n"
done
utils/split_scp.pl $output_wavfiles $split_wavfiles || exit 1;
echo -e "Dereverberation - $task - $array\n"
# making a shell script for each job
for n in `seq $nj`; do
cat <<-EOF > $expdir/log/wpe.$n.sh
while read line; do
$miniconda_dir/bin/python local/run_wpe.py \
--file \$line
done < $output_wavfiles.$n
EOF
done
chmod a+x $expdir/log/wpe.*.sh
$cmd JOB=1:$nj $expdir/log/wpe.JOB.log \
$expdir/log/wpe.JOB.sh
echo "`basename $0` Done."