This DFRobot voice recognition module is built around an offline voice recognition chip, which can be directly used without an internet connection. It comes with 121 built-in fixed command words and supports the addition of 17 custom command words. Any sound could be trained as a command, such as whistling, snapping, or even cat meows, which brings great flexibility to interactive audio projects.
The module features a dual microphone design with better noise resistance and longer recognition distance, making it relatively accurate and reliable even in noisy environments. It comes with a built-in speaker and an external speaker interface for real-time voice feedback of recognition results. The module uses both I2C and UART communication methods and supports various 3.3V or 5V controllers, including Arduino UNO, Arduino Leonardo, Arduino MEGA, FireBeetle series, and more.This voice recognition module provides a reliable and flexible voice interaction solution for makers and electronics enthusiasts, and can be applied to any applications where voice control or interaction is desirable, such as all kinds of smart home appliances, toys, lamps, and robotics projects.
What is voice recognition?
Voice recognition is a computer technology that recognizes and converts speech signals into editable text or operational commands through analysis. It allows people to interact with computers by speaking without using a mouse, keyboard, or other input devices. Voice recognition technology has been widely used in applications such as voice assistants, smart homes, voice search, and voice recognition notebooks.
Features
- Self-learning function: Control the module to learn command words by the voice, and any audio can be used as a command.
- I2C and UART, with a Gravity interface
- Compatible with 3.3V/5V
- Built-in with 121 commonly used fixed command words
- The module has a built-in speaker and an interface for an external speaker, which can provide real-time voice feedback on recognition results
- Equipped with power indicator (red) and recognition status indicator (blue)
- Dual microphones provide better noise resistance and longer recognition distance
- Compatible with Arduino controllers: Arduino UNO, Arduino Leonardo, Arduino MEGA, FireBeetle series controllers, Raspberry Pi, ESP32
Specification
- Operating voltage: 3.3 - 5V
- Maximum operating current: ≤370 mA (5V)
- Communication method: I2C/UART
- I2C address: 0x64
- Fixed command words: 121
- Fixed wake-up words: 1
- User-defined command words: 17
- Learning wake-up words: 1
- Onboard microphone sensitivity: -28db
- Module size: 49 * 32 mm
Board Overview
Command Words
Wake-up word
Wake-up word refers to the word that switches a product from standby mode to working mode, which is the first point of contact between users and voice interactive products.
Learning wake-up word:
First, wake up the voice assistant with the default wake word, then say "Hello robot" and follow the prompts to learn the wake word (before learning a new wake word, delete the previous one, please refer to "Delete Wake-up Words and Command Words").
- Prompt: Learning now, be quiet, please say the wake word to be learned!
- The wake word to be learned: hello, there
- Prompt: Learning successful, please say it again!
- The wake-up word to be learned: hello, there
- Prompt: Learning successful, please say it again!
- The wake-up word to be learned: hello, there
- Prompt: Ok, learning completed!
You can now use the learned wake word to wake up the voice assistant!
Fixed command words:
Command words refer to the words that users use to give certain instructions to voice interactive products and communicate with them.
Learning command words:
Wake up the voice assistant with the wake word (default or already learned), then say "Learning command word" and follow the prompts to learn the command words (before learning a new command word, delete the previous one, please refer to "Delete Wake Words and Command Words").
- Prompt: Learning now, be quiet, please learn the command word according to the prompt! Please say the first command to be learned!
- Example of command word to be learned: Turn on red light
- Prompt: Learning successful, please say it again!
- The command word to be learned: Turn on red light
- Prompt: Learning successful, please say it again!
- The command word to be learned: Turn on red light
- Prompt: OK, learned the first command successfully! Please say the second command to be learned!
... (Continue learning)
Or use "Exit learning" to exit the current learning state.
After learning, an ID will be generated, please refer to the "Command Word/Wake Word ID Table" below to control the program.
Delete Wake Words and Command Words:
Wake up the voice assistant with the wake word (default or already learned), then say "I want to delete" and follow the prompts to learn the command words.
- Prompt: Do you want to delete the learned wake word or command word?
- Delete command word: delete the learned command word.
- Delete wake word: delete the learned wake word.
- Delete all: delete all learned wake words and command words.
- Exit deleting.
Tutorial
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- SEN0539 Gravity: Voice Recognition Module x I2C & UART
- Gravity: Digital RED LED Light Module
- Software
- Arduino IDE
- Download and install the DFRobot_DF2301Q Library (About how to install the library?)
Connection Diagram - I2C
Sample Code
Please switch the communication mode switch to the I2C and download the required library file DFRobot_DF2301Q library for the code.
/*! * @file i2c.ino * @brief Control the voice recognition module via I2C * @n Get the recognized command ID and play the corresponding reply audio according to the ID; * @n Get and set the wake-up state duration * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com) * @licence The MIT License (MIT) * @author [qsjhyy](yihuan.huang@dfrobot.com) * @version V1.0 * @date 2022-04-02 * @url https://github.com/DFRobot/DFRobot_DF2301Q */#include "DFRobot_DF2301Q.h"#define Led 8//I2C communicationDFRobot_DF2301Q_I2C asr;void setup() { Serial.begin(115200); pinMode(Led, OUTPUT); //Init LED pin to output mode digitalWrite(Led, LOW); //Set LED pin to low // Init the sensor while (!(asr.begin())) { Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!"); /** * @brief Set voice volume * @param voc - Volume value(1~7) */ asr.setVolume(4); /** @brief Set mute mode @param mode - Mute mode; set value 1: mute, 0: unmute */ asr.setMuteMode(0); /** @brief Set wake-up duration @param wakeTime - Wake-up duration (0-255) */ asr.setWakeTime(20); /** @brief Get wake-up duration @return The currently-set wake-up period */ uint8_t wakeTime = 0; wakeTime = asr.getWakeTime(); Serial.print("wakeTime = "); Serial.println(wakeTime); // asr.playByCMDID(1); // Wake-up command /** @brief Play the corresponding reply audio according to the ID @param CMDID - command word ID */ //asr.playByCMDID(23); // Command word ID}void loop() { /** @brief Get the ID corresponding to the command word @return Return the obtained command word ID, returning 0 means no valid ID is obtained */ uint8_t CMDID = asr.getCMDID(); switch (CMDID) { case 103: //If the command is “Turn on the light” digitalWrite(Led, HIGH); //Turn on the LED Serial.println("received'Turn on the light',command flag'103'"); //Serial transmits "received"Turn on the light",command flag"103 break; case 104: //If the command is “Turn off the light” digitalWrite(Led, LOW); //Turn off the LED Serial.println("received'Turn off the light',command flag'104'"); //The serial transmits "received"Turn off the light",command flag"104"" break; default: if (CMDID != 0) { Serial.print("CMDID = "); //Printing command ID Serial.println(CMDID); } } delay(300);}
Expected Results
Use a fixed or learned wake-up word to activate the speech recognition module, then speak out "Turn on the light" or "Turn off the light" to control the illumination module.
Connection Diagram - UART
Sample Code
Please switch the communication mode switch to the UART and download the required library file DFRobot_DF2301Q library for the code.
/*! * @file uart.ino * @brief Control the voice recognition module via UART * @n Get the recognized command ID and play the corresponding reply audio according to the ID; * @n Set the wake-up state duration, set mute mode, set volume, enter the wake-up state, and reset the module * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com) * @licence The MIT License (MIT) * @author [qsjhyy](yihuan.huang@dfrobot.com) * @version V1.0 * @date 2022-04-02 * @url https://github.com/DFRobot/DFRobot_DF2301Q */#include "DFRobot_DF2301Q.h"#define Led 8/** @brief DFRobot_URM13_RTU constructor @param serial - serial ports for communication, supporting hard and soft serial ports @param rx - UART The pin for receiving data @param tx - UART The pin for transmitting data*/#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266)) // Use software serialSoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);DFRobot_DF2301Q_UART asr(/*softSerial =*/&softSerial);#elif defined(ESP32) // Use the hardware serial with remappable pin: Serial1DFRobot_DF2301Q_UART asr(/*hardSerial =*/&Serial1, /*rx =*/D3, /*tx =*/D2);#else // Use hardware serial: Serial1DFRobot_DF2301Q_UART asr(/*hardSerial =*/&Serial1);#endifvoid setup() { Serial.begin(115200); pinMode(Led, OUTPUT); //Init LED pin to output mode digitalWrite(Led, LOW); //Set LED pin to low // Init the sensor while (!(asr.begin())) { Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!"); /** @brief Reset module */ // asr.resetModule(); /** @brief Set commands of the module @param setType - Set type @n DF2301Q_UART_MSG_CMD_SET_VOLUME: Set volume, the set value range 1-7 @n DF2301Q_UART_MSG_CMD_SET_ENTERWAKEUP: Enter wake-up state; set value 0 @n DF2301Q_UART_MSG_CMD_SET_MUTE Mute mode; set value 1: mute, 0: unmute @n DF2301Q_UART_MSG_CMD_SET_WAKE_TIME ; Wake-up duration; the set value range 0-255s @param setValue - Set value, refer to the set type above for the range */ asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_MUTE, 0); asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_VOLUME, 7); asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_WAKE_TIME, 20); //asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_ENTERWAKEUP, 0); /** @brief Play the corresponding reply audio according to the command word ID @param CMDID - Command word ID */ asr.playByCMDID(23);}void loop() { /** @brief Get the ID corresponding to the command word @return Return the obtained command word ID, returning 0 means no valid ID is obtained */ uint8_t CMDID = asr.getCMDID(); switch (CMDID) { case 103: //If the command is “Turn on the light” digitalWrite(Led, HIGH); //Turn on the LED Serial.println("received'Turn on the light',command flag'103'"); //Serial transmits "received"Turn on the light",command flag"103"" break; case 104: //If the command is “Turn off the light” digitalWrite(Led, LOW); //Turn off the LED Serial.println("received'Turn off the light',command flag'104'"); //The serial transmits "received"Turn off the light",command flag"104"" break; default: if (CMDID != 0) { Serial.print("CMDID = "); //Print command ID Serial.println(CMDID); } } delay(300);}
Expected Result
Use a fixed or learned wake-up word to activate the speech recognition module, then speak out "Turn on the light" or "Turn off the light" to control the illumination module.
Command Words/Wake-up Words & ID Table
Wake-up words | ID |
---|---|
Wake-up words for learning | 1 |
Hello robot | 2 |
Commands for learning | ID | Commands for learning | ID | Commands for learning | ID |
---|---|---|---|---|---|
The first custom command | 5 | The second custom command | 6 | The third custom command | 7 |
The fourth custom command | 8 | The fifth custom command | 9 | The sixth custom command | 10 |
The seventh custom command | 11 | The eighth custom command | 12 | The ninth custom command | 13 |
The tenth custom command | 14 | The eleventh custom command | 15 | The twelfth custom command | 16 |
The thirteenth custom command | 17 | The fourteenth custom command | 18 | The fifteenth custom command | 19 |
The sixteenth custom command | 20 | The seventeenth custom command | 21 |
Fixed Command Words | ID | Fixed Command Words | ID | Fixed Command Words | ID |
---|---|---|---|---|---|
Go forward | 22 | Retreat | 23 | Park a car | 24 |
Turn left ninety degrees | 25 | Turn left forty-five degrees | 26 | Turn left thirty degrees | 27 |
Turn right forty-five degrees | 29 | Turn right thirty degrees | 30 | Shift down a gear | 31 |
Line tracking mode | 32 | Light tracking mode | 33 | Bluetooth mode | 34 |
Obstacle avoidance mode | 35 | Face recognition | 36 | Object tracking | 37 |
Object recognition | 38 | Line tracking | 39 | Color recognition | 40 |
Tag recognition | 41 | Object sorting | 42 | Qr code recognition | 43 |
General settings | 44 | Clear screen | 45 | Learn once | 46 |
Forget | 47 | Load model | 48 | Save model | 49 |
Take photos and save them | 50 | Save and return | 51 | Display number zero | 52 |
Display number one | 53 | Display number two | 54 | Display number three | 55 |
Display number four | 56 | Display number five | 57 | Display number six | 58 |
Display number seven | 59 | Display number eight | 60 | Display number nine | 61 |
Display smiley face | 62 | Display crying face | 63 | Display heart | 64 |
Turn off dot matrix | 65 | Read current posture | 66 | Read ambient light | 67 |
Read compass | 68 | Read temperature | 69 | Read acceleration | 70 |
Reading sound intensity | 71 | Calibrate electronic gyroscope | 72 | Turn on the camera | 73 |
Turn off the camera | 74 | Turn on the fan | 75 | Turn off the fan | 76 |
Turn fan speed to gear one | 77 | Turn fan speed to gear two | 78 | Turn fan speed to gear three | 79 |
Start oscillating | 80 | Stop oscillating | 81 | Reset | 82 |
Set servo to ten degrees | 83 | Set servo to thirty degrees | 84 | Set servo to forty-five degrees | 85 |
Set servo to sixty degrees | 86 | Set servo to ninety degrees | 87 | Turn on the buzzer | 88 |
Turn off the buzzer | 89 | Turn on the speaker | 90 | Turn off the speaker | 91 |
Play music | 92 | Stop playing | 93 | The last track | 94 |
The next track | 95 | Repeat this track | 96 | Volume up | 97 |
Volume down | 98 | Change volume to maximum | 99 | Change volume to minimum | 100 |
Change volume to medium | 101 | Play poem | 102 | Turn on the light | 103 |
Turn off the light | 104 | Brighten the light | 105 | Dim the light | 106 |
Adjust brightness to maximum | 107 | Adjust brightness to minimum | 108 | Increase color temperature | 109 |
Decrease color temperature | 110 | Adjust color temperature to maximum | 111 | Adjust color temperature to minimum | 112 |
Daylight mode | 113 | Moonlight mode | 114 | Color mode | 115 |
Set to red | 116 | Set to orange | 117 | Set to yellow | 118 |
Set to green | 119 | Set to cyan | 120 | Set to blue | 121 |
Set to purple | 122 | Set to white | 123 | Turn on ac | 124 |
Turn off ac | 125 | Increase temperature | 126 | Decrease temperature | 127 |
Cool mode | 128 | Heat mode | 129 | Auto mode | 130 |
Dry mode | 131 | Fan mode | 132 | Enable blowing up & down | 133 |
Disable blowing up & down | 134 | Enable blowing right & left | 135 | Disable blowing right & left | 136 |
Open the window | 137 | Close the window | 138 | Open curtain | 139 |
Close curtain | 140 | Open the door | 141 | Close the door | 142 |
Learning-related commands | ID | Learning-related commands | ID | Learning-related commands | ID |
---|---|---|---|---|---|
Learning wake word | 200 | Learning command word | 201 | Re-learn | 202 |
Exit learning | 203 | I want to delete | 204 | Delete wake word | 205 |
Delete command word | 206 | Exit deleting | 207 | Delete all | 208 |
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.
More Documents
Get from DFRobot Store or DFRobot Distributor.
Turn to the Top