Updated to a more reliable weather service for talking-clock.

This commit is contained in:
Storm Dragon 2019-09-15 00:40:45 -04:00
parent 0c033aca21
commit a862b9cc4a
2 changed files with 10 additions and 14 deletions

View File

@ -23,16 +23,16 @@ or
paplay
Note that with the ogg123 command the aplay command is used for the pico voice. Aplay will not work for the rest of the commands because it does not play ogg files.
-c --nochime Turn off chimes.
-k --key Your weatherstack.com api key. You can get one for free from weatherstack.com
-n --nospeak turn off spoken time.
-s --soundpack Set path to soundpack. Sound packs should be in ogg format and contain 1.ogg, 2.ogg, ... 11.ogg, 12.ogg and 15.ogg, 30.ogg, and 45.ogg for the quarter-hour chimes.
-t --torify anonymously get your current temperature, used with -z --zipcode.
-v --voice Select voice. Default is espeak other options are
cepstral, espeak, festival, flite, flite_time, gama_tts, googletts (requires the translate-shell package), pico, sam, speech-dispatcher and custom.
If your tts files for gama_tts are somewhere other than /usr/local/share/gama_tts/data/english/ then you can specify it in your ~/.config/talking-clock/talking-clockrc. Just do gama_tts_path="/path/to/tts/vtmN where N is the number you want.
To set a custom voice enter the command as in:
-v 'espeak -v en-us+klatt2'
zipcode and flite_time are incompatable. If you have zipcode set the temperature will not be read while using flite_time.
-z --zipcode Postal code: Will speak the temperature along with the time so long as you do not have nospeak set. E.G. -z 90210
-z --zipcode Postal code: Will speak the temperature along with the time so long as you do not have nospeak set. E.G. -z 90210.
talking clock can also read settings from the following files?
/etc/talking-clockrc global settings
@ -47,7 +47,6 @@ soundpack=/home/USER/thunderstorm
chime=true
speak=true
zipcode=90210
torify=true
Soundpack should be the path to a directory. Do not include the trailing / talking-clock adds it for you.
voice=espeak -v en-us+klatt2 -s 300
Be careful when using custom voice commands, if it is not valid the program will not work. You do not have to specify parameters for voice commands if you want to use the defaults. You can use voice=espeak (this is the default), voice=cepstral, voice=speech-dispatcher, voice=pico, or voice=festival.

View File

@ -15,6 +15,7 @@ half-hour, 4 every quarter, and anything else will delete your existing settings
-a --audio Command for playing sound. The default is play -q provided from the sox package.
-c --nochime Turn off chimes.
-f --format: 12 or 24 hour format. Default is 12 hour time.
-k --key: weatherstack.com api key. This is required for temperature and forecast. You can get a key for free.
-n --nospeak turn off spoken time.
-s --soundpack Set path to soundpack. Sound packs should be in ogg format and contain 1.ogg, 2.ogg, ... 11.ogg, 12.ogg and
15, 30, and 45.oggfor the quarter-hour chimes.
@ -22,7 +23,6 @@ half-hour, 4 every quarter, and anything else will delete your existing settings
cepstral, espeak, festival, gama_tts, pico, sam, speech-dispatcher and custom.
To set a custom voice enter the command as in:
-v 'espeak -v en-us+klatt2'
-t --torify retrieve temperature anonymously using torify, used with -z --zipcode
-z --zipcode postal code Used for current temperature, may not be available inn all areas.
For complete information read the README located at /usr/share/talking-clock/README"
EOF
@ -305,12 +305,13 @@ while [ $# -gt 0 ] ; do
exit 1
fi
;;
"-k" | "--key")
shift
key="$1"
;;
"-n" | "--nospeak")
speakTime="false"
;;
"-t" | "--torify")
torify="true"
;;
"-c" | "--nochime")
chime="false"
;;
@ -357,13 +358,9 @@ if [ "$speakTime" == "true" ] ; then
timeString="${timeString} $(number_to_text $minute)"
fi
fi
#Add temperature if zipcode is set
if [ -n "$zipcode" ] ; then
if [ "$torify" == "true" ] ; then
temperature="$(torify curl -s "http://wttr.in/$zipcode?T0" | grep -m 1 -Eo -e '-?[[:digit:]].*[CF]' | cut -d ' ' -f1 | sed 's/.*-//')"
else
temperature="$(curl -s "http://wttr.in/$zipcode?T0" | grep -m 1 -Eo -e '-?[[:digit:]].*[CF]' | cut -d ' ' -f1 | sed 's/.*-//')"
fi
#Add temperature if key is set
if [ -n "$key" ] ; then
temperature="$(curl -s "http://api.weatherstack.com/current?access_key=$key&query=${zipcode:-fetch:ip}&units=${units:-f}" | jq '.current.temperature')"
if [ -n "$temperature" ] ; then
if [ "$format" = "24" ]; then
timeString="$timeString and $(number_to_text $temperature) degrees."