prep_air.sh
2.4 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
#!/bin/bash
# Copyright 2015 Johns Hopkins University (author: Vijayaditya Peddinti)
# Apache 2.0
# This script downloads the Aachen impulse response database
# http://www.ind.rwth-aachen.de/en/research/tools-downloads/aachen-impulse-response-database/
#==============================================
download=true
sampling_rate=8000
DBname=AIR
file_splitter= #script to generate job scripts given the command file
. ./cmd.sh
. ./path.sh
. ./utils/parse_options.sh
if [ $# != 3 ]; then
echo "Usage: "
echo " $0 [options] <rir-home> <output-dir> <log-dir>"
echo "e.g.:"
echo " $0 --download true db/RIR_databases/ data/impulses_noises exp/make_reverb/log"
exit 1;
fi
RIR_home=$1
output_dir=$2
log_dir=$3
if [ "$download" = true ]; then
mkdir -p $RIR_home
(cd $RIR_home;
rm -rf air_database_release_1_4.zip
wget http://www.openslr.org/resources/20/air_database_release_1_4.zip || exit 1;
unzip air_database_release_1_4.zip > /dev/null
)
fi
AIR_home=$RIR_home/AIR_1_4
# AIR impulse responses
#----------------------
# data is stored in mat files with info about the impulse stored in a structure
type_num=1
python local/multi_condition/get_air_file_patterns.py $AIR_home > $log_dir/air_file_pattern
files_done=0
total_files=$(cat $log_dir/air_file_pattern|wc -l)
echo "" > $log_dir/${DBname}_type$type_num.rir.list
echo "Found $total_files impulse responses in ${AIR_home}."
command_file=$log_dir/${DBname}_read_rir_noise.sh
echo "">$command_file
file_count=1
while read file_pattern output_file_name; do
# output_file_name=`echo ${DBname}_type${type_num}_${file_count}_$output_file_name| tr '[:upper:]' '[:lower:]'`
output_file_name=`echo ${DBname}_type${type_num}_$output_file_name| tr '[:upper:]' '[:lower:]'`
echo "local/multi_condition/read_rir.py --output-sampling-rate $sampling_rate air '${file_pattern}' ${output_dir}/${output_file_name} || exit 1;" >> $command_file
echo ${output_dir}/${output_file_name} >> $log_dir/${DBname}_type$type_num.rir.list
file_count=$((file_count + 1))
done < $log_dir/air_file_pattern
if [ ! -z "$file_splitter" ]; then
num_jobs=$($file_splitter $command_file || exit 1)
job_file=${command_file%.sh}.JOB.sh
job_log=${command_file%.sh}.JOB.log
else
num_jobs=1
job_file=$command_file
job_log=${command_file%.sh}.log
fi
# execute the commands using the above created array jobs
time $decode_cmd --max-jobs-run 40 JOB=1:$num_jobs $job_log \
sh $job_file || exit 1;