Share via


Speech Recognition is gun and easy!

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. 

image

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...

image

image

Comments

  • Anonymous
    December 30, 2008
    The comment has been removed

  • Anonymous
    December 31, 2008
    I was cracking up at "Turn off the lights and Otewell." And then the machine became self-aware... brilliant. ... man it's been a long time since I've Otewelled.

  • Anonymous
    December 31, 2008
    Just linked you. Thanks for keeping the F# related articles coming: http://mostrecent.net/fsharp/

  • Anonymous
    January 16, 2009
    This week’s theme is functional programming.&#160; Included are discussions on Software Transactional