forked from funcwj/setk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_cgmm.sh
executable file
·63 lines (48 loc) · 1.97 KB
/
run_cgmm.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
#!/usr/bin/env bash
# wujian@2018
set -eu
nj=40
cmd="run.pl"
iters=20
# stft.conf example:
# --frame-length 1024
# --frame-shift 256
# --window hann
# --center true
stft_conf=conf/stft.conf
init_mask=
num_classes=2
solve_permu=false
mask_format="numpy"
echo "$0 $@"
function usage {
echo "Options:"
echo " --nj <nj> # number of jobs to run parallel, (default=$nj)"
echo " --cmd <run.pl|queue.pl> # how to run jobs, (default=$cmd)"
echo " --stft-conf <stft-conf> # stft configurations files, (default=$stft_conf)"
echo " --iters <iters> # number of iterations to run CGMM, (default=$iters)"
echo " --num-classes <num-classes> # number of the cluster used in cgmm model, (default=$num_classes)"
echo " --solve-permu <solve-permu> # solve frequency permutation or not, (default=$solve_permu)"
echo " --init-mask <init-mask> # dir or script for mask initialization, (default=$init_mask)"
echo " --mask-format <kaldi|numpy> # mask storage type, (default=$mask_format)"
}
. ./path.sh
. ./utils/parse_options.sh || exit 1
[ $# -ne 2 ] && echo "Script format error: $0 <wav-scp> <dst-dir>" && usage && exit 1
wav_scp=$1
dst_dir=$2
for x in $wav_scp $stft_conf; do [ ! -f $x ] && echo "$0: missing file: $x" && exit 1; done
dirname=$(basename $dst_dir)
exp_dir=./exp/cgmm/$dirname && mkdir -p $exp_dir
stft_opts=$(cat $stft_conf | xargs)
split_wav_scp="" && for n in $(seq $nj); do split_wav_scp="$split_wav_scp $exp_dir/wav.$n.scp"; done
./utils/split_scp.pl $wav_scp $split_wav_scp
cgmm_opts="--num-iters $iters --num-classes $num_classes --solve-permu $solve_permu"
[ ! -z $init_mask ] && cgmm_opts="$cgmm_opts --init-mask $init_mask --mask-format $mask_format"
mkdir -p $dst_dir
$cmd JOB=1:$nj $exp_dir/log/run_cgmm.JOB.log \
./scripts/sptk/estimate_cgmm_masks.py \
$stft_opts $cgmm_opts \
$exp_dir/wav.JOB.scp \
$dst_dir
echo "$0: Estimate mask using CGMM methods done"