Hello Guys,
I am working on a home automation project which is voice based.Everythin g is working fine.But what i wanna do is that the recogniton becomes activated only when a magic word is spoken like "alpha gamma" and the system says"welcome master gimme ur commands" and then when i speak"switch on" then only it performs the action.If i say "switch on" before saying "alpha gamma" then it simply ignores it.
Partial code is as follows:-
Thanks in advance
-King
I am working on a home automation project which is voice based.Everythin g is working fine.But what i wanna do is that the recogniton becomes activated only when a magic word is spoken like "alpha gamma" and the system says"welcome master gimme ur commands" and then when i speak"switch on" then only it performs the action.If i say "switch on" before saying "alpha gamma" then it simply ignores it.
Partial code is as follows:-
Code:
private void Reco_Event(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
txtReco.Text = Result.PhraseInfo.GetText(0, -1, true);
//..........................Device 1------------------------------------
if (txtReco.Text == "Device One ON")
{
//SerialPortDataReader.SendDataToPort("1");
controller.Speak("SWITCHED ON");
//System.Diagnostics.Process.Start(@"C:/1.wma");
//System.Diagnostics.Process.Start("msconfig.exe");
//------------------My Alter
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"c:\on.wav";
myPlayer.Play();
//------------------My Alter
//TODO: Insert Image
Bitmap bmp = new Bitmap(@"C:/1.jpg");
pbImage.Image = bmp;
}
else if (txtReco.Text == "Device One OFF")
{
controller.Speak("Ha ha ha ha ah...");
//------------------My Alter
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"c:\off.wav";
myPlayer.Play();
//------------------My Alter
SerialPortDataReader.SendDataToPort("5");
}
//............................Device 2....................................
else if (txtReco.Text == "Device Two ON")
{
SerialPortDataReader.SendDataToPort("2");
}
else if (txtReco.Text == "Device Two OFF")
{
SerialPortDataReader.SendDataToPort("6");
}
//.....................Device 3-----------------------------------
else if (txtReco.Text == "Device Three ON")
{
SerialPortDataReader.SendDataToPort("3");
}
else if (txtReco.Text == "Device Three OFF")
{
SerialPortDataReader.SendDataToPort("7");
}
-King
Comment