Add continuous announcement server.

This commit is contained in:
Dejvino 2021-01-09 14:22:58 +01:00
parent ccc5c82dba
commit 0cf4c4890d
2 changed files with 41 additions and 5 deletions

21
bin/announcement-server Executable file
View 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

View File

@ -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 "$@"
}