You are reading help file online using chmlib.com
|
Interface: ISpeechRecognizer
The GetRecognizers method returns a selection of SpeechRecognizer objects in the speech configuration database.
Recognizers are stored in the speech configuration database as a series of tokens, with each token representing one recognizer (also called a speech recognition engine). GetRecognizers retrieves all available recognizer tokens and returns the in a list as an ISpeechObjectTokens object. Additional or more detailed information about the tokens is available in methods associated with ISpeechObjectTokens. If no recognizers match the criteria, GetRecognizers returns an empty selection, that is, an ISpeechObjectTokens collection with an ISpeechObjectTokens::Count property of zero.
The recognizer token search may be further refined by using the RequiredAttributes and OptionalAttributes search attributes. Only token matching the specified search attributes are returned. If no search attributes are offered, all tokens are returned.
See Object Tokens and Registry Settings White Paper for a list of SAPI 5-defined attributes.
ISpeechRecognizer.GetRecognizers(
[RequiredAttributes As String = ""],
[OptionalAttributes As String = ""]
) As ISpeechObjectTokens
A ISpeechObjectTokens collection containing tokens for the selected recognizers.
The format of selection criteria may either be Value or "Attribute = Value". Values may be excluded by "Attribute != Value".
This code sample demonstrates the GetRecognizers method. After creating an instance for a recognizer, GetRecognizers polls the computer for available recognizer tokens, which represent individual engines. The results are displayed.
To run this code, create a form with the following control:
Paste this code into the Declarations section of the form.
The Form_Load procedure creates the recognizer.
Private Sub Form_Load()
Dim SharedRecognizer As SpSharedRecognizer
Set SharedRecognizer = CreateObject("SAPI.SpSharedRecognizer")
Dim theRecognizers As ISpeechObjectTokens
Set theRecognizers = SharedRecognizer.GetRecognizers
Dim i As Long
Dim recoObject As SpObjectToken
Label1.Caption = ""
For i = 0 To theRecognizers.Count - 1
Set recoObject = theRecognizers.Item(i)
Label1.Caption = Label1.Caption & recoObject.GetDescription & vbCrLf
Next i
End Sub
The next example is similar to the first except that the "Telephony" attribute is required. Any recognizer token returned must be able to support telephony.
Private Sub Form_Load()
Dim SharedRecognizer As SpSharedRecognizer
Set SharedRecognizer = CreateObject("SAPI.SpSharedRecognizer")
Dim theRecognizers As ISpeechObjectTokens
Set theRecognizers = SharedRecognizer.GetRecognizers("Telephony")
Dim i As Long
Dim recoObject As SpObjectToken
Label1.Caption = ""
For i = 0 To theRecognizers.Count - 1
Set recoObject = theRecognizers.Item(i)
Label1.Caption = Label1.Caption & recoObject.GetDescription & vbCrLf
Next i
End Sub
You are reading help file online using chmlib.com
|