Full tutorial and video found here.
There have been posts here before showing how to do text-to-speech with the Yun, but they've required using a web service to convert text into an audio file that can be played through a connected speaker. To simplify this, I've compiled the Linux program 'eSpeak' so that it's compatible with OpenWrt-Yun. This program allows for text-to-speech translations using simple command line inputs.
To install eSpeak, type in the following commands at the Yun's command prompt:
opkg update
opkg install binutils
opkg -t /root install yun-gcc
wget --no-checkcertificate http://arduinomeetslinux.com/download/espeak_1.48.04_arm71xx.ipk
opkg install espeak_1.48.04_arm71xx.ipk
rm espeak_1.48.04_arm71xx.ipk
You'll need to use a USB audio interface and speaker to play the speech from the Yun. When you connect these make sure that you also have the correct audio support files installed as well:
opkg update
opkg install kmod-usb-audio
Once installed you can easily perform text to speech translations from the command line. For example:
espeak "Hello World, this is a test sentence."
And since you can call it from the command line, calling it from an Arduino sketch is easy as well:
#include <Bridge.h>
Process p;
void setup() {
Bridge.begin();
p.runShellCommand("espeak \"Hello World, this is a sentence from a sketch.\"");
}
Be sure to check out the full tutorial linked above.
Using text to speech I was able to complete a project I'm calling the 'Siri Clone'. Essentially, this project lets users ask it simple questions which are recorded through a microphone connected to the Yun. These questions are then converted to text using AT&T's Speech API, which is passed into the WolframAlpha API to determine an answer. The answer is returned as a text string which is then played back to the user using eSpeak. You can check out a demo video for this project here: