forked from espnet/espnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_wav.sh
executable file
·77 lines (63 loc) · 1.75 KB
/
generate_wav.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
73
74
75
76
77
#!/bin/bash
# Copyright 2018 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# Begin configuration section.
nj=2
fs=22050
n_fft=1024
n_shift=256
cmd=run.pl
help_message=$(cat <<EOF
Usage:
$0 [options] <model-path> <data-dir> [<log-dir> [<fbank-dir>] ]
Example:
$0 ljspeech.wavenet.ns.v1/checkpoint-1000000.pkl data/train exp/wavenet_vocoder/train wav
Note:
<log-dir> defaults to <data-dir>/log, and <fbank-dir> defaults to <data-dir>/data
Options:
--nj <nj> # number of parallel jobs
--fs <fs> # sampling rate (default=22050)
--n_fft <n_fft> # number of FFT points (default=1024)
--n_shift <n_shift> # shift size in point (default=256)
--cmd (utils/run.pl|utils/queue.pl <queue opts>) # how to run jobs.
EOF
)
# End configuration section.
echo "$0 $*" # Print the command line for logging
. parse_options.sh || exit 1;
if [ $# -lt 2 ] || [ $# -gt 4 ]; then
echo "${help_message}"
exit 1;
fi
model=$1
data=$2
if [ $# -ge 3 ]; then
logdir=$3
else
logdir=${data}/log
fi
if [ $# -ge 4 ]; then
wavdir=$4
else
wavdir=${data}/data
fi
# use "name" as part of name of the archive.
name=$(basename ${data})
mkdir -p ${wavdir} || exit 1;
mkdir -p ${logdir} || exit 1;
scp=${data}/feats.scp
split_scps=""
for n in $(seq ${nj}); do
split_scps="$split_scps $logdir/feats.${n}.scp"
done
utils/split_scp.pl ${scp} ${split_scps} || exit 1;
${cmd} JOB=1:${nj} ${logdir}/generate_with_wavenet_${name}.JOB.log \
generate_wav_from_fbank.py \
--model ${model} \
--fs ${fs} \
--n_fft ${n_fft} \
--n_shift ${n_shift} \
scp:${logdir}/feats.JOB.scp \
${wavdir}
rm ${logdir}/feats.*.scp 2>/dev/null
echo "Succeeded creating wav for ${name}"