Time-controlled information announcements with cron

Prepared information announcements can be sent out relatively easily shortly before the relay drops out – i.e. at a time when someone is still listening but nobody really wants to speak anymore. At this point, there is usually at least one listener who may have previously only touched the relay.

The information messages should not be longer than 20 seconds. For this purpose, the prepared WAV files are stored in a directory below
/usr/share/svxlink/sounds/de_DE, e.g. in LocalAudio. The files should all start with „Idle-„, e.g. Idle-00-OV-Abend-Einladung.wav

Further announcements for the use of the relay, the agreed speed dials, help transit passengers or other not yet comprehensively informed to find their way faster.

With the following procedure under /usr/share/svxlink/sounds/de_DE/events.d/local the prepared sound files can be viewed and played each time.

#
# Playing Info-wav when the relay is idle
#
# Draft DK5HH
#

namespace eval RepeaterLogic {

#Counter which Idle-sound shall be the next #
variable idle_nr 0;
variable last_idlesound 100000000;

# minimum time between 2 idle sounds in seconds
variable min_time_between_idlesound 300;

proc repeater_idle {} {
set filelist [get_idle_files];
set idle_max [llength $filelist];
set filelist [lsort -ascii $filelist];
variable idle_nr;
variable last_idlesound;
variable min_time_between_idlesound;
set now [clock seconds];
# more than 300 s since last idlesound
if {$now – $last_idlesound > $min_time_between_idlesound } {
set last_idlesound $now;
if { $idle_nr >= $idle_max } {
set idle_nr 0;
}
set psound [lindex $filelist $idle_nr]
set idle_nr [expr {$idle_nr + 1} ];
puts „playing Idle-Sound $psound. $idle_nr\/$idle_max“;
playMsg „LocalAudio“ $psound;
playSilence 800;
}
}
proc get_idle_files {} {
variable dir „/usr/share/svxlink/sounds/de_DE/LocalAudio“;
variable ext „wav“;
variable files „“;
foreach file [glob -nocomplain -directory $dir Idle-*.wav] {
set foundfile [file tail [file rootname $file]];
lappend files $foundfile;
}
return $files;
}

}
# end Namespace RepeaterLogic

With cron you can activate or deactivate the announcements by renaming them at a certain time – i.e. activate the announcement one week before the OV evening and deactivate it again during the OV evening. So: e.g. turn Idle-….. into idle-….. – Then the greeting „next week Tuesday is OV evening, don’t you want to come too?

Any user of the group svxlink can create an entry with crontab -e. The following small shell script idle-activate.sh is used:

#! /bin/bash
# called with cron to activate / decode
# From idle sounds
DIR=/usr/share/svxlink/sounds/en_DE/LocalAudio/
cd $DIR
ACTIVE=$1
if [ -z $ACTIVE ]
then
echo „usage: Parameter ON|OFF \“File pattern\““
fi
#U_ACT=tr ‚[:lower:]]‘ ‚[:upper:]]‘ $ACTIVE
if [ $ACTIVE = „ON“ ]
then
for renfile in $(find ./ -name „$2“ )
th
re1=$$(basename $renfile)
re2=${re1/idl/Idl}
mv $re1 $re2
done
fi
if [ $ACTIVE = „OFF“ ]
then
for renfile in $(find ./ -name „$2″ )
th
re1=$$(basename $renfile)
re2=${re1/Idl/idl}
mv $re1 $re2
done
fi

we put the small shell helper script idle-activate.sh in the $HOME directory of this user (e.g. dk5hh) and make it with

chmod 775 idle-activate.sh

executable.

As entry in the crontab is required (call with crontab -e)

# Normal OV night: first Tuesday
#2 21 * * 2 [ $(date +“\%m“) -ne $(date -d 7days +“\%m“) ] && /home/dk5hh/idle-activate.sh ONE „*OV-abend*“
#2 21 * * 2 [ $(date +“\%m“) -eq $(date -d 7days +“\%m“) ] && /home/dk5hh/idle-activate.sh OFF „*OV-abend*“
# Moved to second Tuesday OV night
2 21 * * 2 [ `date +\%e` -gt 0 -a `date +\%e` -lt 8 ] && /home/dk5hh/idle-activate.sh ON „*OV-abend*“
2 21 * * 2 [ `date +\%e` -gt 7 -a `date +\%e` -lt 15 ] && /home/dk5hh/idle-activate.sh OFF „*OV-abend*“

The entries in the crontab are called at 21:02 each Tuesday (here in the example), if the entry is not switched off with a „#“ as comment – here the first two lines.
The call of the program to be executed is a logical composition with „&&“. If the first part is logically true, the second part is executed.
The first part in [ … ] is also a logical combination with „-a“ (and). The command date is used to find and link the day of the month from the current date.

For the OV evening on the first Tuesday of the month it is especially easy. We simply check if the month of today’s Tuesday and the month of the next Tuesday have the same month in 7 days – if not, then we activate the idle sound.

If we have a lot of general information announcements that are not time-dependent and if we want to play individual announcements more frequently, we simply create a link to the sound file Idle-00-OV-abend-Einladung.wav:

ln -s Idle-00-OV-evening.invitation.wav Idle-10-OV-evening.link.wav

Several links with different numbers spread the announcement between the others. The list of the wav files to be played is rearranged alphabetically in the TCL procedure shown above.

Note: From our experience it seems good to use a TTS system (Text-to-Speech) with a pleasant voice for the processing of the announcements.