-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfox.sh
78 lines (62 loc) · 1.88 KB
/
fox.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
78
#!/bin/bash
# Raspberry Pi 'FoxInABox'
#
# 2016 - Slim Shady & Thick Shady
if [[ "$1" == --no-wait ]] ; then
NOWAIT=TRUE
fi
cd /boot/fox/
echo "17" | sudo tee /sys/class/gpio/export
echo "out" | sudo tee /sys/class/gpio/gpio17/direction
#echo "1" | sudo tee /sys/class/gpio/gpio17/active_low
echo "0" | sudo tee /sys/class/gpio/gpio17/value
while [ TRUE ] ; do
while read line; do
# Array of conditionals to interpret script.txt file
if [[ "$line" == wait* ]] ; then # Wait command
if [ $NOWAIT ] ; then
sleep 5
else
sleep $(echo $line | cut -c5-)
fi
elif [[ "$line" == \#* ]] ; then # Don't parse comments
echo -n
elif [[ "$line" == "" ]] ; then # Don't parse empty lines
echo -n
elif [[ "$line" == key* ]] ; then # Key command
echo Keying radio
echo "1" | sudo tee /sys/class/gpio/gpio17/value
elif [[ "$line" == unkey* ]] ; then # Key command
echo -n Unkeying radio
echo "0" | sudo tee /sys/class/gpio/gpio17/value
elif [[ "$line" == sayfile* ]] ; then # Say file command
FILE=$(echo $line | cut -c8-)
echo $FILE
cat $FILE | festival --tts
elif [[ "$line" == sayfcmd* ]] ; then # Say file command
CMD=$(echo $line | cut -c8-)
echo $CMD
SAY=$(eval $CMD)
echo $SAY
pico2wave -w /tmp/audio.wav "$SAY"
play -v .25 /tmp/audio.wav > /dev/null 2>&1
elif [[ "$line" == sayf* ]] ; then # Unkey command
SAY=$(echo $line | cut -c5-)
echo $SAY
pico2wave -w /tmp/audio.wav "$SAY"
play -v .25 /tmp/audio.wav > /dev/null 2>&1
elif [[ "$line" == saycmd* ]] ; then # Say file command
CMD=$(echo $line | cut -c8-)
echo $CMD
eval $CMD | festival --tts
elif [[ "$line" == say* ]] ; then # Say command
SAY=$(echo $line | cut -c4-)
echo $SAY
echo $SAY | festival --tts
else # Play files
echo -n Playing $line...
play -v .25 $line > /dev/null 2>&1
echo done!
fi
done < script.txt
done