Fun Uses for Speech

Now to turn the cute to the useful.  Organizations are predicting that voice will surpass typing in the future.  If voice will be the primary input method, voice can be the informational output (it is much more useful to get information with earbuds than carrying a 24 inch LCD display with you).

Reading to You

Speaking content in other file formats usually requires a conversion of the file to a text format. PDF is a popular format for documents and some eBooks. Fortunately the default Rasbian Jessie has a great utility, pdftotext, which has alot of options if you need them (you can just type pdftotext to get the list).  The basics are rather easy.  Say you have mydocument.pdf on your Pi. 

Download: file
pdftotext mydocument.pdf mydocument.txt
festival --tts mydocument.txt

Reading Your Fortune

Nearly all Unix and Linux systems have a utility called fortune which reads you a random quote for the day.  I'm not sure why Rasbian does not have it by default but it is available to load:

Download: file
sudo apt-get install fortune-mod

Then whenever you want to have a new fortune read, type:

Download: file
fortune | festival --tts

To read a selection of fortunes to see what output is generates, just type fortune at the command prompt.  To read about adding your own qoutes to the fortune database on your Pi, see this thread on the Rasberry Pi forums.

Reading the Weather

There is a cool utility for Linux, weather-util, that is able to look up local weather given a location code.  Install the package:

Download: file
sudo apt-get install weather-util

When loaded, you can type weather to see what options there are.  The program will accept airport identification codes, city and state names, and more.  It will search an online database to find matching locations. If the number of locations is too big (typing weather washington for example), it will ask for a narrower search. If you get close but still too many, it will prefix each with a "fips number". Typing weather followed by a specific fips number will pick that unique location. For example:

Download: file
weather nyz072

Using a broad query such as "washington" results is too ambiguous. 

Ok, let's be more specific:

So to get the specifc location, we can type the fips number:

weather will now cache this location so it does not have to do such an extensive search next time.  For speaking the weather, we do not want any of the text before the temperature, so caching one time and adding the -q (quiet) flag gets us the text we want to be read.  So to speak the Boise weather, we can feed the weather output into flite:

Download: file
weather -q fips1600190345 | festival --tts

and it will sound like:

This guide was first published on Feb 01, 2016. It was last updated on Feb 01, 2016. This page (Fun Uses for Speech) was last updated on Jun 24, 2019.