forked from aclew/Yunitator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-htk-vm2.sh
executable file
·59 lines (49 loc) · 1.41 KB
/
extract-htk-vm2.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
#!/bin/bash
# Use OpenSMILE 2.1.0 only
if [ $# -lt 1 ]; then
echo "USAGE: extract-htk.sh <INPUT FILE> <TEMP FOLDER>"
exit 1
fi
filename=$(basename "$1")
dirname=$(dirname "$1")
extension="${filename##*.}"
basename="${filename%.*}"
FEATURE_NAME=med # arbitrary - just a name
INPUT=$1
TEMP=$2
CONFIG_FILE=MED_2s_100ms_htk.conf
OUTPUT_DIR=$dirname/$TEMP/
OPENSMILE=SMILExtract
mkdir -p $OUTPUT_DIR
file=$INPUT
id=`basename $file`
echo "Extracting features for $id ..."
id=${id%.wav}
nosplit=1200
duration=`soxi -D $file|awk '{print int($1)}'`
if [ $duration -gt $nosplit ]; then
# If the audio file is longer than about 15 minutes, let's
# split it up to avoid running our of memory
split=0
while [ $split -lt $duration ]; do
echo Now at $split of $duration ...
LD_LIBRARY_PATH=/home/vagrant/usr/local/lib \
$OPENSMILE \
-C <(awk -v s=$split '/append=/ {if (s==0) {print ("append=0")} else {print ("append=1")}}; !/append=/ {print $0}' $CONFIG_FILE) \
-I <(sox -q $file -t wav - trim $split $nosplit) \
-O $OUTPUT_DIR/${id}.htk \
-logfile extract-htk.log
split=`echo $split+$nosplit|bc`
done
else
# This is the original code, we use it for shorter utterances
# Use OpenSMILE 2.1.0
LD_LIBRARY_PATH=/home/vagrant/usr/local/lib \
$OPENSMILE \
-C $CONFIG_FILE \
-I $file \
-O $OUTPUT_DIR/${id}.htk \
-logfile extract-htk.log # \
#>& /dev/null
fi
echo "DONE!"