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

Print | posted on Thursday, May 17, 2007 9:34 AM

Feedback

No comments posted yet.

Your comment:





 
Please add 1 and 8 and type the answer here:

Copyright © Jeff Certain

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski