Table of Contents

answer

Description

The block holds the most recent text imputed with the Ask () and Wait block. When nothing has been inputted yet, the value will hold nothing.

Example

The example demonstrates how to use a repeat block to recite a table in PictoBlox.

Sprite

Output

Read More
The Language Translator with ChatGPT is a powerful system that enables real-time translation and conversation support, facilitating multilingual communication.

Introduction

The Language Translator with ChatGPT and Speech Recognition is a system that helps people communicate across languages by providing real-time translation and conversation support. It combines language translation, chatbot capabilities, and speech recognition to facilitate multilingual communication.

Language Translator Using ChatGPT is a project that trains the ChatGPT language model with multilingual data to enable it to understand and translate text between different languages. It utilizes ChatGPT’s natural language processing abilities to generate human-like responses, making it ideal for building a language translation system. The training data includes sentence pairs in different languages and their corresponding translations.

Logic

Initially, two characters engage in a conversation. One character asks a question, and the other character converts it into a different language before answering it and providing a response.

  1. Open PictoBlox and create a new file.
  2. Select the environment as appropriate Block Coding Environment.
  3. To add the ChatGPT extension, click on the extension button located as shown in the image. This will enable the ChatGPT extension, allowing you to incorporate its capabilities into your project.
  4. To begin, select two sprites Hazel and John from the sprite options in the bottom left corner, as shown in the image.
  5. To upload a backdrop, use the “Choose Backdrop” option, which allows you to select and set a background image or scene for your activity. Backdrops are used as the type of background in our activity.
  6. To create a script, select a different sprite and then add various block scripts to customize its behavior.
  7. Let’s use the sprites Hazel and Joan for our script.
  8. For Hazel, navigate to the costumes section and enable the “Flip Horizontal” option to add a mirror effect. Set the positions of both sprites as if they are talking to each other.
  9. Click on John’s Sprite first. We will now begin writing a script as shown in the image.
  10. First, we will prompt the user to input a sentence. and using the say() method, the sprite will verbally repeat the same answer provided by the user.
  11. Next, by using the broadcast() block, we can send the translated answer to the second sprite to ensure that both sprites have the same response.
  12. select the second Hazel’s sprite and begin with the when I receive a () block. This block will initiate the action when the second sprite receives a message from the first sprite.
  13. Drag and drop the “translate() into()” function into the block. This block will translate any language of your choice. In this example, we are writing in Hindi language.
  14. We utilize the get AI Response block to obtain a response from ChatGPT. Then, using the say() method, Hazel, the sprite, will deliver the answer in translated sentences.
  15. To begin the script, simply click on the green flag button.

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
The example shows how to use a number classifier in PictoBlox to make the Iris Classifier Bot.

Script

The idea is simple, we’ll add one image of  each class in the “costume” column by making one new sprite which will we display on the stage according to input from user. we’ll also change name of the image according to iris type.

  1. Add iris image as another sprite and upload one image of all iris classes on costume.
  2. Now, come back to the coding tab and select the Tobi sprite.
  3. We’ll start by adding a when flag clicked block from the Events palette.
  4. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  5. Add the “set () as ()” block from the Machine Learning palette. Select the SepalLengthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  6. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  7. Add the “set () as ()” block from the Machine Learning palette. Select the SepalWidthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  8. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  9. Add the “set () as ()” block from the Machine Learning palette. Select the PetalLengthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  10. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  11. Add the “set () as ()” block from the Machine Learning palette. Select the PetalWidthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  12. Add an “analyse numbers” block from the Machine Learning palette.
  13. Add the “if () then” block from the control palette for checking the user’s input.
  14. In the empty place of the “if () then” block, add an “is identified class ()” block from the Machine Learning palette. Select the appropriate class from the options.
  15. Inside the “if () then” block, add an “say ()” block from the Looks palette block. Write an appropriate statement in an empty place.
  16. Inside the “if () then” block, add a “broadcast ()” block from the Events palette block. Select the “New message” option and write an appropriate statement for broadcasting a message to another sprite.
  17. Repeat “if () then” block code for other iris classes, make appropriate changes in copying block code according to other classes, and add code just below it.
  18. Final code of “Tobi” sprite is
  19. Now click on another sprite and write code.
  20. We’ll start writing code for this sprite by adding a when flag is clicked block from the Events palette.
  21. Add the “hide” block from the Looks pallet.
  22. Write a new code in the same sprite according to class and add the “when I receive ()” block from the Events palette. Select the appropriate class from the options.
  23. Add the “show” block from the Looks pallet.
  24. Add the “switch costume to ()” block from the Looks palette. Select the appropriate class from the options.
  25. Repeat the same code for other classes and make changes according to the class.

    Final Result

Read More
The example shows how to use a number classifier in PictoBlox to make the customer spending money classifier bot.

Introduction

In this example project, we are going to create a Machine Learning Model that can predict the amount of money a customer will spend based on the input details added by the user.

Numbers(C/R) in Machine Learning Environment

Datasets on the internet are hardly ever fit to directly train on. Programmers often have to take care of unnecessary columns, text data, target columns, correlations, etc. Thankfully, PictoBlox’s ML Environment is packed with features to help us pre-process the data as per our liking.

Let’s create the ML model.

Opening Image Classifier Workflow

Alert: The Machine Learning Environment for model creation is available in the only desktop version of PictoBlox for Windows, macOS, or Linux. It is not available in Web, Android, and iOS versions.

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. Select the coding environment as Block Coding Environment.
  3. Select the “Open ML Environment” option under the “Files” tab to access the ML Environment.
  4. You’ll be greeted with the following screen.
    Click on “Create New Project“.
  5. You shall see the Numbers C/R workflow with an option to either “Upload Dataset” or “Create Dataset”.

    Uploading/Creating Dataset

    Datasets can either be uploaded or created on the ML Environment. Lets see how it is done.

    Uploading a dataset
    1. To upload a dataset, click on the Upload Dataset button and the Choose CSV from your files button.
      Note: An uploaded dataset must be a “.csv” file.
    2. Once uploaded the first 50 rows of the uploaded CSV document will show up in the window.
    Creating a Dataset
    1. To create a dataset, click on the Create Dataset button.
    2. Select the number of rows and columns that are to be added and click on the Create button. More rows and columns can be added as and when needed.

    Notes:

    1. Each column represents a feature. These are the values used by the model to train itself.
    2. The “Output” column contains the target values. These are the values that we expect the model to return when features are passed.
    3. The window only shows the first 50 rows of the dataset.
    4. Un-check the “Select All” checkbox to un-select all the columns.

    Training the Model

    After data is pre-processed and optimized, it’s fit to be used in model training. To train the model, simply click the “Train Model” button found in the “Training” panel.

    By training the model, meaningful information is extracted from the numbers, and that in turn updates the weights. Once these weights are saved, the model can be used to make predictions on data previously unseen.

    The model’s function is to use the input data and predict the output. The target column must always contain numbers.

    However, before training the model, there are a few hyperparameters that need to be understood. Click on the “Advanced” tab to view them.

    There are three hyperparameters that can be altered in the Numbers(C/R) Extension:

    1. Epochs– The total number of times the data will be fed through the training model. Therefore, in 10 epochs, the dataset will be fed through the training model 10 times. Increasing the number of epochs can often lead to better performance.
    2. Batch Size– The size of the set of samples that will be used in one step. For example, if there are 160 data samples in the dataset, and the batch size is set to 16, each epoch will be completed in 160/16=10 steps. This hyperparameter rarely needs any altering.
    3. Learning Rate– It dictates the speed at which the model updates the weights after iterating through a step. Even small changes in this parameter can have a huge impact on the model performance. The usual range lies between 0.001 and 0.0001.
    Note: Hover the mouse pointer over the question mark next to the hyperparameters to see their description.

    It’s a good idea to train a numeric classification model for a high number of epochs. The model can be trained in both JavaScript and Python. In order to choose between the two, click on the switch on top of the Training panel.

    Alert: Dependencies must be downloaded to train the model in Python, JavaScript will be chosen by default.

    The accuracy of the model should increase over time. The x-axis of the graph shows the epochs, and the y-axis represents the accuracy at the corresponding epoch.

    A window will open. Type in a project name of your choice and select the “Numbers(C/R)” extension. Click the “Create Project” button to open the Numbers(C/R) window.

    Testing the Model

    To test the model, simply enter the input values in the “Testing” panel and click on the “Predict” button.

    The model will return the probability of the input belonging to the classes.

Export in Block Coding

Click on the “Export Model” button on the top right of the Testing box, and PictoBlox will load your model into the Block Coding Environment if you have opened the ML Environment in the Block Coding.

Script

  1. Select the “Tobi” sprite.
  2. We’ll start by adding a when flag clicked” block from the Events palette.
  3. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  4. Add the “if () then” block from the control palette for checking the user’s input.
  5. In the empty place of the “if () then” block, add an “()=()” block from the Operator palette. At the first empty place select an “answer” block from the Sensing palette and for the second place write an appropriate statement in an empty place.
  6. Add the “set gender as ()” block from the Machine Learning palette. Select the Male option at the empty place.
  7. Repeat “if () then” block code for other variables, make appropriate changes in copying block code according to other variables, and add code just below it.
  8. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  9. Add the “if () then” block from the control palette for checking the user’s input.
  10. In the empty place of the “if () then” block, add an “()=()” block from the Operator palette. At the first empty place select an “answer” block from the Sensing palette and for the second place write an appropriate statement in an empty place.
  11. Add the “set education as ()” block from the Machine Learning palette. Select the High School option at the empty place.
  12. Repeat “if () then” block code for other variables, make appropriate changes in copying block code according to other variables, and add code
  13. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  14. Add the “set () as ()” block from the Machine Learning palette. Select the age option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  15. Repeat “ask () and wait” block code for other variables, make appropriate changes in copying block code according to other variables, and add code.
  16. Repeat “ask () and wait” block code for other variables, make appropriate changes in copying block code according to other variables, and add code.
  17. Add the “say ()” block from the Looks palette.
  18. Add an “join () ()” block from the Operator palette. Write an appropriate statement in an first empty place and at second empty place add “analyse numbers” block from the Machine Learning palette. 

    Final Result

Read More
All articles loaded
No more articles to load