Hello everyone!
I’m really new to processing, I’m trying to do a voice recognition patch in which if certain words are said the program display images or text and so on…
The voice recognition work, but I think I’m missing something in the if condition at the end because when I say “Dog” nothing happens.
Thank you!!
import websockets.*;
WebsocketServer ws;
int crono_check = 60000;
int crono_ws = -crono_check;
String SpeechDetectorLink = "site.com";
String lastSpeech = "";
void setup()
{
size(500,500);
ws= new WebsocketServer(this,8080,"/");
// Rendo la finestra di output sempre on top
surface.setAlwaysOnTop(true);
}
void draw()
{
background(0);
if(millis() - crono_ws >= crono_check)
{
openSpeechDetectorLink();
}
int sectorefresh = (int)((crono_check - (millis() - crono_ws)) / 1000.0);
text("Last speech: " + lastSpeech, 20, 20);
text("Refresh link in " + sectorefresh + " sec", 20, 40);
}
void webSocketServerEvent(String msg)
{
lastSpeech = msg;
println(msg + " (" + msg.length());
crono_ws = millis();
String[] m1 = match(msg, "mela");
if (m1 != null)
{
// If not null, then a match was found
println("-----------------------");
}
}
void openSpeechDetectorLink()
{
link(SpeechDetectorLink);
crono_ws = millis();
println("Launched link: " + SpeechDetectorLink);
}
void voicerecognition ()
{
if (lastSpeech.equals("dog")) ;{
println("Matching voice");
}
}