# 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.

![](/files/-Lpg3R2F4nBIZTgG6DGE)

**Toggle on Upload mode**

Click to toggle on Upload mode.

![](/files/-Lpg3R2GR7p18DX9b1XY)

**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.

![](/files/-Lpg3R2H6HLOgKHSRDsf)

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 ().

![](/files/-Lpg3R2IVkpUtD-4LE3A)

**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.

![](/files/-Lpg3R2Jb21vd2aH03FA)

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

![](/files/-Lpg3R2Kr-XyLPJpO71c)

**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.

![](/files/-Lpg3R2LOqcJu7rWD37U)

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.

![](/files/-Lpg3R2MQw7e7LT_mzcC)

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

![](/files/-Lpg3R2NXk8wmsirMnap)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pakronics.com.au/halocode-1/speech-recognition.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
