You are on page 1of 6

Lesson 4 AI

Use AI to recognize age, speech, text, and emotions.


Program the number keys (1 to 5) to trigger different AI features:
Press 1 to recognize age;
Press 2 to recognize speech in English;
Press 3 to recognize speech in Chinese;
Press 4 to recognize text in English,
Press 5 to recognize emotions.

Note: In mBlock 5, the speech and text recognition functionalities provide 6


language options: Chinese, English, French, German, Italian and Spanish. In
the following activities, English and Chinese are selected only as examples.

1. Programming flow charts for the AI features mentioned

above.
Sprite
when key "2" pressed
when key "1" pressed

recognize age and display recognize speech in English and


age recognition result display speech recognition result

True when key "3" pressed


age<20?

False
recognize speech in Chinese and
play laugh sound
display speech recognition result

end
when key "4" pressed

recognize text in English and


display text recognition result

when key "5" pressed

recognize emotion and


display happiness value

True emotion is False


happiness?

for the 11th time go to stage center


glide to random position

repeat 10 times

end

2. Age Recognition
One second after the key "1" is pressed, the panda will detect age, and show
the recognition result. If the result is less than 20 years old, the panda will play
a sound.

Press 1 and wait for 1 second.


Then the panda will detect
your faces and recognize age.

If the age recognition result is


under 20, the panda will play a
laugh sound.
Look straight at the
camera.

TIPS: How to add a sound effect

Click Sounds Click Add Sound


Select the sound effect
you want, then click OK

Select the effect you


want under the drop-
down menu in the start
sound () block.

3. Speech and Text Recognition


When the key "2" is pressed, the panda will recognize speech in English and
display the speech recognition result.

When the key "3" is pressed, the panda will recognize speech in Chinese and
display the speech recognition result.
When the key "4" is pressed, the panda will recognize the printed text in English,
and display the text recognition result.

Press the key "2", turn on the microphone,


and keep speaking English for 2 seconds.
Then the panda will recognize your
speech and display what you've said.
Keep speaking
English for 2 seconds

Press the key "3", turn on the microphone,


and keep speaking Chinese for 2
seconds. Then the panda will recognize
your speech and display what you've said.
Keep speaking
Chinese for 2 seconds

Note: What’s shown by the panda means " It’s a nice day.".

Press 4 and put some English text in front


of the camera. Then the panda will
recognize the text and display the
recognition result.

AI Artificial Intelligence
4. Emotion Recognition

One second after the key "5" is pressed, the panda will recognize your emotion
and display the emotion value. If the emotion is detected as happiness, the
panda will glide to a random position, repeat gliding 10 times and then move
back to the center of the stage.

Press 5, smile at the camera, and wait for 1 second.


Then the panda will recognize your emotion and display
your emotion value (ranging between 0 to 100).

This block runs the blocks inside it if


your emotion is detected as happiness.

This line makes the panda glide to a


random position and the repeat ()
block makes the line repeat 10 times.
This block makes the panda
move back to the center.

Smile at the camera.

You might also like