Help with script

3 posts / 0 new
Last post
k8hw
k8hw's picture
Help with script

Can someone explain how exactly to use the Voice_alert.sh script?
Thanks in advance!

Dave - k8hw

oh1kh
Help with script

HI Dave!
Use script file name as ~/.config/cqrlog/voice_keyer/voice_alert.sh
When alert condition is met Cqrlog will call script file named that way. It will add parameters after file name that include the reason of alert, callsign locator and text information.
Cqrlog' may use string like this for calling the script:
~/.config/cqrlog/voice_keyer/voice_alert.sh call SV5AZK km 46 Dodecanese EU:New mode country!!

Now the scipt itself should pick the parameter information from that line. For that the variable $(num) is used.
$1 pics up the "call", $2 the callsign, $3 main grid's two first letters ... and so on.

To get different kind of alert sound you have to create sound files that are named with 1ST parameter's name added with ".mp3"
To get sound for callsign alert you have to generate audio file called "call.mp3" Keep it short so it does not play too long.
Do the same for other types of alerts.
Then you need to call the player program (that is small and fast and can run on background without graphical view). Like:
mpg123 ~/.config/cqrlog/voice_keyer/$1.mp3
mpg123 will play the sound file found from same folder as voice_alert script and the audio files name is generated from the first parameter string added with ".mp3"
Here is my currently used script. The first line tells it shoudl be run in bash and second line writes a log to /tmp folder called alerts.txt that holds all parameters the script has received. (It is just for debugging)
Then there are lots of explanations (starting with "#") and finally the last line does the job calling mpg123

#!/bin/bash
echo $1 $2 $3>>/tmp/alerts.txt
# Use script name as ~/.config/cqrlog/voice_keyer/voice_alert.sh
#
# //audio file name (prefix) played on alert. Parameter comes from cqrlog as 1st parameter string that can be:
# // my = ansver to me
# // loc = new main grid
# // text = text found from monitor line
# // call = text fits to the callsign
# // create files you want to be played using these as filename prefixes
#(I.E my.wav or my.mp3 ... etc Note:! use low case letters in names)
#
# This scirpt is seeking names with '.wav' suffix! Change if needed (below)
# select audio card(if several cards and selection is needed) here:
#
# next line does the whole job! $1 is replaced by cqrlog to prefixes listed at top of this script
# you need to have aplay installed if you use this, but you can define your own script, too.
#
#message=$(echo $2 | sed -r 's/[ ]+/_/g')
#export $message
#/home/saku/.config/cqrlog/sendbot.sh $message
#
mpg123 ~/.config/cqrlog/voice_keyer/$1.mp3

What is interesting addition are the three out commented (with "#") lines before line "mpg123"
Releasing them (remove #s) voice_alets script will generate a message from parameters and use it as parameter for calling another script named "sendbot.sh"
That sendbot.sh message will generate a Telegram message and send it to my bot in Telegram. That way I can receive alerts to my smartphone when needed.

The sendbot script looks like this (API key and ID are changed to nonsense)

#!/bin/sh
#
api_key="adfjaskdjfsd194892375891kfjskdf89fjaskdf"
chat_id="0010101012324"
curl -s "https://api.telegram.org/bot$api_key/sendMessage?chat_id=$chat_id&text=$message"

You can get the ID and API key for your own bot from Telegram IDBot and BothFather bots.

So you can see that only imagination is limit for alert scripts. As well you script could start your hamshack lights or cook coffee when alert condition is met :-)

--
Saku
OH1KH

k8hw
k8hw's picture
Help with script

Hi Saku!
Thanks so very much for all your help. I got it working and looks like I can have some fun with this! Again, Thanks for the assist.
73 Dave k8hw