Previous Page
PCLinuxOS Magazine
Article List
Next Page

Say It Out Loud With googlesay

by critter

I have an announcement...

Texstar recently introduced a new utility, called googlesay, to forum members. Install the file from the PCLinuxOS repository, along with any dependencies.

To use it, type something along the lines of:

googlesay "Welcome" en

Anything inside the quotes will be spoken, and the 'en' is the language code. Since I live in the UK, I get a British English accent. To make it an American accent, use en-us. Similarly, you can use de, fr, it etc., to add an accent to the spoken language. Try

googlesay "Wilkommen" de

The googlesay utility is actually a small bash script, and as such, it understands things like environment variables passed in the text.

To make use of this I wrote the following script:


DAY=$(date '+%A')
MONTH=$(date '+%B')
DATE=$(date '+%e')
googlesay "Welcome to $HOSTNAME, Today is $DAY $MONTH $DATE" en-us

I made it executable with the command chmod +x

I then added it to my start up files. To do this in KDE, open Configure Your Desktop > Startup and Shutdown > Autostart. Click on add script and browse to the script. If you are not using KDE and don't know how to do this, then you could have a look at one of the excellent special editions on the magazine website. Most desktop types have been covered.

I now get reminded of the date every time I restart my computer.

If you would like to add a comment when you start up an application, it can be done in a similar manner. For example, to create a new document in LibreOffice, and be asked which type of document you want, you could use this.

$(sleep 2 ; googlesay "Please select a document type" en-us) &
exit 0

The sleep command is to allow the application to appear before the speech starts, and you may need to adjust this. Also, if you are using a version of LibreOffice other than 4.1, then adjust this value. Name the script, save it to your home directory, make it executable with chmod +x and then add the following to your .bashrc file.

alias office='~/'

Type office in a terminal to run it (You may have to restart the terminal to activate the new alias). Alternatively, you could add an icon to your desktop or panel. Open a text editor and enter the following text:

[Desktop Entry]
Comment=Show System Infos
Exec=systeminfo %U

Save it as office.desktop and the drop it onto your desktop.

If you have a home network and you are the administrator (have access to other accounts), you could leave a birthday or anniversary message for a family member. In fact, you could get up to all sorts of mischief if you were so inclined.

Now, with googlesay, you can not only just launch a program, but you can announce it aloud.

Previous Page              Top              Next Page