36 lines
758 B
Bash
Executable file
36 lines
758 B
Bash
Executable file
#!/bin/bash
|
|
|
|
cd "$(dirname "$0")"
|
|
line="$1"
|
|
snd="$2"
|
|
. config.txt
|
|
|
|
./ann_end.sh "$line" # and any existing calls to prevent our call ending up in "call waiting" state (and thus not autoanswered)
|
|
sleep 0.5
|
|
./autoanswer_line.sh "$line" 1 || { echo >&2 "failed to enable autoanswer, exiting."; exit 1; }
|
|
|
|
playstring="silence/1"
|
|
i=0
|
|
for arg in "$@"; do
|
|
if [[ "$arg" =~ ^silence ]]; then
|
|
playitem="$arg"
|
|
else
|
|
ffmpeg -i "$arg" -ar 8000 -ac 1 -y /tmp/ann${line}_$i.wav
|
|
playitem=/tmp/ann${line}_$i
|
|
fi
|
|
playstring="$playstring&$playitem"
|
|
i=$((i+1))
|
|
done
|
|
|
|
fn=/var/spool/asterisk/tmp/ann_$line.call
|
|
echo "
|
|
Channel: PJSIP/emerg$line
|
|
Application: Playback
|
|
Data: $playstring
|
|
Priority: 1
|
|
" >$fn
|
|
|
|
mv "$fn" /var/spool/asterisk/outgoing/
|
|
|
|
./ann_volup.sh "$line" &
|
|
|