Cognitive Services Extension

The Cognitive Services API adds more features to your sprites, so you can enjoy more fun with stage programming.

Add Cognitive Services Blocks

1) Make sure "Sprites" is selected and click "+" in the Blocks Area.

2) From the pop-up Extension Center page, click "+" to add Cognitive Services blocks.

3) Go back to Edit Page. You can find AI category is added to the block palette.

Have Some Fun

Let's try out the new AI blocks and do some fun stuff. We will create a new project to have the Panda recognize your happiness value.

1) Drag a when green flag clicked block from the Events category to the Scripts area, and add a AI block recognize emotion in () seconds. So, when you click the green flag, the Panda will recognize your emotion in 2 seconds.

2) Our goal is to have the Panda recognize your happiness value, and have some corresponding reaction. Let's add a if () then () block onto the existing blocks. We have to determine the threshold of happiness first, so we need to add a () > () block from the Controls category into the if condition. By adding the AI block happiness value and number 10, we determine that a happiness value of 10 and above represents a happy emotion.

3) When the Panda recognizes your happiness value as above 10, we want it to say something to you, like "You are happy!". We can add a say () block from the Looks category, which is wrapped up by the if () then () block.

4) Now we can run the script. Click the green flag under the stage, and the Recognition Window will pop up. After a 2-second countdown, the happiness value will be displayed on the stage. The value of 53 represents a happy emotion, so the Panda says "You are happy!".

results matching ""

    No results matching ""