Ricky Jiang
/
TTSmbed_groupproject
emic2
main.cpp@1:ac14b7abc181, 2020-02-28 (annotated)
- Committer:
- jwu13018
- Date:
- Fri Feb 28 14:22:46 2020 +0000
- Revision:
- 1:ac14b7abc181
- Parent:
- 0:2128ea16088c
- Child:
- 2:32f26fe1d8ad
emic2 v1.0;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:2128ea16088c | 1 | #include "mbed.h" |
4180_1 | 0:2128ea16088c | 2 | //Emic 2 Hello Speech World Demo |
4180_1 | 0:2128ea16088c | 3 | |
4180_1 | 0:2128ea16088c | 4 | DigitalOut myled(LED1); |
4180_1 | 0:2128ea16088c | 5 | #include "emic2.h" |
4180_1 | 0:2128ea16088c | 6 | |
jwu13018 | 1:ac14b7abc181 | 7 | emic2 myTTS(PB_6, PB_7); //serial RX,TX pins to emic |
4180_1 | 0:2128ea16088c | 8 | |
4180_1 | 0:2128ea16088c | 9 | int main() |
4180_1 | 0:2128ea16088c | 10 | { |
4180_1 | 0:2128ea16088c | 11 | myTTS.volume(18); //max volume |
4180_1 | 0:2128ea16088c | 12 | while(1) { |
4180_1 | 0:2128ea16088c | 13 | myled = 1; |
4180_1 | 0:2128ea16088c | 14 | //Plain text demo |
4180_1 | 0:2128ea16088c | 15 | myTTS.speakf("S");//Speak command starts with "S" |
4180_1 | 0:2128ea16088c | 16 | 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 |
4180_1 | 0:2128ea16088c | 17 | myTTS.speakf("\r"); //marks end of speak command |
4180_1 | 0:2128ea16088c | 18 | myTTS.ready(); //ready waits for speech to finish from last command with a ":" response |
4180_1 | 0:2128ea16088c | 19 | myled = 0; |
4180_1 | 0:2128ea16088c | 20 | myled = 1; |
4180_1 | 0:2128ea16088c | 21 | //Song Demo |
4180_1 | 0:2128ea16088c | 22 | myTTS.speakf("D1\r");//Sing Song Demo |
4180_1 | 0:2128ea16088c | 23 | myTTS.ready(); //member function wait |
4180_1 | 0:2128ea16088c | 24 | myled = 0; |
4180_1 | 0:2128ea16088c | 25 | //Voice Demo |
4180_1 | 0:2128ea16088c | 26 | for (int i=0; i<9 ; i++) { //demo different voices |
4180_1 | 0:2128ea16088c | 27 | myTTS.voice(i); |
4180_1 | 0:2128ea16088c | 28 | myTTS.speakf("SHello this is a sample of voice number, %D\r",i); |
4180_1 | 0:2128ea16088c | 29 | myTTS.ready(); |
4180_1 | 0:2128ea16088c | 30 | } |
4180_1 | 0:2128ea16088c | 31 | myTTS.voice(0); //back to default voice |
4180_1 | 0:2128ea16088c | 32 | //Number demo |
4180_1 | 0:2128ea16088c | 33 | for (int i=10; i>=0 ; i--) { //demo different numbers |
4180_1 | 0:2128ea16088c | 34 | myTTS.speakf("S%D.\r",i); |
4180_1 | 0:2128ea16088c | 35 | myTTS.ready(); |
4180_1 | 0:2128ea16088c | 36 | } |
4180_1 | 0:2128ea16088c | 37 | //Read Time (RTC) demo |
4180_1 | 0:2128ea16088c | 38 | set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 |
4180_1 | 0:2128ea16088c | 39 | wait(2); //let RTC advance two seconds after setting to confirm it works |
4180_1 | 0:2128ea16088c | 40 | time_t seconds = time(NULL);//read current time |
4180_1 | 0:2128ea16088c | 41 | myTTS.speakf("STime in seconds since January 1, 1970 =, %d\r", seconds); |
4180_1 | 0:2128ea16088c | 42 | myTTS.ready(); |
4180_1 | 0:2128ea16088c | 43 | myTTS.speakf("STime as a basic string = %s\r", ctime(&seconds)); |
4180_1 | 0:2128ea16088c | 44 | myTTS.ready(); |
4180_1 | 0:2128ea16088c | 45 | char buffer[32]; |
4180_1 | 0:2128ea16088c | 46 | strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); |
4180_1 | 0:2128ea16088c | 47 | myTTS.speakf("SThe current time is %s\r", buffer); |
4180_1 | 0:2128ea16088c | 48 | myTTS.ready(); |
4180_1 | 0:2128ea16088c | 49 | |
4180_1 | 0:2128ea16088c | 50 | } |
4180_1 | 0:2128ea16088c | 51 | } |