Grove Speech Recognizer Kit for Arduino
The Grove Speech Recognizer Kit for Arduino is designed for prototype of Smart Home which includes some basic home elements such as Speech Recognizer, Infrared Emitter. You can learn the functions and applications of Speech Recognizer quickly via this kit, the guideline shows some common demos, let's say you can play music via your speak command 'Play music', or turn on the light according to the corresponding command.
Part List
Grove - Speech Recognizer SKU:101020232
Application
How to turn on the TV
Sometimes, we want to control something by our voice, such as TV, air condition. Those devices are controlled by Infrared Remote controller, so we need to know what the code of each button of infrared remote controller first, and then put the code under our program. Finally your voice could trigger those button codes and you can control those devices like infrared remote controller.
Before create this demo you should prepare some necessary components:
Grove - Infrared Receiver
Grove - Infrared Emitter
Grove - Speech Recognizer
Base Shield
Arduino UNO
Infrared Remote controller
Get code of a infrared remote controller via Grove - Infrared Receiver
Download necessary libraries from github : IRSendRev ,pay attention to the path of your libraries: .../arduino/libraries
Now open the example file of "recv" : File --> Sketchbook --> libraries --> IRSendRev --> recv.
Upload the program to your Arduino UNO.
Plug Base Shield onto the Arduino UNO,and plug the Grove - Receiver onto the D2 port of Base Shield.
Also you can change another port while modifying the definement of pin. </dd></dl>
Open the monitor of Arduino UNO.
Press a button of any Infrared Remote Controller, you'll get the detailed information code of the button, see following:
Write down the detailed information of the button you want to press. Following are the information of a button:
Modify the IRSend program
Now we can use the previous information code of a button.
Open the example file of "send" : File --> Sketchbook --> libraries --> IRSendRev --> send.
Upload the program to your Arduino UNO.
Plug Base Shield onto the Arduino UNO,and plug the Grove - Receiver onto the D3 port of Base Shield.
First we need modify the default information of the button:
Modify those information according to the previous one you wrote:
You can observe that:
So you can note or delete those two lines.
Of course you can also define many buttons:
Add Speech Recognizer to your IRSend program
It's very simple to use Speech Recognizer alone, please see the wiki of it first.
We can choose what buttons we need according to the table<ref>Table of return value, Grove - Speech Recognizer</ref> of return value of Speech Recognizer. Following is the table of return value:
Command | Return Value |
Turn on the light | 1 |
Turn off the light | 2 |
Play music | 3 |
Pause | 4 |
Next | 5 |
Previous | 6 |
Up | 7 |
Down | 8 |
Turn on the TV | 9 |
Turn off the TV | 10 |
Increase temperature | 11 |
Decrease temperature | 12 |
What's the time | 13 |
Open the door | 14 |
Close the door | 15 |
Left | 16 |
Right | 17 |
Stop | 18 |
Start | 19 |
Mode 1 | 20 |
Mode 2 | 21 |
Go | 22 |
The following example uses two commands: "Turn of the TV" and "Turn off the TV"
After reading, we can embed the program of Speech Recognizer in the IRSend program. See the following completed program:
```
include
include
/======== IR type ========/
define BIT_LEN 0
define BIT_START_H 1
define BIT_START_L 2
define BIT_DATA_H 3
define BIT_DATA_L 4
define BIT_DATA_LEN 5
define BIT_DATA 6
const int ir_freq = 38; // 38k
/ ======== How many IR buttons you wanna send ========/
unsigned char OpenTV[20]; unsigned char CloseTV[20];
/========= Choose the pins of Speech Recognizer ==========/
define SOFTSERIAL_RX_PIN 5
define SOFTSERIAL_TX_PIN 6
SoftwareSerial speech(SOFTSERIAL_RX_PIN,SOFTSERIAL_TX_PIN);
/ ======= How to write the IR data ========/ / ==== You can get those data via IR Recevier ==== /
void OpenTVInit() { OpenTV[BIT_LEN] = 9; // all data that needs to be sent OpenTV[BIT_START_H] = 180; // the logic high duration of "OpenTV" OpenTV[BIT_START_L] = 88; // the logic low duration of "OpenTV" OpenTV[BIT_DATA_H] = 11; // the logic "long" duration in the communication OpenTV[BIT_DATA_L] = 33; // the logic "short" duration in the communication
}
void CloseTVInit() { CloseTV[BIT_LEN] = 9; // all data that needs to be sent CloseTV[BIT_START_H] = 178; // the logic high duration of "CloseTV" CloseTV[BIT_START_L] = 89; // the logic low duration of "CloseTV" CloseTV[BIT_DATA_H] = 10; // the logic "long" duration in the communication CloseTV[BIT_DATA_L] = 33; // the logic "short" duration in the communication
}
void setup() { OpenTVInit() CloseTVInit() Serial.begin(9600); speech.begin(9600); speech.listen(); }
void loop() { int a=0;
}
PlayPause(); // pause music PlayResume(); // restart a music PlayNext(); // next song PlayPrevious(); // previous song PlayLoop(); // loop all songs SetVolume(uint8_t volume); // set volume. default value is "0x0E", the range is 0x00 to 0x1E. IncreaseVolume(); // increase volume DecreaseVolume(); // decrease volume
SelectPlayerDevice(0x02);
SpecifyMusicPlay(5);
SpecifyfolderPlay(1,5);
delay(length of time); // delay the length of time until the song is played out
while(QueryPlayStatus() != 0); // Return: 0: played out; 1: not play out
SpecifyMusicPlay(1); while(QueryPlayStatus() != 0); SpecifyMusicPlay(2); while(QueryPlayStatus() != 0); SpecifyMusicPlay(3); while(QueryPlayStatus() != 0);
include
include
/** Define the pins of MP3 **/ SoftwareSerial mp3(2, 3);
/** Define the pins of Speech Recognizer **/
define SOFTSERIAL_RX_PIN 5
define SOFTSERIAL_TX_PIN 6
SoftwareSerial speech(SOFTSERIAL_RX_PIN,SOFTSERIAL_TX_PIN);
void setup() { mp3.begin(9600); speech.begin(9600); Serial.begin(9600); delay(100);
}
void loop() { int a=0; if(speech.available()) { a = speech.read(); // Read the return value from the Speech Recognizer switch (a) { case 3: // speech command : Play music SpecifyMusicPlay(1); // MP3: play the name of "001" break; case 4: // speech command : Pause PlayPause(); // MP3: pause music break; case 19: // speech command : Start PlayResume(); // MP3: continue music break; case 5: // speech command : Next PlayNext(); // MP3: play next song break; case 6: // speech command : Previous PlayPrevious(); // MP3: play previous song break; default: break; }
}
clock.fillByYMD(2016,1,19);//May 23,2016 clock.fillByHMS(15,28,30);//15:28 30" clock.fillDayOfWeek(Mon);//Saturday
include
include "DS1307.h"
include
include
/* Define the pins of MP3 **/ SoftwareSerial mp3(2, 3);
/* Define the pins of Speech Recognizer **/
define SOFTSERIAL_RX_PIN 5
define SOFTSERIAL_TX_PIN 6
SoftwareSerial speech(SOFTSERIAL_RX_PIN,SOFTSERIAL_TX_PIN);
/* Define a object of DS1307 class **/ DS1307 clock;//define a object of DS1307 class
void setup () { mp3.begin(9600); speech.begin(9600); clock.begin(); Serial.begin(9600); delay(100);
SelectPlayerDevice(0x02); // Select SD card as the player device. SetVolume(0x15); // Set the volume, the range is 0x00 to 0x1E. }
void loop () { int a=0; speech.listen(); // start to receiver data from the software port of Speech Recognizer if(speech.available()) { a = speech.read(); // Read the return value from the Speech Recognizer if(a==13) { clock.getTime(); // get the real-time from Grove - RTC int b=1+clock.hour; // get hour data; because the 1th name of song is the voice "0" , so in order to get the voice "60" (it's) , the number of the name should be added 1. int c=1+clock.minute; // get hour data; because the 1th name of song is the voice "0" , so in order to get the voice "60" (it's) , the number of the name should be added 1.
} delay(1000); }
```
Resource
Last updated