Table of Contents

How to Build an AI Speech Recognition Assistant in PictoBlox

Example Description
Learn how to create an AI-powered Speech Recognition Assistant in PictoBlox using two different approaches. In the first method, the Speech Recognition Extension is used to detect spoken commands, while in the second method, the Artificial Intelligence Extension performs speech recognition.

Introduction

Speech recognition enables computers to understand and respond to spoken language, making interactions more natural and engaging. In this project, users can ask simple questions such as “What is your name?”, and the AI assistant replies with “My name is Tobi.” If the question is not recognised, it politely asks the user to try again. This project introduces voice-based interaction using PictoBlox and demonstrates two different methods for implementing speech recognition.

Setting Up the Stage

  1. Open PictoBlox and create a new project.
  2. Keep the default Tobi sprite or choose any sprite of your choice.
  3. Ensure that your computer’s microphone is enabled and accessible.
  4. Add the following extensions:
    1. Speech Recognition Extension (Method 1)
    2. Artificial Intelligence Extension (Method 2)
    3. Text-to-Speech Extension

Step-by-Step Block Coding Guide

Method 1: Using the Speech Recognition Extension

Step 1: Configure the Voice Assistant

  1. Add the When Green Flag Clicked block to start the program.
  2. Set the voice to Giant using the Text-to-Speech block.
  3. Set the language to English.
  4. Position the sprite at the desired location on the stage using the Go to x: y: block.

AI Speech Recognition Code

Step 2: Start Listening for Voice Commands

  1. Use the Start Listening block from the Speech Recognition extension.
  2. Wait for a short duration (for example, 2 seconds) to allow the extension to capture the user’s speech.AI Speech Recognition Code

Step 3: Check the Recognised Speech

  1. Use an If-Else condition to verify whether the speech recognition result contains “What is your name?”.
  2. if the condition is true:
    1. Display the message “My name is Tobi.”
    2. Speak the same response using the Text-to-Speech extension.
  3. Otherwise:
    1. Display “Please ask again!”
    2. Speak “Please ask again!”

AI Speech Recognition Code

Final Code –AI Speech Recognition Code

Method 2: Using the Artificial Intelligence Extension

Step 1: Configure the Voice Assistant

  1. Add the When Green Flag Clicked block.
  2. Set the voice to Giant.
  3. Set the language to English.
  4. Position the sprite using the Go to x: y: block.
  5. Use the Recognise Speech for a 2-second block from the Artificial Intelligence extension.
  6. Select English (United States) as the recognition language.

AI Speech Recognition Code

Step 2: Process the Voice Command

  1. Place the recognition process inside a Forever loop to continuously monitor speech.
  2. Check whether the speech recognition result contains “What is your name?”.
  3. If the command matches:
    1. Show the message “My name is Tobi.”
    2. Speak the response using Text-to-Speech.
  4. Otherwise:
    1. Show “Please ask again!”
    2. Speak “Please ask again!”

AI Speech Recognition Code

AI Speech Recognition Code

Conclusion

This project demonstrates two effective approaches to implementing speech recognition in PictoBlox using the Speech Recognition Extension and the Artificial Intelligence Extension. By combining voice input with Text-to-Speech responses, users can create interactive virtual assistants that understand and respond to spoken commands. It is an excellent beginner project for exploring AI, natural language interaction, and voice-enabled applications.