-
Notifications
You must be signed in to change notification settings - Fork 0
/
jingle_round_robin
executable file
·54 lines (48 loc) · 1.07 KB
/
jingle_round_robin
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
#!/bin/sh -eu
#
# This script is run every 10 minutes
musicdir=/home/broadcast/instanssi-musiikki
jingles=/home/broadcast/jingles.txt
ctrfile=/tmp/jingle-counter
insert () {
mpc insert "jingles/$1"
}
parse_line () {
read -r type args || return 1
case $type in
audio)
echo "Inserting $args"
insert "$args"
;;
voice)
echo "$args" | {
read -r lang msg
espeak-ng -w $musicdir/jingles/espeak.wav -v $lang -p 55 -s 200 "$msg"
echo "Inserting speech, lang: $lang, message: $msg"
insert espeak.wav
}
;;
*)
echo FATAL ERROR INVALID COMMAND $type
;;
esac
}
get_next () {
grep '^[^#]' $jingles | sed "$1q;d" | parse_line
}
# Do not insert jingle if there's already one in the queue
if mpc playlist -f %file% | grep -q ^jingles/; then
echo Jingle already queued. Long piece or live underway.
exit 0
fi
# Manual insertion
if test $# -ge 1; then
echo "$@" | parse_line
else
test -e "$ctrfile" && ctr=`cat $ctrfile` || ctr=1
get_next $ctr || {
ctr=1
get_next $ctr
}
echo $(( $ctr + 1 )) >$ctrfile
fi