STT library

edited June 2015 in Library Questions

Hi, I think this is more like a general code question than a library question, but I am using the STT library in this sketch and probably is a good Idea to put my question here. I am trying something on the STT Basic example of the getflourish.stt library and want to be able to say, if the utterance result is "test", do this, but I must be doing something wrong because although the println command prints the right utterance result, my if statement doesn't agree with that. Can someone tell me what am I doing wrong This is the sketch:

import com.getflourish.stt.*;
STT stt;
String result;
String key = "mykeygoeshere";

void setup ()
{
  size(600, 200);
  // Init STT with default manual record mode

  stt = new STT(this, key);
  stt.enableDebug();
  stt.setLanguage("en"); 

  // Some text to display the result
  textFont(createFont("Arial", 24));
  result = "Say something!";
}

void draw ()
{
  background(0);
  text(result, mouseX, mouseY);
}

// Method is called if transcription was successfull 
void transcribe (String utterance, float confidence) 
{
   result = utterance;
}

// Use any key to begin and end a record
public void keyPressed () {
  stt.begin();
}
public void keyReleased () {
  stt.end();

}

void mousePressed() {
println(result);
if (result == "test") {
println("CORRECT");
} else {
println("NOOOOO");
}
}

Although I can see the right result from the console, I get the "NOOOO" from my if statement

Tagged:

Answers

Sign In or Register to comment.