EMIC 2 Speech Synthesizer class for Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file synthesizer.h | |
* @brief Speech Synthesizer class. | |
* @author David Such | |
*/ | |
#ifndef synthesizer_h | |
#define synthesizer_h | |
class Synthesizer | |
{ | |
public: | |
Synthesizer(byte rxPin, byte txPin): _emicSerial(rxPin, txPin) | |
{ | |
_rxPin = rxPin; | |
_txPin = txPin; | |
} | |
void begin() | |
{ | |
pinMode(_rxPin, INPUT); | |
pinMode(_txPin, OUTPUT); | |
_emicSerial.begin(9600); | |
_emicSerial.print('\n'); // Send a CR in case the system is already up | |
while (_emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it | |
delay(10); // Short delay | |
_emicSerial.flush(); // Flush the receive buffer | |
_emicSerial.print("N8\n"); // Select Voice (0 to 8) | |
_emicSerial.print("V15\n"); // Set Volume (-48 to 18) | |
_emicSerial.print("L0\n"); // Set Language (0 to 2) | |
_emicSerial.print("P1\n"); // Select Parser (0 DECtalk, 1 Epson) | |
_emicSerial.print("W200\n"); // Set Speaking Rate (75 to 600) | |
} | |
void speakMessage(String msg) | |
{ | |
_emicSerial.print('\n'); | |
while (_emicSerial.read() != ':'); | |
_emicSerial.print('S'); | |
_emicSerial.print(msg); | |
_emicSerial.print('\n'); | |
} | |
void singSong() | |
{ | |
_emicSerial.print("P0\n"); | |
speakMessage("[:phone arpa speak on][:rate 190][:n2][:dv ap 200 sm 100 ri 100][R EY<200,17>N<100>DRAO<200,24>PS<100>AO<200>N<100>ROW<300,19>ZIX<200,17>Z<100>AE<150>N<100>D<50>WIH<300,12>SKRR<200,17>Z<100>AO<200>N<100>KIH<300,19>TAH<150,17>N<100>Z<50>_<300>BRAY<200>T<100>KAO<300,24>PRR<300>K EH<300,19>TEL<200,17>Z<100>AE<150>N<100>D<50>War<200,12>M<100>WUH<300,17>LL EH<200>N<100>MIH<300,19>TAH<150,17>N<100>Z<50>_<300>BRAW<200>N<100>PEY<300,24>PRR<300,22>PAE<300,17>KIH<300,19>JHIX<200,15>Z<100>TAY<200>D<100>AH<200,22>P<100>WIH<200,20>TH<100>STRIH<300,13>NX<200>Z<100>_<300>DHIY<200,12>Z<100>AR<300,13>AX<300,15>FYU<300,17>AH<200,18>V<100>MAY<300,20>FEY<300,22>VRR<300,24>EH<200,22>T<100>THIH<500,16>NX<300>Z<100>][:n0]"); | |
_emicSerial.print("P1\n"); | |
} | |
private: | |
byte _rxPin, _txPin; | |
SoftwareSerial _emicSerial; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment