Skip to content

Instantly share code, notes, and snippets.

@ihearmoth
Created August 12, 2017 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihearmoth/21afbcade61cca1a082a4f1ae3518aca to your computer and use it in GitHub Desktop.
Save ihearmoth/21afbcade61cca1a082a4f1ae3518aca to your computer and use it in GitHub Desktop.
Text to Speech Emic controlled with processing
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val, saying = 0, state = 0;
void setup()
{
// Open whatever port is the one you're using.
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
String portName[] = Serial.list();
if (portName == null) {
println("Failed to retrieve the list of available serial devices...");
} if (portName.length == 0) {
println("There are no serial ports currently available.");
exit();
} else {
println("Available serial devices:");
for (int i = 0; i < portName.length; i++) {
println(portName[i]);
}
}
//myPort = new Serial(this, "COM10", 9600);
myPort = new Serial(this, portName[6], 9600);
doCommand("R"); // Reset at the outset
doCommand("P0"); // Put Emic 2 into DecTalk mode
doCommand("W200");
doCommand("N1");
//doCommand("[:rate 100]");
//sayString("TIGER, tiger, burning bright In the forests of the night, What immortal hand or eye Could frame thy fearful symmetry? What the hammer? what the chain? In what furnace was thy brain? What the anvil? What dread grasp Dare its deadly terrors clasp?");
sayString("[:dv hs 110][:dv sm 40][:rate 100][:comma 2]Tiger, Tyger.by, William Blake[:comma 15] ");
sayString("[:dv qu 60][:dv hs 110][:dv sm 40][:rate 80][:dv br 40][+]Tiger, [:dv br 30][:dv sr 60][:dv hr 50] tiger,[:dv hr 12] [:rate 190][:dv sr 30] burning bright In the forests of the night,");
sayString("[:rate 190][:dv qu 80][:dv sm 50] What, emmortal hand or eye [:dv hr 40] Could frame thy fearful symmetry?");
sayString("[:rate 190][:dv sm 40][:dv qu 80][:dv hr 70]In what distant deeps or skies burnt the fire of thine eyes? [:dv hr 10][:dv sm 40][:dv qu 80]On what wings dare he aspire? What the hand dare seize the fire!");
sayString("[:dv hr 40][:dv sm 40][:dv qu 80][:rate 160]And what shoulder[:comma 20]and what art[:rate 190][:dv hr 20]Could twist the sinews of thi heart?");
sayString(" [:dv pr 90][:dv hr 20][:dv sm 40][:dv qu 90][:rate 160]And when thi heart began to beat![:dv ap 85 pr 60][:dv br 40][:rate 150][:dv sm 80] What dread hand[:comma 4]and what dread feet.");
sayString("[:rate 160][:dv qu 90][:dv hr 50][:dv sm 40] What the hammer, what the chain![:rate 190] In what furnace was thi brain? ");
sayString(" [:dv hr 90][:dv pr 40]What the anvil? [:dv hr 50][:dv ap 90 pr 50][:rate 180][:dv as 100] What dread [/]grasp, dare its deadly terrorz clasp!");
sayString(" [:rate 160][:dv hr 30][:dv hs 105] When the [/]stars threw down their spears, [:rate 210] And watered [/]heaven with their teaears");
sayString(" [:rate 180][:dv sm 50][:dv hr 30] Did he smile his work to see! [:rate 150] Did he who maid the lamb[:comma 1][:dv ap 90][:dv br 40] make thee? ");
sayString("[:dv qu 60][:dv hs 110][:dv sm 70][:rate 80][:dv br 40][+]Tiger, [:dv br 30][:dv sr 60][:dv hr 50] tiger,[:dv hr 12] [:rate 160][:dv sr 30] burning bright In the forests of the night,");
sayString("[:dv sm 70][:rate 150][:dv qu 80]What, emmortal hand or eye [:dv hr 40] Dare, frame thy fearful symmetry?");
}
void sayString(String foo) {
int reply;
myPort.write("S" + foo + "\n");
println(foo);
while (true){
reply = myPort.read();
if (reply != -1) {
print((char)reply);
if (reply == ':') break;
}
}
}
void doCommand(String foo) {
int reply;
myPort.write(foo + "\n");
println(foo);
while (true){
reply = myPort.read();
if (reply != -1) {
print((char)reply);
if (reply == ':') break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment