Table of Contents
Example Description
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