Python Based Speech Recognition Controlled Mecanum

Example Description
Learn how to code logic for speech recognized control of Mecanum with this example block code. You will be able to direct your own Mecanum easily by just speaking commands.

Learn how to code logic for speech recognized control of Mecanum with this example block code. You will be able to direct your own Mecanum easily by just speaking commands.

Introduction

A speech recognized controlled Mecanum robot is a robot that can recognize and interpret our speech, verbal commands, given by a human. The code uses the speech recognition model that will be able to record and analyze your speech given and react accordingly on the Mecanum.

Speech recognition robots can be used in manufacturing and other industrial settings to control machinery, perform quality control checks, and monitor equipment.

They are also used to help patients with disabilities to communicate with their caregivers, or to provide medication reminders and other health-related information.

Code

sprite=Sprite('Tobi')
import time
meca=Mecanum(1,2,7,8)
quarky = Quarky()
sr = SpeechRecognition()
ts = TexttoSpeech()
sr.analysespeech(4, "en-US")
command = sr.speechresult()
command = command.lower()
if 'forward' in command:
  meca.runtimedrobot("forward",100,2)
elif 'back' in command:
  meca.runtimedrobot("backward",100,2)
elif 'right' in command:
  meca.runtimedrobot("lateral right",100,2)
elif 'left' in command:
  meca.runtimedrobot("lateral left",100,2)

time.sleep(10)
sprite.stopallsounds()

Logic

  1. Firstly, the code initializes the Mecanum pins and starts recording the microphone of the device to store the audio command of the user.
  2. The code then checks conditions whether the command included the word “Go” or not. You can use customized commands and test for different conditions on your own.
  3. If the first condition stands false, the code again checks for different keywords that are included in the command.
  4. When any condition stands true, the robot will align itself accordingly and move in that direction of the respective command.

Output

Table of Contents