text-to-speech hello world

Dependencies:   emic2 mbed SDFileSystem

main.cpp

Committer:
nnguyen45
Date:
2017-11-04
Revision:
2:922b8fe6ff94
Parent:
0:c1e7994288d7

File content as of revision 2:922b8fe6ff94:

#include "mbed.h"
#include <string>
using namespace std;
//Emic 2 Hello Speech World Demo
#include "SDFileSystem.h"

SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board

DigitalOut myled(LED1);
#include "emic2.h"

emic2 myTTS(p28, p27); //serial RX,TX pins to emic

int main()
{
    myTTS.volume(18); //max volume
    string repeat = "Please try again.";



    while(1) {
        myled = 1;
        //Plain text demo
        myTTS.speakf("S");//Speak command starts with "S"
        myTTS.speakf("Welcome to Bat, the Blind Assistive Teacher. This device will help you learn how to write and type braille.");  // 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
        if(str.length(letter[0]) != 0) {
            myTTS.speakf("STo write the letter %s, press pins %D\r",letter[0], ID);
            //check pins pressed
            if(incorrect) {
                myTTS.speakf("SPin %D is incoorect.\r",ID);
                myTTS.speakf("S%s.\r", repeat);
            }
        } else if(str.length(words) != 0) {
            myTTS.speakf("SType the word %s.\r",word);
        }
        myled = 0;
        //Voice Demo
        for (int i=0; i<9 ; i++) { //demo different voices
            myTTS.voice(i);
            myTTS.speakf("SHello this is a sample of voice number, %D\r",i);
            myTTS.ready();
        }
        myTTS.voice(0); //back to default voice
        //Number demo
        for (int i=10; i>=0 ; i--) { //demo different numbers
            myTTS.speakf("S%D.\r",i);
            myTTS.ready();
        }
    }
}