-
Notifications
You must be signed in to change notification settings - Fork 55
/
run_cgmm_beamforming.sh
72 lines (53 loc) · 1.69 KB
/
run_cgmm_beamforming.sh
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
#!/bin/bash
# modified from local/run_beamform_6ch_track.sh
. ./path.sh
nj=10
cmd=run.pl
. utils/parse_options.sh || exit 1;
if [ $# != 2 ]; then
echo "Wrong #arguments ($#, expected 2)"
echo "Usage: local/run_cgmm_beamforimg.sh [options] <wav-in-dir> <wav-out-dir>"
echo "main options (for others, see top of script file)"
echo " --nj <nj> # number of parallel jobs"
echo " --cmd <cmd> # Command to run in parallel with"
exit 1;
fi
src_dir=$1
dst_dir=$2
cgmm_dir='data/cgmm'
[ -d $cgmm_dir ] && rm -rf $cgmm_dir && echo "$0: $cgmm_dir existed, regenerated it."
mkdir -p $cgmm_dir
ln -s $(cd $src_dir; pwd) $cgmm_dir/6ch || exit 1
ln -s $(cd $dst_dir; pwd) $cgmm_dir/dst || exit 1
prefix_all=$cgmm_dir/prefix
find $src_dir/{dt,et}*{simu,real}/ | grep CH1.wav \
| awk -F '/' '{print $(NF-1) "/" $NF}' | sed -e "s/\.CH1\.wav//" | sort > $prefix_all
split_list=""
for n in $(seq $nj); do
split_list="$split_list $prefix_all.$n"
done
utils/split_scp.pl $prefix_all $split_list || exit 1
func_path=$(cd local; pwd)
for n in $(seq $nj); do
cat << EOF > $cgmm_dir/run_cgmm_$n.m
addpath('$func_path');
src_dir = '6ch';
dst_dir = 'dst';
prefix_list = textread('prefix.$n', '%s');
prefix_size = size(prefix_list);
for i = 1: prefix_size(1)
prefix = char(prefix_list(i))
in = [src_dir '/' prefix];
out = [dst_dir '/' prefix];
apply_cgmm_beamforming(in, out);
end
EOF
done
for x in $(awk -F '/' '{print $1}' $prefix_all | sort | uniq); do
mkdir -p $dst_dir/$x
done
cd $cgmm_dir
$cmd JOB=1:$nj log/beamform.JOB.log \
matlab -nojvm -nodisplay -nosplash -r run_cgmm_JOB
echo "$0: run CGMM done"