-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathone-op.sh
More file actions
executable file
·59 lines (44 loc) · 1.29 KB
/
Copy pathone-op.sh
File metadata and controls
executable file
·59 lines (44 loc) · 1.29 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
#!/bin/bash
# $1 src
# $2 dst
# $3 opnr (0-15)
BASEDIR=$(basename $(echo $0))
DIR=$(echo $0 | sed 's/'$BASEDIR'//g')
. $DIR/ops.sh
init_ops
SR=$(soxi "$1" | grep Sample\ Rate | awk '{ print $4 }')
MINS=$(soxi "$1" | grep Duration | sed 's/:0/:/g' | sed 's/:/\ /g' | sed 's/\./\ /g' | awk '{ print $3 }')
SECS=$(soxi "$1" | grep Duration | sed 's/:0/:/g' | sed 's/:/\ /g' | sed 's/\./\ /g' | awk '{ print $4 }')
LEN=$((($MINS * 60) + $SECS + 1))
echo file: $1 is $MINS mins and $SECS secs
DOCHOP=0
if [ $LEN -gt 300 ]; then
echo "File is more than five minutes long ("$LEN" secs). Taking a segment."
STARTSEC=$(($RANDOM % $LEN))
REMAIN=$(($LEN - $STARTSEC))
END=$(($RANDOM % $REMAIN))
ENDSEC=$(($STARTSEC + $END))
echo Chopping from $STARTSEC to $ENDSEC
DOCHOP=1
fi
if [ $DOCHOP -eq 1 ]; then
ARGS="trim $STARTSEC $ENDSEC "
fi
OPNR=$3
CMD=${cmds[$OPNR]}
T=$(eval "$DIR/$CMD $LEN")
ARGS="$ARGS $T"
echo $ARGS
timeout -k 30s 15m \
sox --multi-threaded -S "$1" "$2" \
$ARGS norm -3 \
compand 0.3,1 6:-70,-60,-20 -5 -90 0.2 \
silence 1 0.1 0.1% reverse silence 1 0.1 0.1% reverse
# TODO use remix instead of channels
# sox --multi-threaded -S "$1" "$2" $ARGS norm -3 channels 2 \
FN=$(echo "$2" | sed 's/\.wav$//')
echo "$ARGS" > "$FN.txt"
if [ ! -f "$2" ]; then
exit
fi
echo