EMIC2is an Arduino library for interfacing the Emic 2 Text-to-Speech module. With this library, you can change the characteristics of the module’s speech through the use of a simple interface that hides away the technical stuff, and allows for a more natural way of control. You can send messages that are provided as an immediate argument to a method, or by reference through a file in an SD card.
Let’s see what we can do with the library.
Make the following connections with your Arduino, the Emic2 module, and the speaker.
EMIC2 library has two accompanying examples. The
SpeakMessage example exposes some of the functionality of the library, and the
SpeakMsgFromSD demonstrates how we can use an SD card to read text files.
Let’s examine the code.
First, we include the
EMIC2 library, along with
SD that are needed by our library (lines 3-5). We specify the RX and TX pins we’ll use for the serial communication with the module (lines 9-10), and then we create an
EMIC2 instance (line 12). Inside the setup function, we’ll have to initialize the instance with the RX and TX pins (line 19).
And then we see the first method (line 21). We can use
setVoice to select one of 9 voices there are available on the module. There are voices comprising male, female, and child. The default voice is number zero and it’s a male voice.
Moving on to the loop, we fall into the
speak method (line 28). We can use speak with a char array, a string, or a numeric data type, and send that message to the module to convert it to speech. Next, we send another message, and then we see the use of the
tilde operator (lines 32/34),
~. We can use
tilde with an
EMIC2 instance while a message is playing on the module to pause and unpause playback.
Next, we can use
setRate (line 38) to set the speaking rate to a value within a range, and
resetRate (line 40) to reset it to the default value of 200 words/minute. We can also use the double greater than (line 44),
>>, and double less than (line 46),
<<, operators to increase and decrease the speaking rate, respectively.
Next, we can use
setVolume (line 50) to set the volume level to a value within a range, and
resetVolume (line 52) to reset it to the default value of 0dB. We can also use the
+= (line 59) and
-= (line 56) operators to raise and lower the volume level, respectively. And finally there are the prefix
++ (line 60) and
-- (line 57) operators for a unit step change in the volume level.
Going further down, we meet the
bang operator (line 69),
!, that we can use to stop the playback on the module at any time.
And that’s pretty much the jist of it.
In this example we utilize an SD card, and in order to play something on the module, we need some files.
SD card on your computer, format the card to a
FAT file system, create a folder
emic2, and put any files you want to be read inside this folder.
So, let’s look at the code now.
Everything is pretty much the same. The one thing we have to do is to specify the chip select pin for the
SD card and provide that to the
Now, we call
speak with the name of our file, and an additional argument,
SD_C, to inform the method that the string we gave it, it’s not a message for the module to read, but rather it’s a
filename. And then the method will start sending messages to the Emic2 module for every line in the file.
Simple as that. Initialize and send!
That’s all folks. We hope you enjoy this library, and if you have any comments or suggestions you can contact us at
girder [at] codebender [dot] cc
Sounds are from freesound.org. Schematics were based on Fritzing.