Move a servo with speech recognition (Blockly)

This tutorial is mainly focused on speech recognition. Making the servo move is an example of adding user-defined phrases to the speech recognition robot skill. While there are many speech recognition robot skills available in ARC, we will be using the default Speech Recognition robot skill. This tutorial will add the speech recognition robot skill and configure it to move the servo in a few positions.

*Note: While a built-in computer microphone will work, it is recommended to use a handheld, headset, or dedicated microphone that doesn't pick up ambient sound. The speech recognition system works best when it only hears your voice. Other speech recognition robot skills, such as the Bing Speech Recognition, have higher quality recognition and can successfully detect speech in a noisy environment. The speech recognition robot skill in this tutorial is not as accurate, and therefore we recommend the dedicated microphone.


Requirements

  • Connected to an EZB
  • Servo connected to the EZB
  • Computer with a soundcard and microphone


Robot Skills Used

The following robot skills are used in this tutorial. Click any of these to further read the manuals for the robot skills.



Let's Do It

Add the Speech Recognition robot skill. Do this by pressing the Project -> Add Robot Skill from the top menu.



When the Add Robot Skill window opens, select the Audio tab and click the Speech Recognition robot skill. This will add the robot skill to the project.



Now that the robot skill is added to your project press the configuration button on the speech recognition robot skill. This will open the configuration window for the skill.



In the configuration window, there will be several default phrases with code. These default phrases are bound to movements to control a movement panel. We'll be adding two of our phrases to recognize.



Enter the phrase "Move Servo Left" in the first available empty phrase.



Press the Command button next to the new phrase to open the script window.



Select the Blockly tab. Specify the following block as in the image. The servo position block is found in Movement, and the number for the position is found under Math. Substitute port D0 with the port of your servo. Also, if you are aware that position 1 extends the limits of your robot servo, use a safe position value. Press the SAVE button



Enter the phrase "Move Servo Right" in the first available empty phrase.



Press the Command button next to the new phrase to open the script window.



Select the Blockly tab. Specify the following block as in the image. The servo position block is found in Movement, and the number for the position is found under Math. Substitute port D0 with the port of your servo. Also, if you are aware that position 180 extends the limits of your robot servo, use a safe position value. Press the SAVE button.



Press SAVE on the speech recognition configuration window



Speak the commands "Move Servo Left" and "Move Servo Right". Notice the servo moving.





More Stuff

There are other robot skills to explore for speech recognition. The recommended robot skill for the highest quality is the Bing Speech Recognition robot skill. The configuration of this robot skill is similar to this tutorial. One of the advantages of the Bing Speech Recognition robot skill is that it will translate any speech, not only the defined phrases. You can feed the output to a chatbot to give your robot conversational capabilities by detecting any speech.

  • Bing Speech Recognition robot skill
    The recommended robot skill provides higher quality detection and more capabilities for customization.

  • Artificial Intelligence robot skills
    This category of robot skills contains several chatbots that give the robot conversational capabilities.

  • Robot Chat Video Example
    This video is an example of combining Bing Speech recognition with a chatbot, camera, and cognitive services.

  • ControlCommand() manual
    When you're ready to have speech recognition send commands to other robot skills, this manual is required reading. The ControlCommand is a programming command that simulates pressing a button on another robot skill. For example, you'd use this command in a detected phrase to enable camera motion tracking or use this command in speech recognition to trigger an Auto Position action.