Dynamically Building Custom Grammars

One of my favorite features of System.Speech is the ability to generate custom grammars dynamically. As I've mentioned earler, this took about 50 lines of code in SAPI 5.1. The System.Speech team has included some very nice coarse-grained methods to accomplish this same task in just four lines of code:

Protected WithEvents reco As SpeechRecognizer
Public
Sub LoadGrammar(ByVal options As List(Of String))
    Dim choices As New Choices(options.ToArray)
    Dim gb As New GrammarBuilder(choices)
    Dim g As New Grammar(gb)
    reco.LoadGrammar(g)
End Sub
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted @ Thursday, May 17, 2007 1:34 PM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: