Weather forecast by voice



How to make a script that tells the weather.



Weather forecast by FreeBSD voice.



I often saw people at work look at the weather forecast, look for data on some sites, or my acquaintances asked me:


- have you watched the weather.

This is not for me, I don’t want to look for the weather on sites, look at the data for a certain period and compare it with other sources. I always thought that at any time you can look at the thermometer in the kitchen and dress for the weather. Therefore, I wrote a simple Shell script script for the Bourne shell, which simply when you click on it tells the weather at the moment. Yes, there are cases of work or household nature when you need to know in advance, for example, when there will be frosts. For these purposes, you can always change the script.


Under the article, watch a demo video of this script.



Let's start writing the script.


First, we need to install and configure a speech synthesizer called Festival. I have already written how to do this in the FreeBSD operating system on my website, so I will not talk about it now, but I will go directly to the script. How to install Festival speech synthesizer on FreeBSD you can read in my previous article "Learning to speak FreeBSD".


So we create a file with any name with the extension sh, for me it is We write the following lines into it:







wget -q -O- "$URL" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $10". градусов сейчас в. " }'| head -1 > /tmp/pogoda


wget -q -O- "$URL" | awk -F\" '/acm_RecentLocationsCarousel\.push/{print $2"." }'| head -1 >> /tmp/pogoda


wget -q -O- "$URL" | awk -F\: '/acm_RecentLocationsCarousel\.push/{print $9"." }'| head -1 >> /tmp/pogoda


festival --language russian --tts /tmp/pogoda


That's the whole script, it will create a pogoda file in catalol /tmp into which it will write down the weather data in your city. And the Festival speech synthesizer will already read the contents of the pogoda file.


The example shows the city of Kiev, this is the top line of the URL



https: // www.


https: //



Thus, you can select any city.



Oh yeah, and don't forget to make the script executable with the command:



chmod a+x