Welcome to DOFBOT SE repository
1.Simple Voice Control
Simple Voice Control
1. Function Description
Control RGB lights, buzzers, and robotic arm through the voice recognition and broadcast module.
2. Startup and Operation
2.1 Startup
Open the terminal and enter the following command to start:
xxxxxxxxxxpython3 ~/dofbot_voice/scripts/simple_voice_ctrl.py2.2 Operation Steps
After the program runs, the voice module will broadcast "I'm here", then say "Hi, yahboom" to the voice module. The voice module replies "I'm here" indicating successful wake-up. Then say "Turn on the red light" to the voice module. At this time, the LED light on the driver board will light up red, and the voice module will broadcast "OK, red light is on". The voice commands that this program can recognize are as follows:
| Voice Command | Effect |
|---|---|
| RED-LIGHT-UP | LED light on driver board lights up red |
| GREEN-LIGHT-UP | LED light on driver board lights up green |
| BLUE-LIGHT-UP | LED light on driver board lights up blue |
| WARNING | Buzzer beeps 3 times |
| LIFT-THE-ARM-UP | Robotic arm extends upward |
| PUT-THE-ARM-DOWN | Robotic arm extends downward |
| ARM-LEFT | Robotic arm turns left |
| ARM-RIGHT | Robotic arm turns right |
| CLAMP-THE-DIP | Gripper tightens |
| OPEN-THE-DIP | Gripper releases |
3. Core Code Analysis
Source code path:
xxxxxxxxxx~/dofbot_voice/scripts/simple_voice_ctrl.py
simple_voice_ctrl.py
x# Import robotic arm low-level control libraryimport Arm_Lib# Import voice recognition and broadcast libraryfrom Speech_Lib import Speech# Create voice recognition and broadcast object mySpeechmySpeech = Speech()# Create robotic arm low-level control object ArmArm = Arm_Lib.Arm_Device()# Call speech_read function to get voice recognition resultresult = mySpeech.speech_read()# Call Arm_RGB_set function to control LED light to turn redArm.Arm_RGB_set(50, 0, 0)# Call Arm_Buzzer_On function, pass parameter 1, control buzzer to beep for 100 millisecondsArm.Arm_Buzzer_On(1)# Call Arm_serial_servo_write function, pass parameters, control servo 2 to rotate to 90 degrees within 1000 millisecondsArm.Arm_serial_servo_write(2, 90, 1000)# Call void_write function, pass parameter 11, broadcast corresponding audio filemySpeech.void_write(11)