EMIC 2 Text to Speech Engine

Emic 2 Text to Speech Engine

The Emic 2 Text-to-Speech Module is a multi-language voice synthesizer that converts a stream of ASCII text into natural sounding speech. Its simple command-based interface makes it easy to integrate into any embedded system.


High-quality speech synthesis for English and Spanish languages Nine pre-defined voice styles comprising male, female, and child. Dynamic control of speech and voice characteristics, including pitch, speaking rate, and word emphasis Industry-standard DECtalk text-to-speech synthesizer engine (5.0.E1)


Reading Internet-based data streams (such as e-mails or Twitter feeds) Conveying status or sensor results from robots, scientific equipment, or industrial machinery Language learning or speech aids for educational environments

Emic 2 Documentation

HackaweekTV Video Demo of Emic 2

Just about any 8 ohm speaker can be used. It also has an audio jack that could be used for earphones, headphones, or PC speakers.
Wires could be soldered on a small speaker that could be plugged into a breadboard.
Small Sparkfun Speaker

Sparkfun also has a handy speaker that with plug into a breadboard, but be careful not to overdrive it. There are commands to adjust the volume on the Emic 2.
Small breadboard friendly speaker from Sparkfun


The small Sparkfun PCB speaker works great in a breadboard and is very handy, but when removing it from a breadboard be careful to pry the bottom up first with a something flat like a screwdriver. If you pull it out hard using the top black metal speaker cover, the PCB on the back cover can pull off and break the tiny speaker wires soldered to the pins inside the back cover.


mbedEmic 2Speaker 8OHM
  • Depending on the speaker load and what other devices are connected to mbed, an external 5V DC power supply may be needed. It can draw up to 220MA. Tie grounds together on the power supplies, but not the outputs.

Hello World Example

Here is a sample hello "speech" world example to try. It uses the Stream base class and virtual functions, so that easy to use printfs can send text to the speech engine that it can convert it to human speech. With printfs, it can also speak numbers from program code and not just hard-coded text strings. To avoid confusion with printing, the function speakf can be used instead of printf. The syntax is exactly the same as printf. The ready member function waits for speech to end. Different voices and volume can be set with additional functions.

Emic 2 hello world demo

#include "mbed.h"
//Emic 2 Hello Speech World Demo
#define speakf printf
DigitalOut myled(LED1);
Serial Debug(USBTX,USBRX);

class emic2 : public Stream
public :
    emic2(PinName tx, PinName rx): _cmd(tx,rx) {
        _cmd.putc('X'); //stop talking if reset and not a power on
        _cmd.putc('\r'); // Send a CR in case the system is already up
        wait(1); //delay for emic power on boot or reset respone
        while (_cmd.getc() != ':');   // When the Emic 2 has initialized and is ready, it will send a single ':'
        while (_cmd.readable()) _cmd.getc();//flush out buffer just in case
    void ready() {
        while (_cmd.getc() != ':');
        while (_cmd.readable()) _cmd.getc();//flush out recieve buffer just in case
    int readable() {
        return _cmd.readable();
    int getc() {
        return _cmd.getc();
    void volume(int x) {
    void voice(int x) {
protected :
    Serial     _cmd;
    //used by printf - supply it and printf works!
    virtual int _putc(int c) {
        return 0;
    virtual int _getc() {
        return -1;
    emic2 myTTS(p13, p14); //serial RX,TX pins to emic

int main()
    myTTS.volume(18); //max volume
    while(1) {
        myled = 1;
        //Plain text demo
        myTTS.speakf("S");//Speak command starts with "S"
        myTTS.speakf("Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song on m bed.");  // Send the desired string to convert to speech
        myTTS.speakf("\r"); //marks end of speak command
        myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
        myled = 0;
        myled = 1;
        //Song Demo
        myTTS.speakf("D1\r");//Sing Song Demo
        myTTS.ready(); //member function wait
        myled = 0;
        //Voice demo
        for (int i=0; i<9 ; i++) { //demo different voices
            myTTS.speakf("SHello this is a sample of voice number, %D\r",i);
        myTTS.voice(0); //back to default voice
        //Number demo
        for (int i=10; i>=0 ; i--) { //demo different numbers
        //Read Time (RTC) demo
        set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
        wait(2); //let RTC advance two seconds after setting to confirm it works
        time_t seconds = time(NULL);//read current time
        myTTS.speakf("STime in seconds since January 1, 1970 =, %d\r", seconds);
        myTTS.speakf("STime as a basic string = %s\r", ctime(&seconds));
        char buffer[32];
        strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
        myTTS.speakf("SThe current time is %s\r", buffer);


The download version of the hello world program is setup with the emic2 class code in a .H file.

Import programtext_to_speech_hello_world

Emic2 Speech Synthesis Module Hello World Demo See https://developer.mbed.org/users/4180_1/notebook/emic-2-text-to-speech-engine/

Import libraryemic2

class for emic 2 speech synthesis module

Improving Speech Quality

It is possible to override the speech synthesis software automatic pronunciation of a word or text, by manually supplying additional pronunciation information for specific text using phonemes. Phonemes are the fundamental unit of speech sounds. Here is an example command using phonemes to say “associate”: [:phone arpa speak on] [axs ’owshiyeyt]. This can take some time to figure out and will likely require some experimentation.

If a particular word or phrase needs some improvement, the following program allows you to easily experiment by typing command lines directly to the Emic 2 using a terminal application program attached to the mbed’s USB virtual com port. Additional information can be found in the User guide. Type "H" and then return to see the list of commands.Type the command “P0” to switch to the DECtalk parser (needed once only) and then “S[:phone arpa speak on] [:n0][axs ’owshiyeyt][:n0]” to hear “associate” using phonemes. The built in song demo uses phonemes.

Import programtext_to_speech_terminal_Emic2

Serial passthrough with echo back to PC added - used for testing Emic 2 commands

If louder audio output is needed, a set of PC speakers can be plugged into the stereo jack on the Emic 2. PC speakers have an internal amplifier that expects lower voltage audio signals, so the volume of the Emic 2 output needs to be reduced a bit from the example code and the default setting of V0 seems to work fine. The module has a circuit to reduce the voltage on the audio jack to typical audio levels. The speakers do pick up a bit of AC hum and a low pass filter on the module's power supply might help.

Please log in to post comments.