Thursday 30 May 2013

Preliminary setup

In this post, I'll outline the preliminary steps you need to get text-to-speech working.  This can be done entirely from the terminal or through SSH, but if you are more comfortable using the GUI, there are places you can use that instead.

It's probably best to start with a fresh image of Raspbian, but if you want to add this to an existing image, it will almost certainly still work.

First, you need some speakers.  It shouldn't matter if they are going through the audio jack or USB.

Next, follow steps 1-4 from the RPI Text to Speech guide on the Wiki.
You may already have alsa-utils installed, but it's best to run the command anyway to check.

Then, instead of installing mplayer, we want to install mpg123.
Run 'sudo apt-get install mpg123', hit 'y' and wait for it to install.

Following that, create a file called 'speech.sh' with nano (nano speech.sh) and copy the script from this site into the file.

For those not familiar with scripts, copy everything from '#!/bin/bash' to 'done', then (if you're using nano) press 'ctrl+x' then 'y' when prompted to save the file.

Finally, give the script execute permission by running 'sudo chmod +x speech.sh'.

You can test this is working by running the script with './speech.sh' followed by a string of text you want spoken.

For instance, if you want to have it say 'Hello world', you'd run './speech.sh hello world'.  If everything has worked, you should hear 'hello world' from your speakers.

Coming soon, my horribly crude C program :-)

1 comment:

  1. Cant wait for the C program part, Ive got this initial part up and running, I am hoping to put this to use throughout my apartment once I can get it up and going, thank you for all the work you have put in already

    ReplyDelete