RPItalk: Building a hardware speech synthesizer with a Raspberry Pi
Introduction
RPItalk is a project that allows you to build your own hardware speech synthesizer from any device running a Debian-based operating system, such as a Raspberry Pi. When the device is connected to a host computer running a screen reader, it allows the host to produce speech output much like classic hardware speech synthesizers such as the DECtalk or LiteTalk.
Traditional hardware speech synthesizers are becoming increasingly difficult to obtain on the resale market, and existing units are often unreliable or expensive. RPItalk provides a modern, low-cost replacement using readily available hardware and open-source software.
RPItalk emulates the behavior of legacy hardware speech synthesizers so that existing screen readers and applications can continue to work without modification.
To begin, you need:
- A device with a functioning sound system running Debian Linux (or one of its derivatives such as Raspberry Pi OS)
- One of the following:
- An OTG (gadget) port on the device and a USB-A to mini-USB-B data cable, or
- A USB port on the device and a USB-to-serial converter cable
The software is intended for use on a Raspberry Pi running Raspberry Pi OS, but it should work on any Debian-based system. For example, you could use a laptop running Ubuntu.
Configuring Your RPItalk Device
-
Log in to your Raspberry Pi
These instructions assume you are starting with a Raspberry Pi with a functioning sound system. Instructions for assembling a system using inexpensive hardware costing under $100 can be found at:
-
Install your choice of text-to-speech engine
The recommended text-to-speech (TTS) engine for this project is espeak-ng. However, you can use any TTS supported by Speech Dispatcher on your platform.
Note that not all speech engines have been ported to the ARM architecture used by the Raspberry Pi.
To install espeak-ng, run the following command:
sudo apt install -y espeak-ngAfter installing espeak-ng, test it:
espeak-ng "Espeak NG is installed and working."If you do not hear the message, something has gone wrong and you must try again. See the troubleshooting section below for suggestions.
-
Install and configure Speech Dispatcher and supporting packages
Install Speech Dispatcher, the output module for your chosen TTS engine, and the Python interface for speech-dispatcher. For example, if you are using the espeak-ng TTS, type:
sudo apt install -y speech-dispatcher speech-dispatcher-espeak-ng python3-speechd -
Create a Speech Dispatcher system configuration
Run:
sudo spd-conf -CHint: When prompted to select a default sound system, enter
libao. This generally works better than ALSA on most Raspberry Pi systems. -
Enable and start the Speech Dispatcher system service
sudo systemctl enable speech-dispatcher sudo systemctl start speech-dispatcher -
Verify that Speech Dispatcher is working
spd-say "Speech Dispatcher is working."If you do not hear the test message, Speech Dispatcher is not working and you must try again. See the troubleshooting section below for suggestions.
-
Configure the RPItalk package repository
Download the apt sources file for the RPItalk package repository:
wget https://people.math.wisc.edu/~jheim/debian/johngheim.sourcesCopy this file into
/etc/apt/sources.list.d. Then update your package database:sudo apt update -
Install the RPItalk package
sudo apt install -y rpitalk -
Run the configuration script
sudo rpitalk-configYou will be asked to select a serial port, an emulation type, and a debug level.
When asked to select a port, if you are using an OTG port on a Raspberry Pi, select ttyGS0. If you are using a USB-to-serial converter cable, select ttyUSB0. Traditional serial ports are named ttyS0, ttyS1, etc.
RPItalk can emulate either DECtalk or LiteTalk. If you are using an OTG port on your Raspberry Pi, you must use DECtalk emulation. If you intend to use a USB-to-serial converter cable, LiteTalk emulation is recommended.
Finally, choose a debug level. The default value of zero (0) is appropriate for most users. A debug level of 1 shows some debug information in the system log. A debug level of 2 shows more. A debug level of 3 shows a large amount of diagnostic information and is probably useful only for developers.
Configuring the Host Computer
After connecting your RPItalk device to the host computer, you must configure the host so that the screen reader can communicate with the emulator.
On Linux systems using the Speakup screen reader, this is done by loading the appropriate Speakup kernel modules. The exact procedure depends on your Linux distribution and configuration. Please refer to the official Speakup documentation for detailed instructions on configuring Speakup and loading speech synthesizer modules.
If your RPItalk device is configured to use USB OTG gadget mode, an alternative automatic configuration method is available. Instead of manually loading the Speakup kernel modules, you can install a udev rules file that automatically recognizes the RPItalk device and loads the required modules whenever the device is connected.
Download the following udev rules file:
wget https://people.math.wisc.edu/~jheim/RPITalk/99-speakup-rpitalk.rules
Install the file into /etc/udev/rules.d/:
sudo cp 99-speakup-rpitalk.rules /etc/udev/rules.d/
Then restart the udev system:
sudo udevadm control --reload-rules sudo udevadm trigger
After completing these steps, the host system should automatically recognize the RPItalk device and load the appropriate Speakup kernel modules whenever the device is connected.
Note that this automatic configuration method works only when RPItalk is configured in USB gadget mode. It does not apply when using a USB-to-serial adapter or a traditional serial port connection.
Troubleshooting
When trying to diagnose problems, it is often useful to run the emulator in debug mode at the command line. To do this, stop the emulator running via systemd then start it at the command line:
sudo systemctl stop rpitalk DEBUG=2 rpitalk-emulator
Note: Setting the debug level to 2 will suffice for most purposes. You can use level 3 to show the bytes exchanged by the host system and your device.
List of possible problems and their solutions:
-
No sound when testing espeak-ng
If you do not hear the test message when running espeak-ng, first verify that your sound system is working.
Try playing a known audio file:
aplay /usr/share/sounds/alsa/Front_Center.wavIf you do not hear this file, check the following:
- Ensure speakers or headphones are connected and powered on
- Verify the correct audio output device is selected
- Check system volume levels (using
alsamixer) - Confirm that no other application is blocking the audio device
Once basic audio is working, try espeak-ng again.
-
RPItalk frequently stops speaking
If RPItalk starts but frequently stops speaking or becomes unresponsive, the issue is often with Speech Dispatcher.
On some systems, the default audio backend (such as ALSA) may not behave reliably. The
libaooutput method often works better.Re-run the Speech Dispatcher configuration tool:
sudo spd-conf -CWhen prompted, select
libaoas the default audio output method. Then restart the service:sudo systemctl restart speech-dispatcher -
OTG connection does not work with LiteTalk emulation
If you are using an OTG (USB gadget) connection between the Raspberry Pi and the host computer, you must use DECtalk emulation.
LiteTalk emulation requires additional hardware control signals that are not available over a standard USB-A to mini-USB-B cable.
If you need to use LiteTalk emulation, you must use a USB-to-serial converter that provides the required signaling.
Questions or corrections: jheim@math.wisc.edu
Copyright (©) The Board of Regents of the University of Wisconsin System