Students gain a basic understanding of artificial intelligence (AI) technology, along with its use in everyday life. AI is all around us and has both positive and negative aspects. It is more prevalent in our day-to-day lives than we think. Students explore aspects of AI and develop their own simple AI programs. Then, they connect their newfound knowledge to real-world examples.
Note: This lesson is for experienced users of Scratch 3.0 and contains advanced concepts.
- Understand the uses of AI
- Understand why AI is becoming relevant in our lives
- Create a simple speech recognition project in Scratch 3.0
- Artificial Intelligence (AI) – A technological system displaying attributes of intelligence typically possessed by humans.
Ontario (Grades 4-6)
- A2. Coding and Emerging Technologies
- A2.1: write and execute code in investigations and when modelling concepts, with a focus on producing different types of output for a variety of purposes
- A2.2: identify and describe impacts of coding and emerging technologies on everyday life, including skilled trades
- A3. Applications, Connections, and Contributions
- A3.1: describe practical applications of science and technology concepts in various occupations, including skilled trades, and how these applications address real-world problems
- A3.2: investigate how science and technology can be used with other subject areas to address real-world problems
Task 1—Introduction to AI
Go over the core concepts below orally to build a rudimentary understanding of AI.
What is AI?
AI is an acronym that stands for artificial intelligence. A technological system is considered to be artificial when it displays attributes of intelligence that living beings typically exhibit. This includes processing language, understanding pictures, detecting patterns, and more. In the past years, as technology continues to advance, the use of AI has become more relevant to and useful in our daily lives.
Why is AI important?
AI is all around us! Do you have Alexa or Google Home? Those devices use AI. They can recognize your voice and perform commands when you speak to them. They can even talk back to you. Today, there are self-driving cars, face recognition software, and more. What do all these things have in common? They all were programmed to learn. That’s right! Somebody programmed a computer to be intelligent.
Task 2—Alien Language
Let’s learn how to tell the computer what to do by using only our voice. In this activity, we will teach the computer to move a sprite (character) left or right using new words we will invent.
Step 1: Go to the Machine Learning For Kids Website. This will open the scratch program in your browser.
Step 2: In the bottom left-hand corner, locate the Add extensions button, and choose the Speech to Text extension from the dropdown list.
Step 3: Using the events, motion, and speech-to-text blocks, copy the script below. This tells the computer that when the program starts, it needs to listen and wait for certain commands that we will speak into the microphone.
Step 4: Click on the green flag and choose to say left or right into the mic. The sprite should move in the specified direction. Remember to speak clearly so the computer can understand.
Training Your Own Model: Alien Words
The pretrained model used in part one knew all the words in the dictionary. Now, we are going to create alien words that are made up and not in the dictionary. We are going to get the computer to recognize these words, and complete an action when hearing it.
Follow the instructions below:
- Go to the Machine Learning For Kids website. Click Get Started then click Try it now. From the projects bar, click on Add New Project and name the project Alien Sounds. Set the description to speech recognition
- Create two new words that will represent the words right and left. Make up any words/sounds you like. Make sure to remember them and repeat them back the same way each time you record them. The words have to be different from each other—don’t make them too similar. The new project you created will appear in the project list. Click on the Train button to train the model.
- Click on Add example in the background noise box. This will record the noise in the background around you. This will help the computer to differentiate between background noise and spoken words.
- Click on the microphone button to record two seconds of background noise, then click add. Do this at least eight times so the computer has enough information to process what the background noise around you sounds like.
- Click on the Add new label button at the top right corner of the screen and label it Left. Now in the Left box, click on Add example and record your alien word that means left that you invented in Step 2. Do this at least eight times. Make sure to speak clearly.
- Add another label for Right and repeat Step 5, using the word you invented to indicate right.
- Train the computer to recognize your alien words. In the top left corner, click Back to the project then click Learn and test. Click on Train new machine learning model. This may take a few seconds.
- Once the training is completed, click Start listening to test the project. It will give a confidence score. If learners want to reach a 70% threshold in their confidence score for enhanced accuracy, they can record longer audio samples.
- Once the desired confidence score is reached, click Make then Scratch 3. This will connect the project with Scratch 3.0 and it will take learners to the Scratch interface.
- In the top menu bar, click on Project templates and search or scroll for your Alien Language template.
- Launch the project. A set of scripts will appear on the screen— do not delete them! These scripts tell the sprite how to move. Update the scripts so that they look like the the scripts shown below.
- Now it’s time to test the model to check if the sprite obeys the commands. Click on the green flag on the right side of the screen and speak your alien words into the mic. The sprite should follow the commands and go in the direction you tell it to move.
At the end of the lesson, learners will be well-versed in how AI can use voice recognition and in training machines to follow voice commands. Ask students:
- What are examples of systems that understand voice commands?
- How does voice-assisted technology help us in day-to-day life?
- What are some struggles or problems we might encounter with these types of systems?
- What are some of the positive and negative aspects of voice-generated AI?
- The Raspberry Pi Foundation has lots of fun coding and AI resources to explore
- Speech recognition may seem like a lot of fun, and very useful, but we should also be mindful when using AI tools.
- Natural Language Processing and Artificial Intelligence