Hey, i've managed to implement this in c# and visual studio. Look for the SpeechRecognitionEngine class (SpeechRecognitionEngine Class (System.Speech.Recognition) | Microsoft Learn). It uses the built-in windows 7 speech recognition feature and any usb mike connected to the computer.
Something like this:
class SpeechRecConsole
{
static void Main(string[] args)
{
// Create an in-process speech recognizer for the en-US locale.
using (
SpeechRecognitionEngine recognizer =
new SpeechRecognitionEngine(
new System.Globalization.CultureInfo("en-US")))
{
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());
// Add a handler for the speech recognized event.
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();
// Start asynchronous, continuous speech recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple);
// Keep the console window open.
while (true)
{
Console.ReadLine();
}
}
}
// Handle the SpeechRecognized event.
static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text.ToLower() == "lights on") {
SerialPort port = new SerialPort("COM6", 9600);
port.Open();
port.Write("lights on!!");
port.Close();
}
}