.

Writing mostly about computers and math.

📅 

I got bored this evening so I thought I'd try to figure out how to get text-to-speech working on my Raspberry Pi. I have my Pi running Raspbmc and it's pretty great, but I'm always looking for little things to add to it, so I decided to install eSpeak so I could make my TV talk to me.

It's actually really easy to do this, but I'm recording the steps here in case I have to do it again next time my SD card has a senior moment.

Prerequisites

eSpeak requires a few things to be done before it will work. First of all, Raspbmc does not load the audio HAL for the Broadcom SOC by default and eSpeak (or mplayer, not sure which) needs it to output sound. To enable it just do

sudo modprobe snd_bcm2835

To make that permanent add snd_bcm2835 to the end of /etc/modules.

Next, you need to install alsa-libs, mplayer, and of course, eSpeak.

sudo apt-get update
sudo apt-get install alsa-libs mplayer espeak

mplayer supports LIRC by default, which is neat, but it seems to make it impossible to run mplayer from the terminal. To disable it, add nolirc=yes (why isn't it lirc=no?) to the end of /etc/mplayer/mplayer.conf.

Using eSpeak

Using eSpeak from the terminal is very easy. I've found the default options to work fine for me, so I just do this when I want to hear some words:

espeak "Some words."

eSpeak has a lot of options to play with, but I'm perfectly happy with the defaults. You can read eSpeak's man page for more details.

There are other text-to-speech programs for Debian that will work on the Raspberry Pi, but I think eSpeak strikes the best balance between speed and intelligibility. Festival, for example, is an excellent text-to-speech synthesizer as free synthesizers go, but it's too CPU-intensive to work quickly (or correctly, in my experience) on the Raspberry Pi. If you want to try it, follow these steps but install the package "festival" instead of "espeak". Or install both of them; I don't care.

I still don't know what I want to use this for of course, but I'm sure I'll come up with something eventually.