Evidently Microsoft ninjaed a new assembly into the .NET framework with the 3.0 release called System.Speech.dll. If adding speech recognition or speech synthesis to your applications sounds like fun, read on.
Step 1: Train your computer
The first step for meaningful speech recognition is to tell your computer who is in charge. Open up the Control Panel, navigate to Ease of Access, Speech Recognition options, then select Training. The process of training will take about 10 minutes and is pretty tedious, but the results are well worth it.
Step 2: Write some F# code
This is the easy part.
#light open System open System.Speech.Recognition let sp = new SpeechRecognitionEngine() let defaultDictationGrammar = new DictationGrammar() defaultDictationGrammar.Name <- "Default Dictation" defaultDictationGrammar.Enabled <- true sp.LoadGrammar(defaultDictationGrammar) sp.SetInputToDefaultAudioDevice() sp.RecognizeAsync(RecognizeMode.Multiple) sp.SpeechRecognized.Add(fun args -> printfn "Recognized [%f] '%s'" args.Result.Confidence args.Result.Text) printfn ("(Just start talking. Press any key to quit.)") Console.ReadKey(true) |> ignore
Step 3: Profit
Early results look promising, although it doesn’t handle early 90’s rap very well…