Halloween trick or treat automata with Voice Recognition module
This time I didn’t miss the deadline for unveiling a Halloween project. In this case, voice recognition, dfplayer mini and a servo motor are used to create a trick or treat automata.
Gravity Voice Recognition Module
Gravity Voice Recognition module is a small device by DFRobot that can be used to add voice recognition to any Arduino, ESP and Raspberry Pi project. Some interesting features of this module are:
. It works off line
. It comes with pre-trained commands
. It can learn new commands
. It can be easily trained
. Once it has been trained, a simple I2C or UART connection will give you the IDs of the commands
What can you do with this module? You can add it to any interface instead of wiring buttons and coding bouncing.
Functionality
When the button is pressed the device will start listening for “trick or threat” voice command.
After this point, the device will ask new questions and it will wait for answers. Some music and servo movements will be added to increase the dramatic effect.
Animated figure
This figure was made with clay. There is a SG90 servo inside. The head is a separate part to ensure movement.
Speech, sounds and movement
For the speech mp3 I have used https://elevenlabs.io/ Then I used Audacity to lower the voice pitch.
The audio files should be placed into the microSD
The code to play mp3 is:
void playSound(int myId){
delay(500);
execute_CMD(0x0F,0x01,(byte)myId);
delay(500);
}
Movement is easily obtained by sending angles to the servo motor.
void right(){
myServo.write(160);
}
Teaching commands to the module
The voice recognition module should be trained for new commands, since Yes/No, Trick or treat, etc are not included by default.
Power up the module with 5v and say: “Hello robot” Then say “Learning command word” Now follow the instructions and repeat 3 times the following words:
Kid
Adult
Yes
No
Trick or treat
They will get assigned IDs from 5 to 9 and we will use those IDs from the code.
Note: if you have uploaded the .ino code please consider that mute mode has been enabled. You can disable with:
DF2301Q.setMuteMode(0);
Forcing wake up word
The Voice Recognition module, by default requires a wake up phrase like “Hello, robot”
By giving that command through the code with
DF2301Q.playByCMDID(1);
The device will be at command mode with the front blue light turned on.
Circuit
Connect DFPlayer Mini TX and RX to Arduino Nano pins 10 and 11. DFPlayer Mini GND and VCC to the external 5v Power. DFPlayer Mini SPK+ and SPK- to Speaker pins.
Connect the servo motor signal to pin 12. Servo motor GND and VCC to external 5v Power
Connect Led Button to pin 7 and GND.
Connect Voice module to A4 and A5. GND and VCC to external 5v Power.
3d Parts
If you want to use the same 3d printed box I did use, download all 3d parts from https://cults3d.com/en/3d-model/game/halloween-voice-recognition-trick-or-treat and print with PLA
Other projects
Interested in other projects using DFRobot parts?