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

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 //Emic 2 Hello Speech World Demo
00003 
00004 DigitalOut myled(LED1);
00005 #include "emic2.h"
00006 
00007 emic2 myTTS(p13, p14); //serial RX,TX pins to emic
00008 
00009 int main()
00010 {
00011     myTTS.volume(18); //max volume
00012     while(1) {
00013         myled = 1;
00014         //Plain text demo
00015         myTTS.speakf("S");//Speak command starts with "S"
00016         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
00017         myTTS.speakf("\r"); //marks end of speak command
00018         myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
00019         myled = 0;
00020         myled = 1;
00021         //Song Demo
00022         myTTS.speakf("D1\r");//Sing Song Demo
00023         myTTS.ready(); //member function wait
00024         myled = 0;
00025         //Voice Demo
00026         for (int i=0; i<9 ; i++) { //demo different voices
00027             myTTS.voice(i);
00028             myTTS.speakf("SHello this is a sample of voice number, %D\r",i);
00029             myTTS.ready();
00030         }
00031         myTTS.voice(0); //back to default voice
00032         //Number demo
00033         for (int i=10; i>=0 ; i--) { //demo different numbers
00034             myTTS.speakf("S%D.\r",i);
00035             myTTS.ready();
00036         }
00037         //Read Time (RTC) demo
00038         set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
00039         wait(2); //let RTC advance two seconds after setting to confirm it works
00040         time_t seconds = time(NULL);//read current time
00041         myTTS.speakf("STime in seconds since January 1, 1970 =, %d\r", seconds);
00042         myTTS.ready();
00043         myTTS.speakf("STime as a basic string = %s\r", ctime(&seconds));
00044         myTTS.ready();
00045         char buffer[32];
00046         strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
00047         myTTS.speakf("SThe current time is %s\r", buffer);
00048         myTTS.ready();
00049 
00050     }
00051 }