Add continuous announcement server.
This commit is contained in:
parent
ccc5c82dba
commit
0cf4c4890d
21
bin/announcement-server
Executable file
21
bin/announcement-server
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
source pa-lib
|
||||
|
||||
while [[ true ]]; do
|
||||
# waiting for the PSA text stream to start
|
||||
read
|
||||
|
||||
pa-preheat
|
||||
pa-announcement
|
||||
pa-say "$REPLY"
|
||||
while read -t 4; do
|
||||
pa-say "$REPLY"
|
||||
done
|
||||
|
||||
# no more text, terminate the PSA
|
||||
pa-announcement-quick
|
||||
pa-shutdown
|
||||
done
|
||||
|
||||
|
25
bin/pa-lib
25
bin/pa-lib
@ -7,12 +7,15 @@ export SOUNDS=$ROOT/sounds
|
||||
export PLAYER=mplayer
|
||||
export SPEAK=espeak-ng
|
||||
|
||||
ALARM_PID=-1
|
||||
STATIC_PID=-1
|
||||
|
||||
function info() {
|
||||
echo "[INFO]" $@
|
||||
}
|
||||
|
||||
function play() {
|
||||
$PLAYER $@ > /dev/null 2>&1
|
||||
cat /dev/null | $PLAYER $@ > /dev/null 2>&1
|
||||
}
|
||||
|
||||
function pa-volume() {
|
||||
@ -49,7 +52,8 @@ function pa-preheat() {
|
||||
info "PA Preheating"
|
||||
pa-power off
|
||||
pa-volume-normal
|
||||
play $SOUNDS/announcement_4-tone_up_quickest.ogg
|
||||
pa-static-start 40
|
||||
play $SOUNDS/announcement_4-tone_up_quick.ogg
|
||||
pa-power on
|
||||
info "PA Ready"
|
||||
}
|
||||
@ -58,7 +62,7 @@ function pa-shutdown() {
|
||||
info "PA Shutdown"
|
||||
pa-power off
|
||||
pa-volume-normal
|
||||
killall $PLAYER
|
||||
killall $PLAYER >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function pa-announcement() {
|
||||
@ -78,17 +82,28 @@ function pa-announcement-quickest() {
|
||||
|
||||
function pa-alarm-start() {
|
||||
info "Alarm started"
|
||||
kill $ALARM_PID 2>/dev/null
|
||||
play -loop 0 $SOUNDS/alarm_simple.ogg &
|
||||
ALARM_PID=$!
|
||||
}
|
||||
|
||||
function pa-alarm-stop() {
|
||||
info "Alarm stopped"
|
||||
killall $PLAYER
|
||||
kill $ALARM_PID 2>/dev/null
|
||||
}
|
||||
|
||||
function pa-static-start() {
|
||||
kill $STATIC_PID 2>/dev/null
|
||||
play -loop 0 -volume ${1:--1} -softvol $SOUNDS/static.ogg &
|
||||
STATIC_PID=$!
|
||||
}
|
||||
function pa-static-stop() {
|
||||
kill $STATIC_PID 2>/dev/null
|
||||
}
|
||||
|
||||
function pa-say() {
|
||||
info "Say: $@"
|
||||
$SPEAK "$@"
|
||||
cat /dev/null | $SPEAK "$@"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user