# Voice recognition

**URL:** <https://discourse.processing.org/t/voice-recognition/11563>\
**Category:** Libraries\
**Created:** [May 24, 2019, 6:02pm UTC](https://discourse.processing.org/t/voice-recognition/11563 "2019-05-24T18:02:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Margu](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Margu](https://discourse.processing.org/u/Margu)\
**Post date:** [May 24, 2019, 6:02pm UTC](https://discourse.processing.org/t/voice-recognition/11563/1 "2019-05-24T18:02:19Z")

</div>

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!!

```auto
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");
  }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 28, 2019, 5:33am UTC](https://discourse.processing.org/t/voice-recognition/11563/2 "2019-05-28T05:33:54Z")

</div>

> [@Margu](#):
>
> The voice recognition work, but

How do you know that it works? When does it work, and what happens?
