Arduino Nano Voice Controlled Multi Tasking Coding Tutorial
by Kevr102 in Circuits > Arduino
2202 Views, 33 Favorites, 0 Comments
Arduino Nano Voice Controlled Multi Tasking Coding Tutorial
In this Instructable I will show you in depth how to convert Easyvr3 Voice recognition software into very useable Arduino codes with voice recognition and Voice playback using the Easyvr Commander program.
Easyvr3 Is a voice recognition module which has a microphone and an 8ohm speaker connection, it allows you to give voice commands to energise components, and also recorded voice playback to compliment what each component is doing, could be Servo's, DC motors, Stepper motors, LED's, Lasers etc etc.
I have covered this topic within other Instructables but feel it warrants a separate Instructable as the process is quite complex and Involved, and with very little tuition available online this is an ideal Tutorial as it not only covers Easyvr3 but also Audacity and how to convert mp3 files into the correct Format WAV Files and then using Quick Synthesis 5 to get the sound files into a format so we can import into the Easyvr Commander software.
The goal is to give voice commands to a Stepper motor, Servo motor, DC motor and LED within the same code using Actions in the Easyvr generated Code
The components I am using for this tutorial are as follows:
Supplies
Easyvr3 Module(Without the Shield)
Arduino Nano with Servo Shield
MG90 360 degree continuous Servo Motor
DC Motor with L298 Driver
28BYJ-48 stepper motor with ULN2003 driver
Red LED
Breadboard
Dupont Cables
Mini USB Cable
Easyvr Quick USB Cable 3.3v
9v Battery or 5v 2amp Power supply
Easyvr3 1st Steps
With all components to hand we can now look at the first steps with setting up the Easyvr3
The initial step is to download the libraries for the Easyvr3 these are found on the Fortebit web site.
These zip files then need to be added into the Arduino Library folder.
Once added, within the Arduino Ide click on the examples tab and scroll down to the Easyvr section, select the bridge tab.
Now using an Arduino Nano or Uno connect the Easyvr module making the 5v and ground connections and also the Tx and Rx pins on the module to pins 12 and 13
The bridge makes the connection available so that the Easyvr Commander software can connect to the Easyvr Module.
Failing to do this correctly will result in a warning when connecting to the Commander software.
Using the Easyvr Commander Software
For this process we use the quick USB cable and connect it to the Module and then into the USB port on the computer.
Make sure you have the microphone connected and the 8ohm speaker, the speaker comes into play later.
Looking to the top left of the commander screen we click connect, along the bottom of the screen will say now connected to Easyvr3.
Looking to the left column select Trigger, Trigger is literally the Password to wake the module up, Robot is the default but you can create your own trigger, In this case it will be Wake up, type this into the text box, capital letters are default and space underscores automatically.
To train this word to your voice ensure the text box is highlighted, it will turn Blue and looking along the the text bubbles above the text click on train command, this opens up another box and click on Phase one and say the voice command Wake up! then click phase 2 and repeat the phrase, this is now logged.
In the left hand column now click on 1 group and go through the same process for all the voice actions you want to compile, when you have all your voice commands there is a voice bubble for Test group, click on this and say a command and the correct box will flash green a few times, then press it again and say another command etc until they are all tested.
Note: Try not to get the same sounding words when creating the voice commands, the software tells you if there are conflicts i.e. similar sounding phrases.
With these commands now in place, we will create some Text to Voice free mp3's to mirror our voice commands.
Text to Voice Commands MP3's
Using a Free Text to Speech website TTSMP3 we can convert Text to Speech voices to compliment our Voice Commands.
So when we issue a command the voice will confirm which Motor and the direction of the motor plus state Red LED.
This just entails texting a phrase into the box and selecting a Voice, I went for English Brian, press read to hear the voice and then save as an MP3 file, Once downloaded I renamed the files, we will need to Identify in the next sage of the process, which is converting these files into the correct Format.
Using Audacity to Convert the MP3 Files
Within Audacity using the file tab we can click on Import and select Audio, now select the mp3 voice files we have just created.
I just import one file at a time, and play the file to make sure its ok.
As you can see in the screen shots they are 22050Hz files 16-Bit PCM we need these files to be 8000Hz 16-Bit PCM so to do this on the top row of tabs select Tracks and from the drop down box select Resample, from here we can select 8000Hz click on ok and re play the track, there may be some compression but for this purpose its ok.
We can now click on the file tab and export, then export as a WAV file and save it to a new folder on the desktop, in this case Easyvr voices.
Do the same procedure for all of the files.
We can now move onto the QuickSynthesis 5 software to convert them so we can use them in the commander software.
Quick Synthesis 5 Set Up
Quick Synthesis 5 is part of the Easyvr download and is used to convert the files so that they can be imported into the commander software and used in the Arduino code eventually, a voice command will in turn prompt an action which in turn will trigger a Servo, DC motor or Stepper motor movement.
So on opening up the QS5 software we using the tabs, the white folder is to create a new project, it will just open up a blank page, this is where all the files will be placed eventually, in the file name at the bottom of the page you gve the file a name, in this case it will be Easyvr Voices.
The next process is to click on the green plus tab and find the WAV files we need from the file on the desktop highlight them all and click ok.
In the next box leave settings as default and click ok for all, in the next box click Auto Label all, we now click on the build button, and press ok, it comes up with a warning, click on yes and the next box ok and the following box ok.
We then click save current project and finally click the build button again, next box click ok, then ok again and that's the sound files in the correct format and ready to incorporate into the commander Software.
Easyvr Commander Installing the Newly Created WAV Files
Open the commander software and this time don't connect to the COM port, click on the Update Custom Data tab, this tab is greyed out when connected.
Click on the Import Tab and then find the QS5 Easyvr voice file, click on this and press ok, click on download and this now imports them into the program, you don't see the files at this point, they are uploaded when connected to the Commander.
Now re-connect to the commander and the sound files will be uploaded into the program, clicking on the sound table tab in the left hand column will bring the sound bytes into the main page and we can then click on the speaker to play these files or double clicking does the same thing to test the files.
Make a note of the numbers which correspond to which sound, we will need this information in the code.
We can now create some Arduino code to include our Voice commands and Sound bytes.
Creating Arduino Code From the Easyvr Commander Software
In Easyvr Commander and still connected, click on the Generate code Tab, hovering above any of the Tabs gives a description.
Click the Tab and give the code a unique name, for spaces use underscore, after naming the file select where you want to save it, I always select desktop for ease of finding the file.
So far we have covered Adding voice commands into the Easyvr Commander, Sourcing MP3 text to voice clips, converting the sound clips in Audacity to the correct format, then using the Quick Synthesis software to build the files ready for importing, Then importing the sound files into the commander, then create an Arduino code incorporating the Voice commands and Voice playback.
We can now add our Servo, DC Motor and Stepper motor to the code and initiate some voice activated commands.
The Actual Arduino Code
In this section we look at the Arduino code generated by the Easyvr Commander software.
We want to use a Servo motor, A DC motor and a Stepper motor within the code along with voice commands and triggered voice sound bytes stating what is happening in the action.
We need to add Servo and Stepper motor Libraries into the sketch, I've added screen shots showing exactly what is needed for the sketch to work as I'm not too familiar with the correct "Arduino" terminology and a lot of the code I have no idea what it means but it's what is generated from the Commander software.
The section after Set Up and before the actions is way over my head to be honest.
All I've done is take snippets from existing code and added it into the sketch for each function.
At the end of the day, the goal is achieved, I can give voice commands to make a Servo run clockwise and counter clockwise, and get voice playback for each action, the same for the DC motor and the 28BYJ stepper motor.
Electrical connections are pretty straight forward and the Pin numbers for each component is listed in the code.
I've used the majority of the digital pins on the Nano Shield but using an Arduino Mega would make more ways available for any more complex projects.
The Easyvr3 is a great piece of kit, it looks complicated but once you have been through the process a couple of times it's easy, these are the routines before any code is generated, but the possibilities are endless.
I hope you enjoyed this Instructable and thanks for looking.