Friday The Rabbi Slept Late..

Hey all.
So, another hectic week of tests but its been pretty okay..not too much sweat :-)
So, preparations for Engineering Week are underway...magazine launch, customized tee-shirts and Auditions for the exhibition projects. And I hear I'm to be a judge! But only if I behave..
Like before, categories include software, embedded systems, game design and pretty much anything that sounds remotely techy. I'm actually looking forward to this. I'm pretty sure we're going to see some really wild projects. Will you keep you posted as events unfold.
Meanwhile, I'm still waiting for comments regarding the Intro to AVRs series. Just drop a line (and leave your email address) in the comments and I'll email it to you.
And as promised, here's what we need to begin speech recognition in C#.NET 4.0 (should work from dotNet Framework 3.5 I think):

  • A computer running Visual C# Express 2010 or Visual Studio 2010
  • A working microphone (the integrated mic array on most laptops works ok for this

Here we go:
  1. Fire up your copy of Visual Studio/Visual C# Express
  2. Open a new project. Let's start with Console Application for now.
  3. Give it a suitable name.
  4. Now, to the right of the screen is the Solution Explorer. If that isn't there, then click the "View" menu item on the menu bar at the top of the screen and select "Solution Explorer".
  5. Your project files should be listed in the pane that appears.
  6. Right-click the Project folder (the one below the Solution 'xxx' item) and click "Add Reference"
  7. Cross your fingers :-)
  8. Select the .NET tab in the window that appears, and see if you can locate System.Speech. If you can, say a prayer of thanks :-)
  9. Double-click that.
  10. Returning to the Program.cs file, add "Using System.Speech.Recognition" to the using directives at the top of the file.
  11. Now that that's done, enter/copy-and-paste the code from the link below into your file:
C# Sample Speech Recognition Code

To expedite the process, delete your copy of class Program{..} and replace it with the code above.
To test it out, just run the program and assuming you did everything correctly, you should be able to say the words "Hello" and "Hi" and "exit" (this will close the program though) and see them appear in the console window.
To recognize more or different words, change the contents of the array used in the _eng.LoadGrammar(..) method. As you can see, my array contains only "Hello", "Hi" and "exit". You may add more words or replace my words with any of your choosing. But please leave "exit" in there so you can show someone how cool (read: nerdy) you are and can close a program by saying "exit" to your computer.
Go forth and have fun!
Ps1: Note that the case of words as specified in the array affects the word that will be shown in the console window. For example if in the array I had a word, say "Monkey", and then I said the word "Monkey", the computer would display "Monkey" in the console window. If I'd stored "MONKEY" in the array and said "Monkey", then "MONKEY" would've appeared in the console window. Hence, if you experiment with voice commands, take note of the case of words in the array.
Drop a line if you've any comments or questions. Hopefully if I have the time, my next post will explain what the heck just happened here :-)
Ps2: You'll be seeing many more weird post titles..but this is the name of a rather interesting novel. If you have the time (and are a bookworm) give it a shot. You may like it.


Comments

Popular posts from this blog

Getting Started with Logic Analyzers and Pulseview

Bitbanging SPI on the Raspberry Pi (via spi-gpio)

Enabling SPI1 on the Raspberry Pi B+/Zero/2/3