Table of Contents

speak ()

Description

The speak () block uses the text-to-speech tool to speak the given text. It will speak the selected voice with the chosen language in the set language to () block. Usage of the block is limited to 128 characters. If a string longer than 128 characters is given, then only the first 128 characters will be spoken.

Example

Discover an interactive way to get word definitions using ChatGPT and text-to-speech. Prompt users to choose a definition, generate it with ChatGPT, and have the sprite speak it out using the text-to-speech extension.

Logic

We ask the user which definition they want, and based on their input, ChatGPT generates the definition of the particular word. The sprite then uses the text-to-speech extension to speak out the definition.

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. Choose a suitable coding environment for block-based coding.
  3. Add the text-to-speech and ChatGPT extensions to your project from the extension palette located at the bottom right corner of PictoBlox.
  4. We use the Set Maximum Length to () block to specify the maximum length in ChatGPT, which represents the maximum number of words allowed in a single message.
  5. We prompt users to indicate which definition they would like to receive.
  6. We pass this input to the define() block, which sends a request to ChatGPT to define the user answer.
  7. We utilize the getAI block to retrieve the most recent response from ChatGPT. Then, we use the say() method to have the sprite speak out this response.
  8. Finally, we utilize the speak() block from the text-to-speech extension to have the given text spoken aloud.

Code

Output

Read More
Experience an interactive chatbox where you can specify the tone of AI responses. Ask questions or share thoughts on various topics, and receive personalized answers.

Introduction

In this interactive chatbox experience, the user has the freedom to specify the tone in which they would like the AI to respond. The tone can be anything they prefer: Normal, sarcastic, Friend that suits their preference.

Once the user has selected a particular tone, they can provide their input or ask a question. Based on their input, the AI will generate a response that aligns with the chosen tone. This allows for the creation of a conversational atmosphere similar to real-life interactions.

Users are encouraged to ask any question or share their thoughts on various topics. They can also engage in discussions or seek assistance with the information they need. The AI is there to facilitate a meaningful conversation and provide helpful responses based on the tone chosen by the user.

So, the user is requested to let the AI know the specific tone they would like it to adopt, and then they are free to ask any question they have in mind. The AI is here to provide a personalized and engaging chat experience!

Code

Logic

  1. Open PictoBlox and create a new file.
  2. Choose a suitable coding environment for Block-based coding.
  3. We create an instance of the Speech recognition.This class allows us to convert spoken audio into text.
  4. Next, we create an instance of the ChatGPT model called gpt. ChatGPT is a language model that can generate human-like text responses based on the input it receives. 
  5. We create an instance of the Text to Speech.This class allows us to speak the output.
  6. Use the “recognize speech” block to capture the user’s speech for a duration of 5 seconds.
  7. First, ask the user which format they prefer for the answer: normal, sarcastic, or friendly
  8. If the user requests a normal response, the ChatGPT extension will generate feedback in normal mode.
  9. If the user requests a sarcastic response, ChatGPT will generate a sarcastic answer.
  10. If the user requests a friendly response, ChatGPT will generate a friendly answer. Additionally, Sprite will speak the answer.
  11. The “speak” block, which utilizes the text-to-speech recognition extension, will vocalize the answer to the asked question.

In summary, we can describe it as a chatbox that provides answers in three different ways based on the user’s mood and entertainment preferences. When a question is asked, it will respond accordingly.

Output

Read More
Learn how to build your own AI talking character using PictoBlox, ou will program Tobi to speak, ask questions, and generate personalised responses based on user input. The project combines real-time voice output with animated lip-sync, simulating how virtual assistants work.

Introduction

Have you ever wondered how virtual assistants like Siri or Alexa talk to you? Behind every talking AI, there’s a combination of text-to-speech technology, data variables, and smart programming logic. Today, we’re going to build our very own version, right inside PictoBlox!

In this STEM project, students will program Tobi, PictoBlox’s built-in sprite character, to greet users, ask for their name, and respond with a personalised welcome message. Along the way, learners will discover how AI-powered chatbots use variables, conditions, and speech synthesis to hold a natural conversation.

How the AI Talking Character Works

This project consists of two main scripts running in parallel — a classic pattern in AI-driven applications:

  • Script 1 — Mouth Animation: Continuously checks if Tobi is “Talking” (using a variable) and alternates between mouth-open and mouth-closed costumes to simulate realistic speech animation.
  • Script 2 — Dialogue & AI Response: Controls the full conversation flow — from greeting the user to asking for their name to generating a personalised spoken response using the TTS extension.

Together, these two scripts mirror how modern AI assistants work: one process handles the voice output (TTS), while another handles the animated visual feedback (avatar lip-sync). This is a simplified but accurate representation of how virtual AI operate!

Setting Up Your PictoBlox AI Project

Prerequisites

You’ll need the following things to make the tobi talking animation:

  • A laptop or a computer with a camera.
  • The latest version of PictoBlox, which you can download from here.
  • A good Internet connection.

Setting Up the Project

Let’s begin by setting up the project.

Step 1: Open PictoBlox 

Step 2: Add the Text-to-Speech Extension

Click the Add Extension button (the blue puzzle icon at the bottom left of the screen). Search for “Text to Speech” and add it to your project. This extension gives you access to AI-powered voice blocks including speak, set voice to, and more.

Step 3: Select the Tobi Sprite

Make sure you are working on the Tobi sprite. Tobi comes with two costumes pre-loaded in PictoBlox:

  • Tobi’s mouth is open (for when Tobi is speaking)
  • Tobi’s mouth closed (the default resting state)

This two-costume setup is the foundation of the AI lip-sync animation in Script 1.

Script 1: Building the AI Lip-Sync Animation 

This script is what makes Tobi’s mouth move in sync with speech  – a technique called lip-sync animation, commonly used in AI avatars, animated characters, and virtual assistants.

Understanding the Talking Variable (AI State Flag)

At the heart of this animation is a variable called Talking. Think of it as an “AI state flag” – a signal that tells the program whether the AI is currently speaking (value = 1) or silent (value = 0). This is a real concept used in AI systems to manage state and trigger actions.

Script 1 (Step-by-Step):

  1. Place a ‘when Green Flag clicked’ block from the Events palette — this starts the animation when the project runs.
  2. Add a ‘forever loop’ block from the Control palette. This loop keeps checking the Talking variable continuously, just like how a real AI system constantly monitors its state.
  3. Inside the forever loop, place an ‘if-then’ block. Make a variable talking. Set the condition to: Talking = 1 from Operatiors Palatte
  4. When ‘Talking’ equals 1, the AI is speaking. Add a ‘switch costume to Tobi block’ (Tobi) from the Looks palette. So Tobi’s mouth opens.
  5. Add a ‘wait 0.15 seconds’ block from the Control palette to make the animation visible.
  6. Then add the ‘switch costume to Tobi, mouth closed’ block to close the mouth.
  7. Add another ‘wait 0.15 seconds’ block. This 0.15-second toggle creates the appearance of natural lip movement — a simplified version of the phoneme-based lip-sync used in professional AI avatars.

Script 2: Coding the AI Dialogue & Personalized Response Flow

This is the main conversation script – the brain of our AI talking character. It controls what Tobi says, when it listens, and how it personalises its response using the user’s input.

Part A – Setting Up the Voice and Greeting

  1. Place a ‘when Green Flag clicked’ block from the Event palette.
  2. Add ‘set voice to tenor’ from the Text-to-Speech palette. The voice type (alto, tenor, squeak, etc.) is an AI model setting – it selects a different neural speech synthesis voice for Tobi.
  3. ‘Set Talking to 1’ block from the variable palette – this activates the mouth animation from Script 1.
  4. Add a ‘say’ block with: Hello! My name is Tobi.
  5. Add a ‘speak’ block from the Text to Speech palette with the same text – this triggers the AI Text-to-Speech engine to vocalise the words.
  6. Add a ‘say’ block with an empty space to clear the speech bubble after talking.
  7. ‘Set Talking to 0’ to stop the mouth animation between sentences.

Part B – Asking a Question and Collecting User Input

  1. Add ‘wait 0.5 seconds’ – a natural conversational pause, like how AI assistants pause briefly between sentences for a more human-like rhythm.
  2. Set Talking to 1’ from the variable palette again – Tobi is about to speak again.
  3. Add a ‘say’ block with ‘What’s your name?’
  4. Add a ‘speak’ block with ‘What’s your name?’
  5. ‘Set Talking to 0’ from the variable palette.
  6. Add an ‘ask [What’s your name?] and wait’ block from the Sensing palette. This pauses the program and waits for the user to type their response. The user’s input is stored in the built-in answer variable — this is how AI systems collect and store user data.

Part C — Generating a Personalized AI Response

  1. This is where the magic of AI-driven personalisation happens. We’ll use the join operator to dynamically build a custom response string using the user’s name:
  2. Add a ‘set message to’ block. In the value field, use ‘join’ [Hello] ‘join’ [answer] variable [Welcome to PictoBlox!]
  3. This creates a dynamic sentence like “Hello, Arjun! Welcome to PictoBlox” — personalised based on whatever name the user entered. This is the same concept behind AI personalisation used in apps and chatbots!
  4. Add Set Talking to 1.
  5. Create the new variable as ‘Message’ 
  6. Add the ‘say’ block and add the ‘Message block from the Variable palette inside the say block – Tobi displays the personalised message.
  7. Add ‘speak’ and add the ‘Message block from the Variable palette inside the speak block—Tobi speaks the personalised message aloud using the AI TTS.
  8. Add a ‘say’ block with an empty value to clear the bubble.
  9. Add ‘Set Talking to 0’.
  10. Add the ‘stop all’ block from the control palette to cleanly end the program.

Output

Click the Green Flag and watch Tobi speak with you.

Conclusion

In this AI and STEM project, we built a fully functional talking character in PictoBlox using the Text-to-Speech extension, variable-based state management, and block-based event-driven programming. We learnt how AI systems use speech synthesis to produce natural-sounding voices, how variables act as state flags to coordinate multiple processes, and how dynamic text generation creates personalised responses — the same principles that power real-world AI chatbots and virtual assistants.

This project is a perfect entry point for young learners exploring AI literacy, computational thinking, and human-computer interaction through hands-on STEM education. Whether you are building in a school coding lab, an Atal Tinkering Lab, or at home — the skills you have practiced here form the foundation of modern AI application development.

Read More
All articles loaded
No more articles to load