We’ve already covered inexpensive offline voice recognition modules based on US516P6 or TW-ASR ONE microcontrollers that allow people to add smarts to their projects without a network connection for improved privacy and lower latency.
Those are great in theory, but at the time (April 2022) documentation was lacking or only in Chinese, and they were fairly hard to use based on some of the comments in my earlier posts. But today, I’ve noticed DFRobot is now selling the “Gravity: Offline Voice Recognition Sensor – I2C & UART” module with support for Arduino programming, and it looks fairly easy to customize as we’ll see further below.
Gravity Voice Recognition DF2301QG module specifications:
- Voice recognition module – WS-2520-TR module with
- MCU – TBD
- 121 commonly used fixed voice commands, one-fixed wake word
- Support for 1 learned wake-word, 17 user-defined commands
- Audio
- Output – Built-in speaker and external speaker interface
- Input – Dual microphones with -28dB sensitivity
- Host interface – I2C (0x64 address) and UART via 4-pin “Gravity” connector; 3.3V and 5V compatible
- Misc – Power LED (red), recognition status LED (blue)
- Supply Voltage – 3.3 to 5V
- Max current – ≤370 mA (5V)
- Dimensions – 49 x 32 mm
The important part is that it is much easier to work with than the earlier offline voice modules. The default wake word is “Hello robot”, but you can change it to another one with the voice command “learning wake word” and you’ll be asked to repeat your new wake word such as “hello, there” three times.
The same is true for voice commands. The module comes with over 100 preset commands such as “Turn left ninety degrees”, “Tag recognition”. “Forget”, “Turn off the light”, etc.. and so on, but the user can also have the module learn up to 17 new custom commands using the voice command “Learning command word” for a specific ID. You’ll also be asked to repeat the voice command three times to register it. Everything is explained in detail in the wiki.
The DF2301QG offline voice recognition module is shown connected to an Arduino clone over I2C board, but it could support any other hardware with UART or I2C including other Arduino boards, Raspberry Pi boards or SBCs, ESP32 modules, and boards, etc…
So far we have not done any programming, and only used our voice to customize the module. Each wake word and voice command has its own ID, and that’s what we’d use in an Arduino Sketch as shown below after having installed the DF2301Q Arduino library:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
#include "DFRobot_DF2301Q.h" #define Led 8 //I2C communication DFRobot_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); } |
DFRobot DF2301QG module is selling for $16.90 which is about double the price of the other modules I covered before, but it may be worth it as it looks much easier to use than the other ones.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
can Fixed Command Words and Learning-related commands themselves be deleted by “I want to delete” ? If so it can be sabotaged and potentially put in non-functioning state.
The way I understand it, the fixed commands/wake word can’t be deleted, only the custom ones. So for example, the “delete all” command only deletes the user-defined commands.
Under $20 that’s not bad. I’d like more than 17 custom commands but its price isn’t unreasonable all things considered.
It’s not a complete solution yet (with microphone, etc), but did you see the announcement for the Renesas ASSP EASY MCU for Voice HMI Based on RISC-V? I haven’t investigated it in detail (no need), but it’s a Renesas RISC-V MCU with 3rd part off line voice recognition software.
https://www.renesas.com/us/en/products/microcontrollers-microprocessors/risc-v/r9a06g150-assp-easy-mcu-voice-hmi-based-risc-v