loading

Step 4:

As we open a Visual C# IDE, i.e. Visual Studio 2010, we create an new project in Visual C#, using windows form.

Using the properties panel and the toolbox we make the form as we like it, and we just put a button that will enable monitoring and some labels guiding the user to control the program.

To make the communication PC-Arduino possible we must drag&drop from the toolbox, a serialPort object and set the correct port from its properties.

Also we must add the reference of speech recognition to our project:
Project > Add Reference. Add there "System.Speech".

Ending with the UI designing, it's time to get things working!
Double click the button we made and put the following code in the event:

private void button1_Click(object sender, EventArgs e)
        {
            rec = new SpeechRecognitionEngine();
            rec.SetInputToDefaultAudioDevice();
            // Specify the exact words that the engine will try to recognize.
            Choices choices = new Choices("help", "abort");
            // Create and load a Grammar using the Choices above.
            GrammarBuilder grBuilder = new GrammarBuilder(choices);
            Grammar grammar = new Grammar(grBuilder);
            rec.LoadGrammar(grammar);
          
            // Create the event handler
          
            if (button1.Text == "Disable" )
            {
                button1.Text = "Enable";
                label5.Text = "Unsecured";
            }
            else
            {
                rec.SpeechRecognized += newEventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized);
                rec.RecognizeAsync(RecognizeMode.Multiple);
                button1.Text = "Disable";
                label5.Text = "Secured";
            }


void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {       
            foreach (RecognizedWordUnit word in e.Result.Words)
            {
                switch (word.Text)
                {
                    case "help":
                        if (button1.Text == "Disable")
                        {
                            label6.Text = "help";
                            USB.Write("1");
                        }
                        break;
                    case "abort":
                        if (button1.Text == "Disable")
                        {
                            label6.Text = "abort";
                            USB.Write("0");
                        }
                        break;
                    default:
                        USB.Write("1");
                        break;
                }
            }
        }


So... this flashes an SOS when it hears the word &quot;help&quot;, but I don't see &quot;microphone&quot; on your hardware list.<br><br>Is there a microphone built into the Arduino board already, or is it the computer's microphone you're using?<br><br><sub>(PS, I think you need to check the timings of your SOS, it doesn't look very clear to me.)</sub>
Right, it uses the computer microphone and through the program we have made, using Microsoft Speech Recognition, we send &quot;1&quot; or &quot;0&quot; to the serial port.<br><br>The timings are up to you, we chose 250ms and 500ms just to make a discrete signal for short and long Morse code.
Are you going to try for a portable, self-contained model?<br><br>You could add a speaker to sound three sharp whistle-blasts as well, the standard hill-walking distress signal.<br><br><sub>(And I meant that the sequences are running together, obscuring the code.)</sub>
This is a little hard to be done, because we use speech recognition library and we are sending data via the serial port. If you are suggesting that we could use a &quot;built-in microphone&quot; on the Arduino, i don't know if it is possible to execute the C# code from an SD-card (Arduino Shield). <br>The main idea of the project was to have the Arduino communicate with the pc, using Speech Recognition. :)

About This Instructable

1,803views

2favorites

License:

More by Brainstorms:SOS Daemon with Voice Recognition!
Add instructable to: