 Hello everyone! Welcome back to our channel. I hope you all are safe and sound. In some of our previous projects, we have used smartphones to control our home appliances via either text commands or voice commands. In this video, we will make a project in VictorBlocks to control the appliances using speech recognition technology, one of the many cool applications of artificial intelligence. We will make a small setup of bedroom in VictorBlocks and control the appliance sprite using the voice commands. Hello, I am your AI assistant. What do you want me to do today? Turn the lights on. Switching on the lights. Pre-requisites are a laptop or a computer with latest version of VictorBlocks downloaded, a camera and a good internet connection. You can download the all-new VictorBlocks from the link given in the description box below. Let's begin by adding the artificial intelligence extension. Click on the board button and select if I from the list. While working with the AI and MN extensions, you need to keep two things in mind. First, you need to sign in or log in into VictorBlocks account from here. Your computer needs to be connected to the internet. Now click on the add extension button and select the artificial intelligence extension from the list. We'll even make our AI assistant speak up. Thus, we'll add the text to speech extension from the extension library. Now before writing the script, we will set up the scene of the room in VictorBlocks. We have already added up a few sprites and have set up the background. Simply download the SB3 file from the link given in the description box below. Once you have downloaded the file and have opened it in VictorBlocks, we will now start writing the script for each and every sprite. We will be controlling three sprites. First, fan, second lamp and third, the radio. Abby will be our virtual AI assistant. Let's first write the script for Abby. We'll make Abby ask the user what does the user want to do and then perform the actions accordingly. To execute the program as soon as the green flag is clicked, place when flag clicked HUD block from the events palette. As you can see that the Abby is standing in the center of the stage. Let's shift her to the right hand side of the stage. Thus use go to XY block from the motion palette and write 197 in X and minus 73 in the Y. Now let's set the size of HUD to 80% of the original. Thus use the set size to block from the looks palette and write 80 in the space given. We will make Abby speak thus let's give her the voice. Place set voice to block from the text to speech extension and choose L2 from the drop down. Let's first introduce Abby to users. Thus drag and drop C block from the looks palette and write hello I am Abby your AI assistant. To make her say the text place a speak block and copy the above sentence into the white space given. Now place a forever block to run the script continuously. We need Abby to ask the user what do they need to do to placate these blocks and write what do you want me to do today in both the space given. We first need to recognize the speech from the user. Thus from the artificial intelligence palette drag and drop the recognize speech for block and choose five from the first drop down to keep how long do we recognize speech from the user. Now the speech is recognized but is not stored in the block. It is stored in the speech recognition result block. Now we'll match the speech from the user to the text we have added. Thus place an effects block from the controls palette. Now to compare the recognized speech and the command place a contain operator block from the operator's palette. This block is used to check whether the user has spoken the phrase written in the space or not. Place the speech recognition result in the first input. We will first turn the lights on. Thus write lights on in the second space of the contain block. As soon as the lights on speech is recognized we will make Abby say switching on the lights. Thus place the say and the speak block below the if arm. To turn on the light we will make a broadcast block and write new message as lights on. Now we want to turn the light off. Thus duplicate the if else block and place it into the else arm. Replace all the ons with the ops. Now we will make our fan turn on and off. Thus duplicate the above nested if else arm and place it into the else arm. Into the duplicated else arm replace all the light word with fan. Again to turn the radio on and off we will duplicate the last two if else arms and place it into the else arm. Replace fan with radio. Now if the commands by the user does not match any of the above commands we need Abby to say sorry didn't get you please try again. Thus play the say and the speak blocks for the same. Now the script for Abby is done. Let's try the script to make each and every appliance work as soon as the command is given. Let's first see what to do with the lamp light sprite. Click on the lamp sprite. We will first initialize the looks and the position of the lamp sprite as soon as the green flag is clicked. Thus place a wind flag click hat block. From the looks palette use the set size to block and set its size to 50 percent. Add switch the costume to block and choose lamp light animation from the drop down. Now to set the initial position use the go to XY block from the motion palette and write minus 27 in X and 28 in Y. Now we need the lamp to light up as soon as we command lights on. Thus place a when I receive broadcast block and choose lights on from the drop down. Place switch costume to block from the looks palette and choose lamp light animation to from the drop down. This will glow up the lampshade. Now we even want the room to lighten up as soon as the lights are on. Thus go to the backdrop. Let's first initially set the brightness of the room. Thus place a when flag click hat block. From the looks palette using the set brightness effect to block set it to minus 10. Now to lighten up the room place a when I receive a broadcast block and choose lights on from the drop down. Using the set brightness effect to block set the brightness to 20. Now let's go back to the lamp sprite to write script for what happens when we turn the lamp off. Duplicate these blocks and choose lights off from the first drop down and lamp light animation from the second drop down. Finally we need to turn the room dark as soon as we command lights off. Thus let's go to backdrop and duplicate this block. Choose lights off from the first drop down and write minus 10 in the space here. With this our script for the lamp is complete. Let's move on to make the fan rotate. Go to the fence sprite. We will first initialize the looks and the position of the fence sprite as soon as the flag is clicked. Thus place a when flag clicked hat block. From the looks palette using the set size to block set its size to 70%. The switch costume to block and choose fan from the drop down. Now to set the initial position use go to XY block from the motion palette and write 66 in X and 141 in the Y. Now we need the lamp to light up as soon as we command fan on. Thus place a when I receive broadcast block and choose fan on from the drop down. Now we want the fan to rotate as still we command it to stop. Thus place a repeat until block from the controls palette. Drag and drop and equal to block inside it. Place speech recognition result in the first input and write fan off in the second. To make fan look like it is rotating we will switch its costume one after another. Place a next costume block from the looks palette and add a weight of 0.001 seconds. Now let's write script to stop the fan. Duplicate the above block and choose fan off from the drop down and remove all the blocks. Now place a switch costume to block below the hat block and stop the rotation of the fan. With this the script to control the fan is complete. Finally let's write the script to turn the radio on and off. Go to the radius sprite. Similar to the fan and the lamp sprite we will first initialize its look and the position. Thus place a when flag clicked hat block from the looks palette using the set size to block set its size to 70% and switch the costume to radio A. Now to set initial position use the go to XY block from the motion palette and write minus 163 in X and minus 78 in Y. We want the radio to play spiderman song or the song of your choice. Thus place a when I receive broadcast hat block and choose radio on from the drop down. Now we want the music to stop as soon as we command it to stop. Thus place a repeat until block from the controls palette. Drag and drop an equal to block inside it. Place speech recognition result in the first input and write radio off in the second. To add the spiderman song go to the sound tab. From the sound library choose the spiderman song. From the sound palette drag and drop the play sound until done and choose spiderman song from the drop down. Now we need to change the costume of the radio to make it look like it is playing. Duplicate this block and remove the play sound block. Place next costume block from the looks palette and to make it look like it is changing place the wait block of 0.1 seconds. With this your script is ready. Hello, I am your AI assistant. What do you want me to do today? Turn the lights on. Switching on the lights. What do you want me to do today? Turn the fan on. Switching on the fan. What do you want me to do today? Turn the radio on. Switching on the radio. What do you want me to do today? Switching off the lights. What do you want me to do? Using the similar concept you can control actual appliances using picture blocks. Don't forget to share it with us in our picture blocks community on Facebook. Also, if you like this video, give it a thumbs up and subscribe to Follow us on Facebook, Instagram and Twitter. Bye bye, stay safe.