Interfacing EasyVR with PIC Microcontroller
Easy VR 3.0 Speech Recognition Module is a multi-purpose speech recognition module designed to easily add versatile, robust and cost effective speech recognition capabilities to almost any application. The Easy VR 3 module can be used with any host with an UART interface powered at 3.3V – 5V, such as PIC and Arduino boards.
Some application examples include home automation, such as voice controlled light switches, locks, curtains or kitchen appliances, or adding “hearing” to the most popular robots on the market.
It can be easily plugged into a solder-less breadboard or standard prototyping board using the male headers provided.
Specification
- A selection of 26 built-in Speaker Independent (SI) commands (available in US English, Italian, Japanese, German, Spanish, and French) for ready to run basic controls.
- Supports up to 32 user-defined Speaker Dependent (SD) triggers or commands (any language) as well as Voice Passwords.
- With the optional Quick T2SI Lite license you can add up to 28 Speaker Independent (SI) Vocabularies, each one with up to 12 SI different commands. Therefore an overall number of up to 336 additional SI commands!
- SonicNet to control one or more EasyVR 3.0s wirelesly with sound tokens generated by the module or other sound source.
- DTMF tone generation
- Easy-to-use and simple Graphical User Interface to program Voice Commands to your robot
- Compatible with Arduino boards that have the 1.0 Shield interface (UNO R3) and legacy boards including:
- Arduino Duemilanove
- Arduino Uno
- Arduino Mega
- Arduino Leonardo
- Arduino Due
- Module can be used with any host with an UART interface (powered at 3.3V – 5V).
- Supports direct connection to the PC on main boards with a separate USB/Serial chip and a special software-driven “bridge” mode on boards with only native USB interface, for easy access by the EasyVR Commander.
- Simple and robust serial protocol to access and program the module through the host board.
- Make your own sound tables using Sensory QuickSynthesis4 tool.
- Supports remapping of serial pins used by the Shield (in SW mode).
- The new EasyVR GUI includes a command to process and download custom sound tables to the module (overwriting existing sound table)
- Provides a 3.5mm audio output jack suitable for headphones or as a line out
- 8 ohm speaker output
- Access to EasyVR I/O pins
- LED to show feedback during recognition tasks
- Live message recording and Fast SD/SV recognition
- Arduino Libraries provided
Pinout
The outer headers J1 and J2 are the mikroBUS™ interface connectors, providing selectable 3.3V/5V power input to the module and voltage translated digital I/O lines, including: UART receive/transmit lines and control pins.
The header J3 provides configurable I/O expansion lines (inputs with weak internal pull-up by default), powered at the internal logic voltage VDD.
The header J4 contains the main analog signals, such as microphone signals and amplified DAC outputs, which are also available on the internal right angle connectors J5 and J6.
The module can also be operated through the programming connector J7 alone, by using the QuickUSB Adapter Cable.
Pin Assignment
Communication protocol
Communication with the EasyVR module uses a standard UART interface compatible with 3.3-5V TTL/CMOS logical levels, according to the powering voltage VCC.
A typical connection to an MCU-based host:
The initial configuration at power on is 9600 baud, 8 bit data, No parity, 1 bit stop. The baud rate can be changed later to operate in the range 9600 – 115200 baud.
The receiver input data line is RX, while the transmitter output data line is TX. No handshake lines are used.
EasyVR Commander
The EasyVR Commander software can be used to easily configure your EasyVR module connected to your PC through a QuickUSB cable, an adapter board, or by using the micro-controller host board.
You can define groups of commands or passwords and generate a basic code template to handle them. It is required to edit the generated code to implement the application logic, but the template contains all the functions or subroutines to handle the speech recognition tasks.
Connect the QuickUSB cable, an adapter board or a micro-controller host board with a running “bridge” program6 to your PC, then check that all devices are properly turned on and start the EasyVR Commander. Select the serial port to use from the toolbar or the “File” menu, and then go with the “Connect” command.
There are five kinds of commands in the software (see Figure ):
- Trigger – special group where you have the built-in SI trigger word “Robot” and you may add one user-defined SD trigger word. Trigger words are used to start the recognition process
- Group – where you may add user-defined SD commands, organized in subsets
- Password – special group of “voice passwords” (up to 5), using Speaker Verification (SV) technology
- Wordset – built-in set of SI commands (for instance in Figure 3 above, the Wordset 1 is selected)
- Grammar – custom set of SI commands (created with QuickT2SI TM Lite software).
There are also two other categories of data shown:
- SoundTable – list of compressed audio samples (prompts, sounds, etc.) loaded into the module
- Messages – run-time sound recordings stored on internal memory
Speech Recognition
The recognition function of the EasyVR works on a single group at a time, so that users need to group together all the commands that they want to be able to use at the same time.
When EasyVR Commander connects to the module, it reads back all the user-defined commands and groups, which are stored into the EasyVR module non-volatile memory.
Adding a Command to the EasyVR
You can add a new command by first selecting the group in which the command needs to be created and then using the toolbar icons or the “Edit” menu.
A command should be given a label and then it should be trained twice with the user’s voice: the user will be guided throughout this process (see Figure 5) when the “Train Command” action is invoked.
Training a Command to the EasyVR
First click on the Training a command icon.
After clicking on “Phase 1” or “Phase 2” buttons, remember you have to start speaking only when you see a little window of Speak now.
If any error happens, command training will be cancelled. Errors may happen when the user’s voice is not heard correctly, there is too much background noise or when the second word heard is too different from the first one.
Testing the trained Command
If you want to test the trained commands, select the group in which the trained commands are present then click on the Test group icon on the toolbar or the “Edit” menu.
Sound Table
The EasyVR module can play one of the sounds or sentences saved on its internal flash memory. A predefined “beep” sound is also always available, even when no sounds have been downloaded to the module.
The custom sounds are organized in a so-called “sound table” that users can prepare and build with the special QuickSynthesis TM tool. Please refer to this application’s own manual for details about the creation of a sound table. Let’s summarize the basic steps here:
- Prepare the audio files you want to include in the sound table in WAV format, uncompressed 16-bit 22050Hz mono. To create the sound files you may use a free software like Audacity for example (http://audacity.sf.net)
- Open Sensory’s QuickSynthesisTM 5 and create a new project, specifying “RSC4 family”
- Add your WAV files and specify one of the supported compression scheme (see table below)
- Optionally add sentences, by combining basic WAV sounds. That allows you to save memory when you have speech audio files, if they share some pieces (like “You said” + “One”, “You said” + “Two”, and so on)
- Build the project with QuickSynthesis TM and use default settings (“Build linkable module”, “Load in CONST space”, “Load above or at: 0”). You will be asked to recompress new or modified sound files, just confirm and proceed
- Now save your project and build it once again, so that the EasyVR Commander will see that your build is up to date.
The audio compression formats supported by the EasyVR module (from highest to lowest compression rate):
For audio file containing speech, the SX-3 compression is usually a good choice. If you need higher quality try lower compression rates. Please note that due to the sampling rate used, the audio files cannot contain very high frequencies (less than half the sampling rate).
Adding a wave to the sound table
Inorder to add a wave to the Sound Table we need another software called Sensory QuickSynthesis.
First of all create a new file,
Then create a new project
Then add wave files, next you get a compression window, click ok for all.
After that your wave files are added to the list. Next you need to build it by clicking on the build icon
Again click on the Build icon then OK
Import and Export of Custom Commands
Starting with firmware revision 4 of the EasyVR 3 module, it is possible to export all the data, including training, of the existing commands and passwords into a file. You can then use that file to import all the commands at once into another module or just as a backup for your commands.
While the module is connected, click on “Export Commands…” under the “File” menu and write the name of the file that will contain the exported commands. In the same way you can select “Import Commands…” and then choose the file with the commands you would like to import.
During the Import/Export process some feedback is provided with pop-up windows and with the progress bar on the main window.
Updating Custom Data
Once the sound table and/or custom recognition grammars have been created, they can be processed by the EasyVR Commander and downloaded to the module. Note that you must first disconnect from the module and do the steps required to start it in “boot-mode”.
Now the command “Update Custom Data” is enabled, either on the toolbar or the “File” menu, and it can be used to start the update process. First you are required to list all the QuickSynthesis TM and QuickT2SI TM projects you want to use. A new file containing the specified custom data will be generated and the contents will be displayed, so that you can verify them before updating the module.
Once back in the EasyVR Commander the project can be reloaded by pressing the “Refresh” button. If the process completes successfully, the “Download” button will be enabled and the flash update process can start.
The default format of generated data is suitable for the EasyVR 3. For previous versions of the module or the shield please make sure to check the option “Old Format (EasyVR 2.0)”.
The download process will connect at a higher speed to the EasyVR module, so the “bridge” program running on your host device might not work (in particular Robonova and Basic Stamp cannot be used for this purpose) and you might need a true “serial adapter”.
The full speed used is 230400 bps, but the option “Slow transfer” can be used to reduce it to115200, for better compatibility with slower serial adapters 7. One adapter that can go to full speed is the QuickUSB cable. Otherwise any USB/Serial adapter with TTL/CMOS interface can be used for updating the flash. The EasyVR Shield can be used for the download, provided that the mode jumper is in UP or LEO position.
After the download completes, a new connection can be established with the EasyVR module (in “normal mode”) and the new sounds will be displayed by the EasyVR Commander, in the special group “SoundTable” (the last one in the list with a yellow icon). They can be played back and tested using the “Play Sound” command on the toolbar or in the “Tools” menu. See also how to do that in your application in the code example Use custom sound playback.
Custom grammars will be displayed just after the built-in word sets and they work exactly the same way. Trigger words, when specified, will have their own vocabulary with only one entry. You can test and use the custom trigger and command grammars as you do with the built-in ones.
Flash Update
The EasyVR module includes a boot loader that allows to update the firmware and to download new sound tables or custom grammars to the on-board memory.
The boot mode is activated by keeping the XM signal to a high logical level at power on or reset. This can be easily done with a jumper (or switch) taking the signal to a suitable pull-up resistor.
To download a firmware update, a sound table or a custom grammar to the EasyVR, power on the module with the jumper closed. For normal operation, just leave the jumper open. Do not change the jumper position while the module is already powered on. It is safe to change XM level while the module is reset (RST low).
Interfacing with PIC Microcontroller
It is quite easy to use the EasyVR with Arduino by using this library from Github. It uses software serial pins to communicate with the module. The connections should be as follows
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
#include pic.h #define RS RC1 // LCD RS pin #define RW RC0 // LCD RW pin #define EN RC5 // LCD Enable pin #define Data PORTD // LCD Data port #define BEEP "wAAP" // default beep in the location #define HAI "wABP" // play 1st Wave entry at full volume #define HELLO "wACP" // play wave entry 2 at full volume #define RHYDO "wADP" // play wave entry 3 at full volume #define ACTIVE_REC "dC" int Temp_val=0,Count=0,Count1=0; int Timer_flag=0,ext_cnt=0; unsigned char Start_flag=0,Ok_done=0, Error_flag=0, Time_Out=0,Response_flag=0,Wake_done=0; unsigned char Hai_flag=0,Hello_flag=0,Rhydo_flag=0;//,Left_flag=0,Right_flag=0,Stop_flag=0,Kick_flag=0; unsigned char Mode=0; /************************************************************************************************** * Function : DelayMs * Description : Function to get delay * Parameters : y, contains the delay to be send **************************************************************************************************/ void DelayMs(int ms) { int i,count; for(i=1;i<=ms;i++) { count=498; while(count!=1) { count--; } } } /************************************************************************************************** * Function : lcd_Command * Description : Function to send a command to LCD * Parameters : cmd, contains the command to be send **************************************************************************************************/ void lcd_command(char cmd) { Data=cmd; RS=0; RW=0; EN=1; DelayMs(20); EN=0; } /************************************************************************************************** * Function : lcd_Data * Description : Function to send a data to LCD * Parameters : data, contains the data to be send **************************************************************************************************/ void lcd_data(char dat) { Data=dat; RS=1; RW=0; EN=1; DelayMs(20); EN=0; } /************************************************************************************************** * Function : LCD_initial * Description : Function to intialize LCD * Parameters : None **************************************************************************************************/ void lcd_initial() { lcd_command(0X30); DelayMs(10); //LCD Initial Delay lcd_command(0X30); DelayMs(10); //LCD Initial Delay lcd_command(0X30); DelayMs(20); //LCD Initial Delay lcd_command(0x01); //Clear Display lcd_command(0x38); //Double Line Enable lcd_command(0x06); //Auto Increment lcd_command(0x0C); //Display On lcd_command(0x80); //Lcd Location } /*********************************************************************************************** * Function : display * Description : Function to send a string of data in to LCD * Parameters : cmd,dis ***********************************************************************************************/ void display(char cmd,const char *dis) { lcd_command(cmd); while(*dis!='') { lcd_data(*dis); dis++; } } /*********************************************************************************************** * Function : usart_initial * Description : Function Intialises USART * Parameters : baud_rate, contains the value calculated for baudrate ***********************************************************************************************/ void usart_initial(long int baud_rate) { TXSTA=0X24; switch(baud_rate) { case 9600: SPBRG = 129; break; case 19200: SPBRG = 64; break; case 38400: SPBRG = 32; break; case 57600: SPBRG = 21; break; case 115200:SPBRG = 10; break; default: break; } CREN=1; /* Continous Receive Enable */ SPEN=1; /* Serial Port Enable */ GIE=1; /* Global Interrupt Enable */ PEIE=1; /* Periphral Interrupt Enable */ RCIE=1; /* Reception Interrupt Enable */ } /*********************************************************************************************** * Function : usart_char * Description : Function to send a single data through USART * Parameters : dat ************************************************************************************************/ void usart_char(char dat) { TXREG = dat; while(TRMT == 0); } /*********************************************************************************************** * Function : usart_send * Description : Function to send a string of data through USART * Parameters : snd, contains the adddress of a string ************************************************************************************************/ void usart_send(const char *snd) { while(*snd!='') { usart_char(*snd); snd++; } } /************************************************************************************************/ void Voice_Recognisation() { if(Start_flag==0) { lcd_command(0x01); usart_send(BEEP); DelayMs(300); display(0X80,"Speak "); usart_send(ACTIVE_REC); DelayMs(1);display(0X80,"Speak. "); DelayMs(1);display(0X80,"Speak.. "); DelayMs(1);display(0X80,"Speak... "); DelayMs(1);display(0X80,"Speak.... "); if(Response_flag==3){display(0XC0,"Matched. ...... ");DelayMs(50);TXREG=' ';while(TRMT==0);Start_flag=0;DelayMs(1);} if(Response_flag==2){display(0XC0,"Error....... ");DelayMs(300);while(Ok_done!=1);Ok_done=0; }//usart_send(ERROR); if(Response_flag==1){display(0XC0,"Time Out....... ");DelayMs(300);while(Ok_done!=1);Ok_done=0;}//usart_send(TIME_OUT); Response_flag=0; lcd_command(0x01); } } char Voice_Play() { if(Hai_flag==1) { display(0X80,"Hai "); usart_send(HAI);while(Ok_done!=1);Ok_done=0;Hai_flag=0; return 'A'; } if(Hello_flag==1) { display(0X80,"Hello "); usart_send(HELLO);while(Ok_done!=1);Ok_done=0; Hello_flag=0; return 'H'; } if(Rhydo_flag==1) { display(0X80,"Rhydo "); usart_send(RHYDO);while(Ok_done!=1);Ok_done=0; Rhydo_flag=0; return 'R'; } } /******************************************* Main function *******************************************/ void main() { char Rec_voice; TRISC=0X80; TRISD=0X00; lcd_initial(); usart_initial(9600); display(0X80,"EasyVR"); usart_send(BEEP);DelayMs(500); while(1) { Voice_Recognisation(); Rec_voice=Voice_Play(); if(Rec_voice=='A'){display(0XC0,"Hai okk");DelayMs(200);} if(Rec_voice=='H'){display(0XC0,"Hello okk");DelayMs(200);} if(Rec_voice=='R'){display(0XC0,"Rhydo okk");DelayMs(200);} } } /******************************************* Interrupt Function *******************************************/ void interrupt ISR() { char Rec_Data; if(RCIF==1) { RCIF=0; Rec_Data=RCREG; //TXREG=Rec_Data; //while(TRMT==0); /******************************************* Voice Play *******************************************/ if(Rec_Data=='A') {Hai_flag=1;} if(Rec_Data=='B') {Hello_flag=1;} if(Rec_Data=='C') {Rhydo_flag=1;} if(Response_flag==2&&Rec_Data=='o') {Ok_done=1;} if(Response_flag==1&&Rec_Data=='o') {Ok_done=1;} if(Hai_flag==1 &&Rec_Data=='o') {Ok_done=1;} if(Hello_flag==1 &&Rec_Data=='o') {Ok_done=1;} if(Rhydo_flag==1 &&Rec_Data=='o') {Ok_done=1;} /******************************************* Voice Recognisation *******************************************/ if(Rec_Data=='t') {Start_flag=0;Response_flag=1;} if(Rec_Data=='e') {Start_flag=0;Response_flag=2;} if(Rec_Data=='r') {Start_flag=1;Response_flag=3;} /******************************************* ************ *******************************************/ } } |
Shop With Us
Click here to buy Easy VR 3.0 Speech Recognition Module
Leave a Reply
You must be logged in to post a comment.