Voice recognition technology has been here around the past few years. We still remember the great excitement we had while talking to the first Siri enabled iphone. Since then, voice command devices has grown to a very advanced level beyond our expectations in a very short time. With the introduction of many advanced voice recognition systems there came many other voice assistants like the Google assistant and the Amazon Alexa. The rapid success of Amazon’s Echo alone proves that we are gradually coming to terms with talking to machines.
So let's start from the basics. In this instructable i'll give you an introduction about the Elechouse V3 Voice Recognition Module and how to turn on/off an LED using voice commands. There are several other ways to implement voice recognition in your project, right from an android phone to Alexa or Raspberry pi or some other tech. But i got several messages from many of my friends asking me how to use this specific module with Arduino. So i'm writing this instructable as a basic tutorial for the Elechouse V3 module. I wanted to make this instructable as simple as possible for beginners, so we won't be discussing the complete features and functions of the module, but at the end, i'm sure you'll get some pretty cool ideas for your next project.
Step 1: Elechouse V3 Voice Recognition Module.
Elechouse V3 is one of the most compact and easy-to-control voice recognition module in the market.
There are two ways for using this module, using the serial port or through the built-in GPIO pins. The V3 board has the capacity to store up to 80 voice commands each with a duration of 1500 milliseconds. This one will not convert your commands to text but will compare it with an already recorded set of voices. So technically there are no language barriers to use this product. You can record your command in any language or literally any sound can be recorded and used as a command. So you need to train it first before you let it recognize any voice commands.
If you're using the module with it's GPIO pins, the module will deliver outputs for only 7 commands out of the 80. For this method you need to select and load 7 commands in to the recognizer and the recognizer will send outputs to the respective GPIO pins if any of these voice commands gets recognized. As we're using this with the arduino, we don't need to bother about the limited features.
The device works at an input voltage range of 4.5 - 5 volts and will draw a current less than 40 mA. This module can work with 99% recognition accuracy if it is used under ideal conditions. The choice of microphone and the noise in the environment plays a vital role in affecting the performance of the module. It's better to choose a microphone with good sensitivity and try to reduce the noise in your background while giving commands to get the maximum performance out of the module.
Step 2: Connecting the Module to Arduino.
Now let's talk about the connections to be made.
Hardware required :
- Arduino UNO R3. (I'm using Arduino Pro Mini here, It doesn't matter, both of them are almost same in function.)
- Microphone with 3.5 mm plug attached. (or you can solder it directly on to the board. They've given the pins.)
- An LED.
- A 470 ohms resistor for the LED.
- Wires as required.
- USB cable for programming the Arduino.
Connecting the Module to Arduino
- GND - Ground
- VCC - 5 V
- RXD - Digital pin 3 of Arduino (This is a user defined pin. Sample code has Pin 3 as Tx.)
- TXD - Digital pin 2 of Arduino (This is also a user defined pin.)
The LED is connected to the digital pin 13 of the Arduino as defined in the sample code. Connect a 470 ohms resistor in series to the LED.
Plug the microphone in to the 3.5 mm jack in the board. Solder it to the mic pins in the module if it doesn't come with a 3.5 mm plug.
That's all it is about the connections. Now let's have a look at the code.
Step 3: Setting Up the Code.
All the codes and libraries mentioned here are open-source and the credits for developing them goes to their respective authors.
You should download and install the "voicerecognitionv3.h" Arduino library before you could use the module with an Arduino.
Download the library from here.
All the codes we need are there in the library zip file as example programs.
Training the V3 Module.
As I've mentioned above, we must train the module before we can use it for voice recognition. Follow these steps to train the module.
- Connect the Circuit to the computer.
- Launch the Arduino IDE.
- Check whether you've selected the right Arduino board. (Tools -> Board)
- Check if the right COM port is selected. (Tools -> Port)
- Now open the sample program for training the module.
- Go to File -> Examples -> VoiceRecognitionV3 -> vr_sample_train
- Upload the code to Arduino and wait until the code gets uploaded. (Ctrl + U)
- Open the Serial Monitor. (Ctrl + Shift +M)
- Make sure that the baud rate is set to 115200 and the "Newline" option is selected.
- If everything is fine, a menu will be shown on the serial monitor as shown in the pictures.
- There are several commands that you can type in to the serial monitor to program the module, here we'll be using the "train" command to train the module.
- The V3 has a capacity to store 80 voice commands, each with a duration of 1500 ms. Each command is stored in an address starting from 0 to 79.
- By using the "train" command, we're storing a voice command in to a specific address, so you should specify the address in the command.
- The syntax of the command goes like this : train address For example : train 0, train 20, train 79.
- We will require two voice commands for controlling the LED. One command to turn it ON and the other one to turn it OFF.
- Enter the command in the serial monitor followed by the address you want to store it. eg : train 20.
- After you've entered the command, wait for a message to appear on the serial monitor that says "speak now". Now speak your command for turning ON the LED in to the microphone clear and loud enough.
- If the command is clear enough, another message will show up asking you to speak again. Speak it again to register the command.
- The code will ask you to repeat the command if some noise occurs during the recording or if the sound is not clear enough. The quality of your microphone has a considerable role over here. You may fail to register a command if your microphone isn't good enough. Also train the board in a noise free environment.
- Once you've successfully entered a voice into the module, repeat the same process to input the voice command for turning OFF the LED. Remember to store the command in a different address. For eg : train 30.
- If you've successfully loaded both of the commands, you're now ready to upload the code for controlling the LED.
Controlling the LED using Voice Commands.
- Open the sample program for controlling the LED.
- Go to File -> Examples -> VoiceRecognitionV3 -> vr_sample_control_led
- In this program two records are defined as "onrecord"(for turning ON the LED) and "offrecord" (for turning OFF the LED).
- Change the value of "onrecord" to the address of the voice command which you've trained to turn ON the LED.
Change the value of "offrecord" to the address of the voice command which you've trained to turn OFF the LED.
Now upload the code to the Arduino. (Ctrl+U)
That's all it is. Now you're ready to control your LED with voice commands.
Step 4: Result
To test the circuit, speak up the commands just as you trained it to turn ON/OFF the LED. Remember, the quality of your microphone and the noise around your environment will really affect the output. Try testing it in a noise free environment or change the microphone if you're not getting a proper response for your voice commands. Also open the serial monitor to check if the device is responding to your voice commands. If a command gets recognized, the serial monitor will show a message with the address of the recognized command.
Congrats! You've learned to control an LED using voice commands. Now you can convert any such device in to a voice controlled device. Connect a relay module to the Arduino to control AC devices like a light bulb or a fan.
There are numerous possibilities to apply this in our daily life. Share your thoughts in the comments section below.
I hope this instructable has given you a basic idea about using the Elechouse V3 Voice Recognition module with Arduino. If you've any questions, feel free to ask it here or send a mail to firstname.lastname@example.org. I'll try my best to help you out.
KevinJ202 made it!