Linux Blog

Add Voice to your Shell Scripts

Filed under: Shell Script Sundays — TheLinuxBlog.com at 3:52 pm on Sunday, October 12, 2008

Text to speech has been around for a number of years. While you may not want to add text to speech to all of your shell scripts you may have a particular script that would be nice to get some audio feedback from. There are a couple of text-to-speech engines that run in the shell, but my favorite is flite. It is really simple to install and use and has a decent set of voices. You can add other voices or compile your own with FestVox.

Here is how to use flite from the shell to directly play the text:

[owen@TheLinuxBlog ~]$ flite -t "Thanks for reading The Linochs Blog"

Notice the misspelling of the word Linux. If flite doesn’t correctly output the words, you can sometimes use phonetics to get a better result.

You can also play text files by using the -f option.

[owen@TheLinuxBlog ~]$ flite -t "Thanks for reading The Linochs Blog"
flite: pcm_params.c:2333: sndrv_pcm_hw_params: Assertion `err >= 0' failed.

(Read on …)

Sorting lists with Sort

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 11:11 pm on Wednesday, June 4, 2008

There comes a time when it is useful to know how to sort lists. Thankfully using open source software sorting text files can be very easy.

This example shows how to sort a file alphabetically using the sort command. I assume that you have a text file in mind so I will skip the creation of that. There are two ways to sort the file with the sort command. The first being the preferred method but not always suitable.

sort [textfile]
 
cat [textfile] | sort

That’s it! The second method can be useful if you would like to do any thing special, for example searching with grep, using cut or sed for data extraction or just out of convenience. Check out the man page for sort for more information on all of the options!