Instantly share code, notes, and snippets.

anonymous /BasnikClass_Improved.pde
Created Oct 16, 2016

Embed
What would you like to do?
Processing code by Eric Valosin, used in conjunction with SimpleOpenNI and FreeTTS libraries, kinect, and the Basnik Class
/* THANKS TO KOF FOR SHARING HIS "BASNIK" CLASS AND TUTORIAL SKETCH ON THE PROCESSING FORUM:
https://processing.org/discourse/beta/num_1204335245.html
REVISIONS MADE BY ERIC VALOSIN. FEEL FREE TO USE AND ADAPT.
REVISIONS:
- I put the Basnik (which, in case you were wondering, is Slovak for "poet") class in separate tab to tidy up sketch
- separate instances of the class can be threaded together for polyphonic effects
- added missing freeTTS controls for volume and rate.
- moved setPitch, setPitchRange, setPitchShift, and setRate controls out of the constructor's setup phase
and made them custom functions so each instance of the class can be dynamically and individually controlled
in the draw phase by calling a function (ex: basnik1.setPitch(300); basnik2.setPitch(150);
- I know freeTTS allows for output speaker pan control with speakLeft() and speakRight() functions - I could not
get these to work here. Maybe you can.
*/
// CLASS CONSTRUCTOR /////////////////////////////////////////////////////////////////////////////////////////////////
public class Basnik {
String voiceName = "kevin16";
VoiceManager voiceManager;
Voice voice;
Basnik(String name){
voiceName = name;
this.setup();
}
void listAllVoices() {
System.out.println();
System.out.println("All voices available:");
VoiceManager voiceManager = VoiceManager.getInstance();
Voice[] voices = voiceManager.getVoices();
for (int i = 0; i < voices.length; i++) {
System.out.println(" " + voices[i].getName()
+ " (" + voices[i].getDomain() + " domain)");
}
}
void setup() {
listAllVoices();
System.out.println();
System.out.println("Using voice: " + voiceName);
voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);
// I haven't gotten setStyle to make any difference, but maybe it depends on the voice used
voice.setStyle("casual"); //"business", "casual", "robotic", "breathy"
// (Other control functions like setPitch were previously listed here. See below)
if (voice == null) {
System.err.println(
"Cannot find a voice named "
+ voiceName + ". Please specify a different voice.");
System.exit(1);
}
voice.allocate();
}
// CUSTOM FUNCTIONS to allow instances to have their own pitch, range, tempo, volume control//////////////////////////
void setPitch(int p){ // root pitch in Hz. (261.626 = Middle C
voice.setPitch(p);
}
void setPitchShift(int s){ // transposition. Same scale as setPitch
voice.setPitchShift(s);
}
void setRange(int r){ // range of pitches within a phrase. 1 = monotone, 30 = roughly natural
voice.setPitchRange(r);
}
void setVolume(float v){ // output volume. 0 = mute, 1 = full volume (.5 is still barely audible on computer speakers)
voice.setVolume(v);
}
void setTempo(int t){ //rate of speech in words per minute. 150 = natural default.
voice.setRate(t); //DOES THIS NEED TO BE "setSpeakingRate()?"
}
// PLAYBACK FUNCTIONS ////////////////////////////////////////////////////////////////////////////////////////////////////
void say(String _a){
if(_a==null){
_a= "nothing";
}
voice.speak(_a);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void exit(){
voice.deallocate();
}
}
/* BASED ON KOF'S "BASNIK" CLASS AND TUTORIAL SKETCH ON THE PROCESSING FORUM:
https://processing.org/discourse/beta/num_1204335245.html */
//objectless sound object - program chants its own code, up to 2 voices controlled by hands
//locations of hands determine pitch, tempo, and volume
// developed on Processing 2 (not tested on Processing 3) and uses a Kinect Sensor
//////////////////////////////////////////////////
import SimpleOpenNI.*;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.audio.JavaClipAudioPlayer;
SimpleOpenNI kinect;
Basnik voice1;
Basnik voice2;
// sound control variables
int pitch1;
int pitch2;
float vol1;
float vol2;
int tempo;
// body part variables
int rightX;
int rightY;
int rightZ;
int leftX;
int leftY;
int leftZ;
int rHipX;
int rHipY;
int rHipZ;
int lHipX;
int lHipY;
int lHipZ;
// voice controls
boolean voice1on;
boolean voice2on;
// spoken code array
String[] speech = new String[1478];
int i;
void setup(){
size(640, 480);
fill(255, 0, 0);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableUser();
kinect.setMirror(true);
voice1 = new Basnik("kevin16");
voice1.setRange(1);
voice2 = new Basnik("kevin16"); // A second instance of Basnic class, threaded below so both voices can speak at once
voice2.setRange(1);
pitch1 = 220;
pitch2 = 220;
// SPOKEN CODE ////////////////////
speech[0] = "import";
speech[1] = "Simple Open N I";
speech[2] = "dot";
speech[3] = "star";
speech[4] = "semicolon";
speech[5] = "import";
speech[6] = "com";
speech[7] = "dot";
speech[8] = "sun";
speech[9] = "dot";
speech[10] = "speech";
speech[11] = "dot";
speech[12] = "free TTS";
speech[13] = "dot";
speech[14] = "voice";
speech[15] = "semicolon";
speech[16] = "import";
speech[17] = "com";
speech[18] = "dot";
speech[19] = "sun";
speech[20] = "dot";
speech[21] = "speech";
speech[22] = "dot";
speech[23] = "free TTS";
speech[24] = "dot";
speech[25] = "voice manager;";
speech[26] = "semicolon";
speech[27] = "import";
speech[28] = "com";
speech[29] = "dot";
speech[30] = "sun";
speech[31] = "dot";
speech[32] = "speech";
speech[33] = "dot";
speech[34] = "free TTS";
speech[35] = "dot";
speech[36] = "audio";
speech[37] = "dot";
speech[38] = "java clip audio player";
speech[39] = "semicolon";
speech[40] = "Simple Open N I";
speech[41] = "kinect";
speech[42] = "semicolon";
speech[43] = "Basnik";
speech[44] = "voice 1";
speech[45] = "semicolon";
speech[46] = "Basnik";
speech[47] = "voice 2";
speech[48] = "semicolon";
speech[49] = "int";
speech[50] = "pitch 1";
speech[51] = "semicolon";
speech[52] = "int";
speech[53] = "pitch 2";
speech[54] = "semicolon";
speech[55] = "float";
speech[56] = "vol 1";
speech[57] = "semicolon";
speech[58] = "float";
speech[59] = "vol 2";
speech[60] = "semicolon";
speech[61] = "int";
speech[62] = "tempo";
speech[63] = "semicolon";
speech[64] = "int";
speech[65] = "right X";
speech[66] = "semicolon";
speech[67] = "int";
speech[68] = "right Y";
speech[69] = "semicolon";
speech[70] = "int";
speech[71] = "right Z";
speech[72] = "semicolon";
speech[73] = "int";
speech[74] = "left X";
speech[75] = "semicolon";
speech[76] = "int";
speech[77] = "left Y";
speech[78] = "semicolon";
speech[79] = "int";
speech[80] = "left Z";
speech[81] = "semicolon";
speech[82] = "int";
speech[83] = "R hip X";
speech[84] = "semicolon";
speech[85] = "int";
speech[86] = "R hip Y";
speech[87] = "semicolon";
speech[88] = "int";
speech[89] = "R hip Z";
speech[90] = "semicolon";
speech[91] = "int";
speech[92] = "L hip X";
speech[93] = "semicolon";
speech[94] = "int";
speech[95] = "L hip Y";
speech[96] = "semicolon";
speech[97] = "int";
speech[98] = "L hip Z";
speech[99] = "semicolon";
speech[100] = "boolean";
speech[101] = "voice 1 on";
speech[102] = "semicolon";
speech[103] = "boolean";
speech[104] = "voice 2 on";
speech[105] = "semicolon";
speech[106] = "string";
speech[107] = "left bracket";
speech[108] = "right bracket";
speech[109] = "speech";
speech[110] = "equals";
speech[111] = "new";
speech[112] = "string";
speech[113] = "left bracket";
speech[114] = "1478";
speech[115] = "right bracket";
speech[116] = "semicolon";
speech[117] = "int";
speech[118] = "I";
speech[119] = "semicolon";
speech[120] = "void";
speech[121] = "setup";
speech[122] = "left parenthesis";
speech[123] = "right parenthesis";
speech[124] = "left curly bracket";
speech[125] = "size";
speech[126] = "left parenthesis";
speech[127] = "640";
speech[128] = "comma";
speech[129] = "480";
speech[130] = "right parenthesis";
speech[131] = "semicolon";
speech[132] = "fill";
speech[133] = "left parenthesis";
speech[134] = "255";
speech[135] = "comma";
speech[136] = "zero";
speech[137] = "comma";
speech[138] = "zero";
speech[139] = "right parenthesis";
speech[140] = "semicolon";
speech[141] = "kinect";
speech[142] = "equals";
speech[143] = "new";
speech[144] = "Simple Open N I";
speech[145] = "left parenthesis";
speech[146] = "this";
speech[147] = "right parenthesis";
speech[148] = "semicolon";
speech[149] = "kinect";
speech[150] = "dot";
speech[151] = "enable Depth";
speech[152] = "left parenthesis";
speech[153] = "right parenthesis";
speech[154] = "semicolon";
speech[155] = "kinect";
speech[156] = "dot";
speech[157] = "enable User";
speech[158] = "left parenthesis";
speech[159] = "right parenthesis";
speech[160] = "semicolon";
speech[161] = "kinect";
speech[162] = "dot";
speech[163] = "set Mirror";
speech[164] = "left parenthesis";
speech[165] = "true";
speech[166] = "right parenthesis";
speech[167] = "semicolon";
speech[168] = "voice 1";
speech[169] = "equals";
speech[170] = "new";
speech[171] = "Basnik";
speech[172] = "left parenthesis";
speech[173] = "quote";
speech[174] = "kevin 16";
speech[175] = "endquote";
speech[176] = "right parenthesis";
speech[177] = "semicolon";
speech[178] = "voice 1";
speech[179] = "dot";
speech[180] = "set range";
speech[181] = "left parenthesis";
speech[182] = "1";
speech[183] = "right parenthesis";
speech[184] = "semicolon";
speech[185] = "voice 2";
speech[186] = "equals";
speech[187] = "new";
speech[188] = "Basnik";
speech[189] = "left parenthesis";
speech[190] = "quote";
speech[191] = "kevin 16";
speech[192] = "endquote";
speech[193] = "right parenthesis";
speech[194] = "semicolon";
speech[195] = "voice 2";
speech[196] = "dot";
speech[197] = "set range";
speech[198] = "left parenthesis";
speech[199] = "1";
speech[200] = "right parenthesis";
speech[201] = "semicolon";
speech[202] = "pitch 1";
speech[203] = "equals";
speech[204] = "220";
speech[205] = "semicolon";
speech[206] = "pitch 2";
speech[207] = "equals";
speech[208] = "220";
speech[209] = "semicolon";
speech[210] = "speech array";
speech[211] = "I";
speech[212] = "equals";
speech[213] = "zero";
speech[214] = "semicolon";
speech[215] = "voice 1 on";
speech[216] = "equals";
speech[217] = "false";
speech[218] = "semicolon";
speech[219] = "voice 2 on";
speech[220] = "equals";
speech[221] = "false";
speech[222] = "semicolon";
speech[223] = "right curly bracket";
speech[224] = "void";
speech[225] = "draw";
speech[226] = "left parenthesis";
speech[227] = "right parenthesis";
speech[228] = "left curly bracket";
speech[229] = "background";
speech[230] = "left parenthesis";
speech[231] = "zero";
speech[232] = "right parenthesis";
speech[233] = "semicolon";
speech[234] = "kinect";
speech[235] = "dot";
speech[236] = "update";
speech[237] = "left parenthesis";
speech[238] = "right parenthesis";
speech[239] = "semicolon";
speech[240] = "image";
speech[241] = "left parenthesis";
speech[242] = "kinect";
speech[243] = "dot";
speech[244] = "depth image";
speech[245] = "left parenthesis";
speech[246] = "right parenthesis";
speech[247] = "comma";
speech[248] = "zero";
speech[249] = "comma";
speech[250] = "zero";
speech[251] = "right parenthesis";
speech[252] = "semicolon";
speech[253] = "int vector";
speech[254] = "user list";
speech[255] = "equals";
speech[256] = "new";
speech[257] = "int vector";
speech[258] = "left parenthesis";
speech[259] = "right parenthesis";
speech[260] = "semicolon";
speech[261] = "kinect";
speech[262] = "dot";
speech[263] = "get users";
speech[264] = "left parenthesis";
speech[265] = "user list";
speech[266] = "right parenthesis";
speech[267] = "semicolon";
speech[268] = "if";
speech[269] = "parenthesis";
speech[270] = "user list";
speech[271] = "dot";
speech[272] = "size";
speech[273] = "left parenthesis";
speech[274] = "right parenthesis";
speech[275] = "greater than";
speech[276] = "zero";
speech[277] = "right parenthesis";
speech[278] = "left curly bracket";
speech[279] = "int";
speech[280] = "user I D";
speech[281] = "equals";
speech[282] = "user list";
speech[283] = "dot";
speech[284] = "get";
speech[285] = "left parenthesis";
speech[286] = "zero";
speech[287] = "right parenthesis";
speech[288] = "semicolon";
speech[289] = "if";
speech[290] = "left parenthesis";
speech[291] = "kinect";
speech[292] = "dot";
speech[293] = "is Tracking skeleton";
speech[294] = "left parenthesis";
speech[295] = "user I D";
speech[296] = "right parenthesis";
speech[297] = "right parenthesis";
speech[298] = "left curly bracket";
speech[299] = "draw joint";
speech[300] = "left parenthesis";
speech[301] = "user I D";
speech[302] = "comma";
speech[303] = "Simple Open N I";
speech[304] = "dot";
speech[305] = "skel";
speech[306] = "underscore";
speech[307] = "left";
speech[308] = "underscore";
speech[309] = "hand";
speech[310] = "right parenthesis";
speech[311] = "semicolon";
speech[312] = "draw joint";
speech[313] = "left parenthesis";
speech[314] = "user I D";
speech[315] = "comma";
speech[316] = "Simple Open N I";
speech[317] = "dot";
speech[318] = "skel";
speech[319] = "underscore";
speech[320] = "right";
speech[321] = "underscore";
speech[322] = "hand";
speech[323] = "right parenthesis";
speech[324] = "semicolon";
speech[325] = "draw joint";
speech[326] = "left parenthesis";
speech[327] = "user I D";
speech[328] = "comma";
speech[329] = "Simple Open N I";
speech[330] = "dot";
speech[331] = "skel";
speech[332] = "underscore";
speech[333] = "right";
speech[334] = "underscore";
speech[335] = "hip";
speech[336] = "right parenthesis";
speech[337] = "semicolon";
speech[338] = "draw joint";
speech[339] = "left parenthesis";
speech[340] = "user I D";
speech[341] = "comma";
speech[342] = "Simple Open N I";
speech[343] = "dot";
speech[344] = "skel";
speech[345] = "underscore";
speech[346] = "left";
speech[347] = "underscore";
speech[348] = "hip";
speech[349] = "right parenthesis";
speech[350] = "semicolon";
speech[351] = "P Vector";
speech[352] = "L pos Prelim";
speech[353] = "equals";
speech[354] = "new";
speech[355] = "P vector";
speech[356] = "left parenthesis";
speech[357] = "right parenthesis";
speech[358] = "semicolon";
speech[359] = "P Vector";
speech[360] = "R pos Prelim";
speech[361] = "equals";
speech[362] = "new";
speech[363] = "P vector";
speech[364] = "left parenthesis";
speech[365] = "right parenthesis";
speech[366] = "semicolon";
speech[367] = "P Vector";
speech[368] = "R hip Prelim";
speech[369] = "equals";
speech[370] = "new";
speech[371] = "P vector";
speech[372] = "left parenthesis";
speech[373] = "right parenthesis";
speech[374] = "semicolon";
speech[375] = "P Vector";
speech[376] = "L hip Prelim";
speech[377] = "equals";
speech[378] = "new";
speech[379] = "P vector";
speech[380] = "left parenthesis";
speech[381] = "right parenthesis";
speech[382] = "semicolon";
speech[383] = "P Vector";
speech[384] = "L pos";
speech[385] = "equals";
speech[386] = "new";
speech[387] = "P vector";
speech[388] = "left parenthesis";
speech[389] = "right parenthesis";
speech[390] = "semicolon";
speech[391] = "P Vector";
speech[392] = "R pos";
speech[393] = "equals";
speech[394] = "new";
speech[395] = "P vector";
speech[396] = "left parenthesis";
speech[397] = "right parenthesis";
speech[398] = "semicolon";
speech[399] = "P Vector";
speech[400] = "R hip pos";
speech[401] = "equals";
speech[402] = "new";
speech[403] = "P vector";
speech[404] = "left parenthesis";
speech[405] = "right parenthesis";
speech[406] = "semicolon";
speech[407] = "P Vector";
speech[408] = "L hip pos";
speech[409] = "equals";
speech[410] = "new";
speech[411] = "P vector";
speech[412] = "left parenthesis";
speech[413] = "right parenthesis";
speech[414] = "semicolon";
speech[415] = "kinect";
speech[416] = "dot";
speech[417] = "get joint position skeleton";
speech[418] = "left parenthesis";
speech[419] = "user I D";
speech[420] = "comma";
speech[421] = "Simple open N I";
speech[422] = "dot";
speech[423] = "skel";
speech[424] = "underscore";
speech[425] = "left";
speech[426] = "underscore";
speech[427] = "hand";
speech[428] = "comma";
speech[429] = "L pos prelim";
speech[430] = "right parenthesis";
speech[431] = "semicolon";
speech[432] = "kinect";
speech[433] = "dot";
speech[434] = "get joint position skeleton";
speech[435] = "left parenthesis";
speech[436] = "user I D";
speech[437] = "comma";
speech[438] = "Simple open N I";
speech[439] = "dot";
speech[440] = "skel";
speech[441] = "underscore";
speech[442] = "right";
speech[443] = "underscore";
speech[444] = "hand";
speech[445] = "comma";
speech[446] = "R pos prelim";
speech[447] = "right parenthesis";
speech[448] = "semicolon";
speech[449] = "kinect";
speech[450] = "dot";
speech[451] = "get joint position skeleton";
speech[452] = "left parenthesis";
speech[453] = "user I D";
speech[454] = "comma";
speech[455] = "Simple open N I";
speech[456] = "dot";
speech[457] = "skel";
speech[458] = "underscore";
speech[459] = "right";
speech[460] = "underscore";
speech[461] = "hip";
speech[462] = "comma";
speech[463] = "L hip prelim";
speech[464] = "right parenthesis";
speech[465] = "semicolon";
speech[466] = "kinect";
speech[467] = "dot";
speech[468] = "get joint position skeleton";
speech[469] = "left parenthesis";
speech[470] = "user I D";
speech[471] = "comma";
speech[472] = "Simple open N I";
speech[473] = "dot";
speech[474] = "skel";
speech[475] = "underscore";
speech[476] = "left";
speech[477] = "underscore";
speech[478] = "hip";
speech[479] = "comma";
speech[480] = "L hip prelim";
speech[481] = "right parenthesis";
speech[482] = "semicolon";
speech[483] = "kinect";
speech[484] = "dot";
speech[485] = "convert real world to projective";
speech[486] = "left parenthesis";
speech[487] = "L pos Prelim";
speech[488] = "comma";
speech[489] = "L pos";
speech[490] = "right parenthesis";
speech[491] = "semicolon";
speech[492] = "kinect";
speech[493] = "dot";
speech[494] = "convert real world to projective";
speech[495] = "left parenthesis";
speech[496] = "R pos Prelim";
speech[497] = "comma";
speech[498] = "R pos";
speech[499] = "right parenthesis";
speech[500] = "semicolon";
speech[501] = "kinect";
speech[502] = "dot";
speech[503] = "convert real world to projective";
speech[504] = "left parenthesis";
speech[505] = "R hip Prelim";
speech[506] = "comma";
speech[507] = "R hip pos";
speech[508] = "right parenthesis";
speech[509] = "semicolon";
speech[510] = "kinect";
speech[511] = "dot";
speech[512] = "convert real world to projective";
speech[513] = "left parenthesis";
speech[514] = "L hip Prelim";
speech[515] = "comma";
speech[516] = "L hip pos";
speech[517] = "right parenthesis";
speech[518] = "semicolon";
speech[519] = "left X";
speech[520] = "equals";
speech[521] = "int";
speech[522] = "left parenthesis";
speech[523] = "L pos";
speech[524] = "dot";
speech[525] = "X";
speech[526] = "right parenthesis";
speech[527] = "semicolon";
speech[528] = "left Y";
speech[529] = "equals";
speech[530] = "int";
speech[531] = "left parenthesis";
speech[532] = "L pos";
speech[533] = "dot";
speech[534] = "Y";
speech[535] = "right parenthesis";
speech[536] = "semicolon";
speech[537] = "left Z";
speech[538] = "equals";
speech[539] = "int";
speech[540] = "left parenthesis";
speech[541] = "L pos";
speech[542] = "dot";
speech[543] = "Z";
speech[544] = "right parenthesis";
speech[545] = "semicolon";
speech[546] = "right X";
speech[547] = "equals";
speech[548] = "int";
speech[549] = "left parenthesis";
speech[550] = "R pos";
speech[551] = "dot";
speech[552] = "X";
speech[553] = "right parenthesis";
speech[554] = "semicolon";
speech[555] = "right Y";
speech[556] = "equals";
speech[557] = "int";
speech[558] = "left parenthesis";
speech[559] = "R pos";
speech[560] = "dot";
speech[561] = "Y";
speech[562] = "right parenthesis";
speech[563] = "semicolon";
speech[564] = "right Z";
speech[565] = "equals";
speech[566] = "int";
speech[567] = "left parenthesis";
speech[568] = "R pos";
speech[569] = "dot";
speech[570] = "Z";
speech[571] = "right parenthesis";
speech[572] = "semicolon";
speech[573] = "R hip X";
speech[574] = "equals";
speech[575] = "int";
speech[576] = "left parenthesis";
speech[577] = "R hip pos";
speech[578] = "dot";
speech[579] = "X";
speech[580] = "right parenthesis";
speech[581] = "semicolon";
speech[582] = "R hip Y";
speech[583] = "equals";
speech[584] = "int";
speech[585] = "left parenthesis";
speech[586] = "R hip pos";
speech[587] = "dot";
speech[588] = "Y";
speech[589] = "right parenthesis";
speech[590] = "semicolon";
speech[591] = "R hip Z";
speech[592] = "equals";
speech[593] = "int";
speech[594] = "left parenthesis";
speech[595] = "R hip pos";
speech[596] = "dot";
speech[597] = "Z";
speech[598] = "right parenthesis";
speech[599] = "semicolon";
speech[600] = "L hip X";
speech[601] = "equals";
speech[602] = "int";
speech[603] = "left parenthesis";
speech[604] = "L hip pos";
speech[605] = "dot";
speech[606] = "X";
speech[607] = "right parenthesis";
speech[608] = "semicolon";
speech[609] = "L hip Y";
speech[610] = "equals";
speech[611] = "int";
speech[612] = "left parenthesis";
speech[613] = "L hip pos";
speech[614] = "dot";
speech[615] = "Y";
speech[616] = "right parenthesis";
speech[617] = "semicolon";
speech[618] = "L hip Z";
speech[619] = "equals";
speech[620] = "int";
speech[621] = "left parenthesis";
speech[622] = "L hip pos";
speech[623] = "dot";
speech[624] = "Z";
speech[625] = "right parenthesis";
speech[626] = "semicolon";
speech[627] = "pitch 1";
speech[628] = "equals";
speech[629] = "int";
speech[630] = "left parenthesis";
speech[631] = "65.4";
speech[632] = "star";
speech[633] = "pow";
speech[634] = "left parenthesis";
speech[635] = "1.05946";
speech[636] = "comma";
speech[637] = "left parenthesis";
speech[638] = "33";
speech[639] = "minus";
speech[640] = "left parenthesis";
speech[641] = "left Y";
speech[642] = "slash";
speech[643] = "left parenthesis";
speech[644] = "L hip Y";
speech[645] = "slash";
speech[646] = "33";
speech[647] = "right parenthesis";
speech[648] = "right parenthesis";
speech[649] = "right parenthesis";
speech[650] = "right parenthesis";
speech[651] = "right parenthesis";
speech[652] = "semicolon";
speech[653] = "pitch 2";
speech[654] = "equals";
speech[655] = "int";
speech[656] = "left parenthesis";
speech[657] = "65.4";
speech[658] = "star";
speech[659] = "pow";
speech[660] = "left parenthesis";
speech[661] = "1.05946";
speech[662] = "comma";
speech[663] = "left parenthesis";
speech[664] = "33";
speech[665] = "minus";
speech[666] = "left parenthesis";
speech[667] = "right Y";
speech[668] = "slash";
speech[669] = "left parenthesis";
speech[670] = "R hip Y";
speech[671] = "slash";
speech[672] = "33";
speech[673] = "right parenthesis";
speech[674] = "right parenthesis";
speech[675] = "right parenthesis";
speech[676] = "right parenthesis";
speech[677] = "right parenthesis";
speech[678] = "semicolon";
speech[679] = "int";
speech[680] = "arm Length X";
speech[681] = "equals";
speech[682] = "487600";
speech[683] = "slash";
speech[684] = "r Hip Z";
speech[685] = "semicolon";
speech[686] = "vol 1";
speech[687] = "equals";
speech[688] = "map";
speech[689] = "left parenthesis";
speech[690] = "left X";
speech[691] = "comma";
speech[692] = "r hip X";
speech[693] = "minus";
speech[694] = "arm length X";
speech[695] = "comma";
speech[696] = ".70";
speech[697] = "comma";
speech[698] = "1.00";
speech[699] = "right parenthesis";
speech[700] = "semicolon";
speech[701] = "vol 2";
speech[702] = "equals";
speech[703] = "map";
speech[704] = "left parenthesis";
speech[705] = "right X";
speech[706] = "comma";
speech[707] = "R hip X";
speech[708] = "plus";
speech[709] = "arm length X";
speech[710] = "comma";
speech[711] = ".70";
speech[712] = "comma";
speech[713] = "1.00";
speech[714] = "right parenthesis";
speech[715] = "semicolon";
speech[716] = "int";
speech[717] = "avg hip Z";
speech[718] = "equals";
speech[719] = "left parenthesis";
speech[720] = "L hip Z";
speech[721] = "plus";
speech[722] = "R hip Z";
speech[723] = "right parenthesis";
speech[724] = "slash";
speech[725] = "2";
speech[726] = "semicolon";
speech[727] = "int";
speech[728] = "avg arm length";
speech[729] = "equals";
speech[730] = "left parenthesis";
speech[731] = "left parenthesis";
speech[732] = "avg hip Z";
speech[733] = "minus";
speech[734] = "left Z";
speech[735] = "right parenthesis";
speech[736] = "plus";
speech[737] = "left parenthesis";
speech[738] = "avg hip Z";
speech[739] = "minus";
speech[740] = "right Z";
speech[741] = "right parenthesis";
speech[742] = "right parenthesis";
speech[743] = "slash";
speech[744] = "2";
speech[745] = "semicolon";
speech[746] = "tempo";
speech[747] = "equals";
speech[748] = "int";
speech[749] = "left parenthesis";
speech[750] = "map";
speech[751] = "left parenthesis";
speech[752] = "avg arm length";
speech[753] = "comma";
speech[754] = "zero";
speech[755] = "comma";
speech[756] = "600";
speech[757] = "comma";
speech[758] = "50";
speech[759] = "comma";
speech[760] = "250";
speech[761] = "right parenthesis";
speech[762] = "right parenthesis";
speech[763] = "semicolon";
speech[764] = "if";
speech[765] = "left parenthesis";
speech[767] = "left Y";
speech[768] = "less than";
speech[769] = "L hip Y";
speech[770] = "right parenthesis";
speech[771] = "left curly bracket";
speech[772] = "voice 1 on";
speech[773] = "equals";
speech[774] = "true";
speech[775] = "semicolon";
speech[776] = "right curly bracket";
speech[777] = "else if";
speech[778] = "left parenthesis";
speech[779] = "left Y";
speech[780] = "greater than";
speech[781] = "equals";
speech[782] = "L hip Y";
speech[783] = "right parenthesis";
speech[784] = "left curly bracket";
speech[785] = "voice 1 on";
speech[786] = "equals";
speech[787] = "false";
speech[788] = "semicolon";
speech[789] = "right curly bracket";
speech[790] = "if";
speech[791] = "left parenthesis";
speech[792] = "right Y";
speech[793] = "less than";
speech[794] = "R hip Y";
speech[795] = "right parenthesis";
speech[796] = "left curly bracket";
speech[797] = "voice 2 on";
speech[798] = "equals";
speech[799] = "true";
speech[800] = "semicolon";
speech[801] = "right curly bracket";
speech[802] = "else if";
speech[803] = "left parenthesis";
speech[804] = "right Y";
speech[805] = "greater than";
speech[806] = "equals";
speech[807] = "R hip Y";
speech[808] = "right parenthesis";
speech[809] = "left curly bracket";
speech[810] = "voice 2 on";
speech[811] = "equals";
speech[812] = "false";
speech[813] = "semicolon";
speech[814] = "right curly bracket";
speech[815] = "if";
speech[816] = "left parenthesis";
speech[817] = "exclamation point";
speech[818] = "voice 1 on";
speech[819] = "ampersand";
speech[820] = "ampersand";
speech[821] = "exclamation point";
speech[822] = "voice 2 on";
speech[823] = "right parenthesis";
speech[824] = "left curly bracket";
speech[825] = "return";
speech[826] = "semicolon";
speech[827] = "right curly bracket";
speech[828] = "if";
speech[829] = "left parenthesis";
speech[830] = "voice 1 on";
speech[831] = "vertical bar vertical bar";
speech[832] = "voice 2 on";
speech[833] = "right parenthesis";
speech[834] = "left curly bracket";
speech[835] = "voice 1";
speech[836] = "dot";
speech[837] = "set pitch";
speech[838] = "left parenthesis";
speech[839] = "pitch 1";
speech[840] = "right parenthesis";
speech[841] = "semicolon";
speech[842] = "voice 2";
speech[843] = "dot";
speech[844] = "set pitch";
speech[845] = "left parenthesis";
speech[846] = "pitch 2";
speech[847] = "right parenthesis";
speech[848] = "semicolon";
speech[849] = "voice 1";
speech[850] = "dot";
speech[851] = "set volume";
speech[852] = "left parenthesis";
speech[853] = "vol 1";
speech[854] = "right parenthesis";
speech[855] = "semicolon";
speech[856] = "voice 2";
speech[857] = "dot";
speech[858] = "set volume";
speech[859] = "left parenthesis";
speech[860] = "vol 2";
speech[861] = "right parenthesis";
speech[862] = "semicolon";
speech[863] = "voice 1";
speech[864] = "dot";
speech[865] = "set tempo";
speech[866] = "left parenthesis";
speech[867] = "tempo";
speech[868] = "right parenthesis";
speech[869] = "semicolon";
speech[870] = "voice 2";
speech[871] = "dot";
speech[872] = "set tempo";
speech[873] = "left parenthesis";
speech[874] = "tempo";
speech[875] = "right parenthesis";
speech[876] = "semicolon";
speech[877] = "if";
speech[878] = "left parenthesis";
speech[879] = "voice 1 on";
speech[880] = "ampersand ampersand";
speech[881] = "exclamation point";
speech[882] = "voice 2 on";
speech[883] = "right parenthesis";
speech[884] = "left curly bracket";
speech[885] = "voice 1";
speech[886] = "dot";
speech[887] = "say";
speech[888] = "left parenthesis";
speech[889] = "speech";
speech[890] = "left bracket";
speech[891] = "I";
speech[892] = "right bracket";
speech[893] = "right parenthesis";
speech[894] = "semicolon";
speech[895] = "right curly bracket";
speech[896] = "else if";
speech[897] = "left parenthesis";
speech[898] = "exclamation point";
speech[899] = "voice 1 on";
speech[900] = "ampersand ampersand";
speech[901] = "voice 2 on";
speech[902] = "right parenthesis";
speech[903] = "left curly bracket";
speech[904] = "voice 2";
speech[905] = "dot";
speech[906] = "say";
speech[907] = "left parenthesis";
speech[908] = "speech";
speech[909] = "left bracket";
speech[910] = "I";
speech[911] = "right bracket";
speech[912] = "right parenthesis";
speech[913] = "semicolon";
speech[914] = "right curly bracket";
speech[915] = "else if";
speech[916] = "left parenthesis";
speech[917] = "voice 1 on";
speech[918] = "ampersand ampersand";
speech[919] = "voice 2 on";
speech[920] = "right parenthesis";
speech[921] = "left curly bracket";
speech[922] = "voice 1";
speech[923] = "dot";
speech[924] = "say";
speech[925] = "left parenthesis";
speech[926] = "speech";
speech[927] = "left bracket";
speech[928] = "I";
speech[929] = "right bracket";
speech[930] = "right parenthesis";
speech[931] = "semicolon";
speech[932] = "thread";
speech[933] = "left parenthesis";
speech[934] = "quote";
speech[935] = "voice 2";
speech[936] = "end quote";
speech[937] = "right parenthesis";
speech[938] = "semicolon";
speech[939] = "right curly bracket";
speech[940] = "I plus plus";
speech[941] = "semicolon";
speech[942] = "if";
speech[943] = "left parenthesis";
speech[944] = "I";
speech[945] = "greater than";
speech[946] = "1477";
speech[947] = "right parenthesis";
speech[948] = "left curly bracket";
speech[949] = "I";
speech[950] = "equals";
speech[951] = "zero";
speech[952] = "semicolon";
speech[953] = "right curly bracket";
speech[954] = "right curly bracket";
speech[955] = "right curly bracket";
speech[956] = "right curly bracket";
speech[957] = "right curly bracket";
speech[958] = "void";
speech[959] = "voice 2";
speech[960] = "left parenthesis";
speech[961] = "right parenthesis";
speech[962] = "left curly bracket";
speech[963] = "voice 2";
speech[964] = "dot";
speech[965] = "say";
speech[966] = "left parenthesis";
speech[967] = "speech";
speech[968] = "left bracket";
speech[969] = "I";
speech[970] = "right bracket";
speech[971] = "right parenthesis";
speech[972] = "semicolon";
speech[973] = "right curly bracket";
speech[974] = "void";
speech[975] = "draw Joint";
speech[976] = "left parenthesis";
speech[977] = "int";
speech[978] = "user I D";
speech[979] = "comma";
speech[980] = "int";
speech[981] = "joint I D";
speech[982] = "right parenthesis";
speech[983] = "left curly bracket";
speech[984] = "P vector";
speech[985] = "joint";
speech[986] = "equals";
speech[987] = "new";
speech[988] = "P vector";
speech[989] = "left parenthesis";
speech[990] = "right parenthesis";
speech[991] = "semicolon";
speech[992] = "float";
speech[993] = "confidence";
speech[994] = "equals";
speech[995] = "kinect";
speech[996] = "dot";
speech[997] = "get joint position skeleton";
speech[998] = "left parenthesis";
speech[999] = "user I D";
speech[1000] = "comma";
speech[1001] = "joint I D";
speech[1002] = "comma";
speech[1003] = "joint";
speech[1004] = "right parenthesis";
speech[1005] = "semicolon";
speech[1006] = "if";
speech[1007] = "left parenthesis";
speech[1008] = "confidence";
speech[1009] = "less than";
speech[1010] = "0.5";
speech[1011] = "right parenthesis";
speech[1012] = "left curly bracket";
speech[1013] = "returen";
speech[1014] = "semicolon";
speech[1015] = "right curly bracket";
speech[1016] = "P vector";
speech[1017] = "converted Joint";
speech[1018] = "equals";
speech[1019] = "new";
speech[1020] = "P vector";
speech[1021] = "left parenthesis";
speech[1022] = "right parenthesis";
speech[1023] = "semicolon";
speech[1024] = "kinect";
speech[1025] = "dot";
speech[1026] = "convert real world to projective";
speech[1027] = "left parenthesis";
speech[1028] = "joint";
speech[1029] = "comma";
speech[1030] = "converted joint";
speech[1031] = "right parenthesis";
speech[1032] = "semicolon";
speech[1033] = "ellipse";
speech[1034] = "left parenthesis";
speech[1035] = "converted joint";
speech[1036] = "dot";
speech[1037] = "X";
speech[1038] = "comma";
speech[1039] = "converted joint";
speech[1040] = "dot";
speech[1041] = "Y";
speech[1042] = "comma";
speech[1043] = "15";
speech[1044] = "comma";
speech[1045] = "15";
speech[1046] = "right parenthesis";
speech[1047] = "right curly bracket";
speech[1048] = "void";
speech[1049] = "on new user";
speech[1050] = "left parenthesis";
speech[1051] = "simple open N I";
speech[1052] = "cur context";
speech[1053] = "comma";
speech[1054] = "int";
speech[1055] = "user I D";
speech[1056] = "right parenthesis";
speech[1057] = "left curly bracket";
speech[1058] = "print L N";
speech[1059] = "left parenthesis";
speech[1060] = "quote";
speech[1061] = "on new user";
speech[1062] = "dash";
speech[1063] = "user I D";
speech[1064] = "colon";
speech[1065] = "end quote";
speech[1066] = "plus";
speech[1067] = "user I D";
speech[1068] = "right parenthesis";
speech[1069] = "semicolon";
speech[1070] = "print L N";
speech[1071] = "left parenthesis";
speech[1072] = "quote";
speech[1073] = "forward slash";
speech[1074] = "T start";
speech[1075] = "tracking";
speech[1076] = "skeleton";
speech[1077] = "end quote";
speech[1078] = "right parenthesis";
speech[1079] = "semicolon";
speech[1080] = "kinect";
speech[1081] = "dot";
speech[1082] = "start tracking skeleton";
speech[1083] = "left parenthesis";
speech[1084] = "user I D";
speech[1085] = "right parenthesis";
speech[1086] = "semicolon";
speech[1087] = "right curly bracket";
speech[1088] = "void";
speech[1089] = "on lost user";
speech[1090] = "left parenthesis";
speech[1091] = "simple open N I";
speech[1092] = "cur context";
speech[1093] = "comma";
speech[1094] = "int";
speech[1095] = "user I D";
speech[1096] = "right parenthesis";
speech[1097] = "left curly bracket";
speech[1098] = "print L N";
speech[1099] = "quote";
speech[1100] = "on lost user";
speech[1101] = "dash";
speech[1102] = "user I D";
speech[1103] = "colon";
speech[1104] = "end quote";
speech[1105] = "plus";
speech[1106] = "user I D";
speech[1107] = "right parenthesis";
speech[1108] = "semicolon";
speech[1109] = "right curly bracket";
speech[1110] = "void";
speech[1111] = "on visible user";
speech[1112] = "left parenthesis";
speech[1113] = "simple open N I";
speech[1114] = "cur context";
speech[1115] = "comma";
speech[1116] = "int";
speech[1117] = "user I D";
speech[1118] = "right parenthesis";
speech[1119] = "left curly bracket";
speech[1120] = "right curly bracket";
speech[1121] = "public class";
speech[1122] = "Basnik";
speech[1123] = "left curly bracket";
speech[1124] = "string";
speech[1125] = "voice name";
speech[1126] = "equals";
speech[1127] = "quote";
speech[1128] = "kevin 16";
speech[1129] = "end quote";
speech[1130] = "semicolon";
speech[1131] = "voice manager";
speech[1132] = "voice manager";
speech[1133] = "semicolon";
speech[1134] = "voice";
speech[1135] = "voice";
speech[1136] = "semicolon";
speech[1137] = "Basnik";
speech[1138] = "left parenthesis";
speech[1139] = "string";
speech[1140] = "name";
speech[1141] = "right parenthesis";
speech[1142] = "left curly bracket";
speech[1143] = "voice name";
speech[1144] = "equals";
speech[1145] = "name";
speech[1146] = "semicolon";
speech[1147] = "this";
speech[1148] = "dot";
speech[1149] = "setup";
speech[1150] = "left parenthesis";
speech[1151] = "right parenthesis";
speech[1152] = "semicolon";
speech[1153] = "right curly bracket";
speech[1154] = "void";
speech[1155] = "list all voices";
speech[1156] = "left parenthesis";
speech[1157] = "right parenthesis";
speech[1158] = "left curly bracket";
speech[1159] = "system";
speech[1160] = "dot";
speech[1161] = "out";
speech[1162] = "dot";
speech[1163] = "print L N";
speech[1164] = "left parenthesis";
speech[1165] = "right parenthesis";
speech[1166] = "semicolon";
speech[1167] = "system";
speech[1168] = "dot";
speech[1169] = "out";
speech[1170] = "dot";
speech[1171] = "print L N";
speech[1172] = "left parenthesis";
speech[1173] = "quote";
speech[1174] = "All";
speech[1175] = "voices";
speech[1176] = "available";
speech[1177] = "colon";
speech[1178] = "end quote";
speech[1179] = "right parenthesis";
speech[1180] = "semicolon";
speech[1181] = "voice manager";
speech[1182] = "voice manager";
speech[1183] = "equals";
speech[1184] = "voice manager";
speech[1185] = "dot";
speech[1186] = "get Instance";
speech[1187] = "left parenthesis";
speech[1188] = "right parenthesis";
speech[1189] = "semicolon";
speech[1190] = "voice";
speech[1191] = "left bracket";
speech[1192] = "right bracket";
speech[1193] = "voices";
speech[1194] = "equals";
speech[1195] = "voice manager";
speech[1196] = "dot";
speech[1197] = "get voices";
speech[1198] = "left parenthesis";
speech[1199] = "right parenthesis";
speech[1200] = "semicolon";
speech[1201] = "for";
speech[1202] = "left parenthesis";
speech[1203] = "int";
speech[1204] = "I";
speech[1205] = "equals";
speech[1206] = "zero";
speech[1207] = "semicolon";
speech[1208] = "I";
speech[1209] = "less than";
speech[1210] = "voices";
speech[1211] = "dot";
speech[1212] = "length";
speech[1213] = "semicolon";
speech[1214] = "I plus plus";
speech[1215] = "right parenthesis";
speech[1216] = "left curly bracket";
speech[1217] = "system";
speech[1218] = "dot";
speech[1219] = "out";
speech[1220] = "dot";
speech[1221] = "print L N";
speech[1222] = "left parenthesis";
speech[1223] = "quote";
speech[1224] = "end quote";
speech[1225] = "plus";
speech[1226] = "voices";
speech[1227] = "left bracket";
speech[1228] = "I";
speech[1229] = "right bracket";
speech[1230] = "dot";
speech[1231] = "get name";
speech[1232] = "left parenthesis";
speech[1233] = "right parenthesis";
speech[1234] = "plus";
speech[1235] = "quote";
speech[1236] = "left parenthesis";
speech[1237] = "end quote";
speech[1238] = "plus";
speech[1239] = "voices";
speech[1240] = "left bracket";
speech[1241] = "I";
speech[1242] = "right bracket";
speech[1243] = "dot";
speech[1244] = "get domain";
speech[1245] = "left parenthesis";
speech[1246] = "right parenthesis";
speech[1247] = "plus";
speech[1248] = "quote";
speech[1249] = "domain";
speech[1250] = "right parenthesis";
speech[1251] = "end quote";
speech[1252] = "right parenthesis";
speech[1253] = "semicolon";
speech[1254] = "right curly bracket";
speech[1255] = "right curly bracket";
speech[1256] = "void";
speech[1257] = "setup";
speech[1258] = "left parenthesis";
speech[1259] = "right parenthesis";
speech[1260] = "left curly bracket";
speech[1261] = "list all voices";
speech[1262] = "left parenthesis";
speech[1263] = "right parenthesis";
speech[1264] = "semicolon";
speech[1265] = "system";
speech[1266] = "dot";
speech[1267] = "out";
speech[1268] = "dot";
speech[1269] = "print L N";
speech[1270] = "left parenthesis";
speech[1271] = "right parenthesis";
speech[1272] = "semicolon";
speech[1273] = "system";
speech[1274] = "dot";
speech[1275] = "out";
speech[1276] = "dot";
speech[1277] = "print L N";
speech[1278] = "left parenthesis";
speech[1279] = "quote";
speech[1280] = "using voice";
speech[1281] = "colon";
speech[1282] = "end quote";
speech[1283] = "plus";
speech[1284] = "voice name";
speech[1285] = "right parenthesis";
speech[1286] = "semicolon";
speech[1287] = "voice manager";
speech[1288] = "equals";
speech[1289] = "voice manager";
speech[1290] = "dot";
speech[1291] = "get instance";
speech[1292] = "left parenthesis";
speech[1293] = "right parenthesis";
speech[1294] = "semicolon";
speech[1295] = "voice";
speech[1296] = "equals";
speech[1297] = "voice manager";
speech[1298] = "dot";
speech[1299] = "get voice";
speech[1300] = "left parenthesis";
speech[1301] = "voice name";
speech[1302] = "right parenthesis";
speech[1303] = "semicolon";
speech[1304] = "voice";
speech[1305] = "dot";
speech[1306] = "set style";
speech[1307] = "left parenthesis";
speech[1308] = "quote";
speech[1309] = "casual";
speech[1310] = "end quote";
speech[1311] = "right parenthesis";
speech[1312] = "semicolon";
speech[1313] = "if";
speech[1314] = "left parenthesis";
speech[1315] = "voice";
speech[1316] = "equals equals";
speech[1317] = "null";
speech[1318] = "right parenthesis";
speech[1319] = "left curly bracket";
speech[1320] = "system";
speech[1321] = "dot";
speech[1322] = "err";
speech[1323] = "dot";
speech[1324] = "print L N";
speech[1325] = "left parenthesis";
speech[1326] = "quote";
speech[1327] = "cannot";
speech[1328] = "find";
speech[1329] = "a";
speech[1330] = "voice";
speech[1331] = "named";
speech[1332] = "end quote";
speech[1333] = "plus";
speech[1334] = "voice name";
speech[1335] = "plus";
speech[1336] = "quote";
speech[1337] = "period";
speech[1338] = "please";
speech[1339] = "specify";
speech[1340] = "a";
speech[1341] = "different";
speech[1342] = "voice";
speech[1343] = "period";
speech[1344] = "end quote";
speech[1345] = "right parenthesis";
speech[1346] = "semicolon";
speech[1347] = "system";
speech[1348] = "dot";
speech[1349] = "exit";
speech[1350] = "left parenthesis";
speech[1351] = "1";
speech[1352] = "right parenthesis";
speech[1353] = "semicolon";
speech[1354] = "right curly bracket";
speech[1355] = "voice";
speech[1356] = "dot";
speech[1357] = "allocate";
speech[1358] = "left parenthesis";
speech[1359] = "right parenthesis";
speech[1360] = "semicolon";
speech[1361] = "right curly bracket";
speech[1362] = "void";
speech[1363] = "set pitch";
speech[1364] = "left parenthesis";
speech[1365] = "int";
speech[1366] = "P";
speech[1367] = "right parenthesis";
speech[1368] = "left curly bracket";
speech[1369] = "voice";
speech[1370] = "dot";
speech[1371] = "set pitch";
speech[1372] = "left parenthesis";
speech[1373] = "P";
speech[1374] = "right parenthesis";
speech[1375] = "left curly bracket";
speech[1376] = "void";
speech[1377] = "set pitch shift";
speech[1378] = "left parenthesis";
speech[1379] = "int";
speech[1380] = "S";
speech[1381] = "right parenthesis";
speech[1382] = "left curly bracket";
speech[1383] = "voice";
speech[1384] = "dot";
speech[1385] = "set pitch";
speech[1386] = "left parenthesis";
speech[1387] = "S";
speech[1388] = "right parenthesis";
speech[1389] = "semicolon";
speech[1390] = "right curly bracket";
speech[1391] = "void";
speech[1392] = "set range";
speech[1393] = "left parenthesis";
speech[1394] = "int";
speech[1395] = "R";
speech[1396] = "right parenthesis";
speech[1397] = "left curly bracket";
speech[1398] = "voice";
speech[1399] = "dot";
speech[1400] = "set pitch range";
speech[1401] = "left parenthesis";
speech[1402] = "R";
speech[1403] = "right parenthesis";
speech[1404] = "semicolon";
speech[1405] = "right curly bracket";
speech[1406] = "void";
speech[1407] = "set volume";
speech[1408] = "left parenthesis";
speech[1409] = "float";
speech[1410] = "V";
speech[1411] = "right parenthesis";
speech[1412] = "left curly bracket";
speech[1413] = "voice";
speech[1414] = "dot";
speech[1415] = "set volume";
speech[1416] = "left parenthesis";
speech[1417] = "V";
speech[1418] = "right parenthesis";
speech[1419] = "semicolon";
speech[1420] = "right curly bracket";
speech[1421] = "void";
speech[1422] = "set tempo";
speech[1423] = "left parenthesis";
speech[1424] = "int";
speech[1425] = "T";
speech[1426] = "right parenthesis";
speech[1427] = "left curly bracket";
speech[1428] = "voice";
speech[1429] = "dot";
speech[1430] = "set rate";
speech[1431] = "left parenthesis";
speech[1432] = "T";
speech[1433] = "right parenthesis";
speech[1434] = "semicolon";
speech[1435] = "right curly bracket";
speech[1436] = "void";
speech[1437] = "say";
speech[1438] = "left parenthesis";
speech[1439] = "string";
speech[1440] = "underscore A";
speech[1441] = "right parenthesis";
speech[1442] = "left curly bracket";
speech[1443] = "if";
speech[1444] = "left parenthesis";
speech[1445] = "underscore A";
speech[1446] = "equals equals";
speech[1447] = "null";
speech[1448] = "right parenthesis";
speech[1449] = "left curly bracket";
speech[1450] = "underscore A";
speech[1451] = "equals";
speech[1452] = "quote";
speech[1453] = "nothing";
speech[1454] = "end quote";
speech[1455] = "semicolon";
speech[1456] = "right curly bracket";
speech[1457] = "voice";
speech[1458] = "dot";
speech[1459] = "speak";
speech[1460] = "left parenthesis";
speech[1461] = "underscore A";
speech[1462] = "right parenthesis";
speech[1463] = "semicolon";
speech[1464] = "right curly bracket";
speech[1465] = "void";
speech[1466] = "exit";
speech[1467] = "left parenthesis";
speech[1468] = "right parenthesis";
speech[1469] = "left curly bracket";
speech[1470] = "voice";
speech[1471] = "dot";
speech[1472] = "deallocate";
speech[1473] = "left parenthesis";
speech[1474] = "right parenthesis";
speech[1475] = "semicolon";
speech[1476] = "right curly bracket";
speech[1477] = "right curly bracket";
///////////////////////////////////
i = 0;
voice1on = false;
voice2on = false;
}
void draw(){
background(0);
kinect.update();
image(kinect.depthImage(), 0, 0);
IntVector userList = new IntVector();
kinect.getUsers(userList);
// if user's detected...
if (userList.size() > 0) {
int userId = userList.get(0);
// track and draw the hands
if (kinect.isTrackingSkeleton(userId)) {
drawJoint(userId, SimpleOpenNI.SKEL_LEFT_HAND);
drawJoint(userId, SimpleOpenNI.SKEL_RIGHT_HAND);
drawJoint(userId, SimpleOpenNI.SKEL_RIGHT_HIP);
drawJoint(userId, SimpleOpenNI.SKEL_LEFT_HIP);
// get hand and hip positions
PVector LposPrelim = new PVector();
PVector RposPrelim = new PVector();
PVector RhipPrelim = new PVector();
PVector LhipPrelim = new PVector();
PVector Lpos = new PVector();
PVector Rpos = new PVector();
PVector RhipPos = new PVector();
PVector LhipPos = new PVector();
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, LposPrelim);
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, RposPrelim);
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HIP, RhipPrelim);
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HIP, LhipPrelim);
kinect.convertRealWorldToProjective(LposPrelim, Lpos);
kinect.convertRealWorldToProjective(RposPrelim, Rpos);
kinect.convertRealWorldToProjective(RhipPrelim, RhipPos);
kinect.convertRealWorldToProjective(LhipPrelim, LhipPos);
// variables for joint positions
leftX = int(Lpos.x);
leftY = int(Lpos.y);
leftZ = int(Lpos.z);
rightX = int(Rpos.x);
rightY = int(Rpos.y);
rightZ = int(Rpos.z);
rHipX = int(RhipPos.x);
rHipY = int(RhipPos.y);
rHipZ = int(RhipPos.z);
lHipX = int(LhipPos.x);
lHipY = int(LhipPos.y);
lHipZ = int(LhipPos.z);
// MAP HAND POSITION TO AUDIO CONTROLS /////////////////////////
// convert y location of hand (from top of screen [0 px] to the location of the hips [r/lHipY])
// to pitch frequency (C2 [65.4064 Hz] to A4 [440])
// using Equal-Tempered Scale's semitone interval ratio of 1.05946
pitch1 = int(65.4 * pow(1.05946,(33-(leftY/(lHipY/33))))); // starting pitch Hz * semitone interval ratio ^(# of semitones in range - (leftY/number of pixels per semitone, which is the hipY / #of semitones in range))
pitch2 = int(65.4 * pow(1.05946,(33-(rightY/(rHipY/33)))));
// convert x location of hand (on a scale from the opposing hip'sX to full lateral arm extension)
// to volume (pianisimo [.4] to forte [1]
// find full extension:
// Givens: arm length = 30"; at 1219mm, 30" equals 400px; inverse proportion (forshortening) means that armlength = k/distance, where k (the constant of proportionality) = 487600 (400=k/1219)
// if k=487600, then length=487600/dist
int armLengthX = 487600/rHipZ;
vol1 = map(leftX, rHipX,lHipX-armLengthX, .70,1.00);
vol2 = map(rightX, lHipX,rHipX+armLengthX, .70,1.00);
// convert average of two arms z distance from body
// to tempo (close to body = slow [50], full extension = fast [250]
int avgHipZ = (lHipZ+rHipZ)/2; // get average distance of hips to camera
int avgArmLength = ((avgHipZ-leftZ)+(avgHipZ-rightZ))/2; // get average distance from hips to hands
tempo = int(map(avgArmLength, 0,600, 50,250)); // assumes 60cm arm span
// if the given hand is raised, turn on the respective voice
if (leftY < lHipY){
voice1on = true;
} else if (leftY >= lHipY){
voice1on = false;
}
if (rightY < rHipY){
voice2on = true;
} else if (rightY >= rHipY){
voice2on = false;
}
// if neither voice is turned on (i.e. both hands are down) exit the loop
if(!voice1on && !voice2on){
return;
}
// if either voice is on (either hand is raised) set the pitch, volume, tempo
if (voice1on || voice2on){
voice1.setPitch(pitch1);
voice2.setPitch(pitch2);
voice1.setVolume(vol1);
voice2.setVolume(vol2);
voice1.setTempo(tempo);
voice2.setTempo(tempo);
// if left is raised and right isn't
if(voice1on && !voice2on){
voice1.say(speech[i]);
}
// if right is raised and left isn't
else if (!voice1on && voice2on){
voice2.say(speech[i]);
}
// if both are raised
else if (voice1on && voice2on){
voice1.say(speech[i]);
thread("voice2"); //threaded so multiple voices speak simultaneously rather than consecutively
}
// now that either voice has sung one word, increment that word to the next one
i++;
if (i > 1477){
i=0;
}
}
}
}
}
// THREAD FOR SECOND VOICE ///////////////////////////////
void voice2(){
//delay(50); // to get the voices in sync
voice2.say(speech[i]);
}
/// DRAWJOINT FUNCTION //////////////////////////////////
void drawJoint(int userId, int jointID) {
PVector joint = new PVector();
float confidence = kinect.getJointPositionSkeleton(userId, jointID, joint);
if (confidence < 0.5) {
return;
}
PVector convertedJoint = new PVector();
kinect.convertRealWorldToProjective(joint, convertedJoint);
ellipse(convertedJoint.x, convertedJoint.y, 15,15);
}
///// KINECT User tracking callbacks ///////////////////////
// SimpleOpenNI user events
void onNewUser(SimpleOpenNI curContext,int userId){
println("onNewUser - userId: " + userId);
println("\tstart tracking skeleton");
kinect.startTrackingSkeleton(userId);
}
void onLostUser(SimpleOpenNI curContext,int userId){
println("onLostUser - userId: " + userId);
}
void onVisibleUser(SimpleOpenNI curContext,int userId){
//println("onVisibleUser - userId: " + userId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment