# Speech Recognition

With HaloCode's microphone and built-in Wi-Fi, we can make a simple speech recognition application. The internet enables HaloCode to use Microsoft's speech recognition service. You need to sign in/up to mBlock 5 to connect your HaloCode to the internet.

**Sign in to mBlock 5**

HaloCode needs to connect to the internet to use online speech recognition service. We need to sign in to mBlock 5 first.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2F4nBIZTgG6DGE%2F0.gif?generation=1569476166444902\&alt=media)

**Toggle on Upload mode**

Click to toggle on Upload mode.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2GR7p18DX9b1XY%2F1.gif?generation=1569476166396591\&alt=media)

**Connect to the internet**

1\. Drag an Events block when HaloCode starts up and a Wi-Fi block connect to Wi-Fi () password (). Input the Wi-Fi name and password.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2H6HLOgKHSRDsf%2F2.gif?generation=1569476166495390\&alt=media)

2\. We want to know when the Wi-Fi is successfully connected. Add a Control block wait (), a Wi-Fi block Wi-Fi is connected?, and a Lighting block all LEDs light up ().

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2IVkpUtD-4LE3A%2F3.gif?generation=1569476166498207\&alt=media)

**Speech recognition**

When the button is pressed, HaloCode will start speech recognition and all LEDs will light up white. The recognition process lasts for 3 seconds. When it's done, all LEDs will go off as a signal.

3\. Add an Events block when button is pressed and a Lighting block all LEDs light up (). Change the color to white. Then add a Wi-Fi block recognize (English) for (3) seconds.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2Jb21vd2aH03FA%2F4.gif?generation=1569476166628182\&alt=media)

4\. Add a Lighting block light off all LEDs to light off all LEDs after the speech recognition is done.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2Kr-XyLPJpO71c%2F5.gif?generation=1569476166377465\&alt=media)

**Recognize "red"**

5\. Add a Control block if () then () and an Operators block () contains ()?. Add Wi-Fi block speech recognition result to the first box and input "red" to the second box.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2LOqcJu7rWD37U%2F6.gif?generation=1569476166511493\&alt=media)

6\. If the speech recognition result contains "red", all LEDs will light red, and go off in 1 second. Add these blocks: all LEDs light up (), wait () seconds, and light off all LEDs.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2MQw7e7LT_mzcC%2F7.gif?generation=1569476166510069\&alt=media)

7\. Click "Upload" to upload the program to HaloCode.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg3R2NXk8wmsirMnap%2F8.gif?generation=1569476166400557\&alt=media)

8\. Wait until all the LEDs light up green. Then press the button and say "red". Check the LEDs of HaloCode.
