CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

Interface: ISpeechRecoGrammar

CmdLoadFromResource Method


The CmdLoadFromResource method loads a command and control grammar from a Win32 resource.


ISpeechRecoGrammar.CmdLoadFromResource(
     hModule As Long,
     ResourceName As Variant,
     ResourceType As Variant,
     LanguageId As Long,
     [LoadOption As SpeechLoadOption = SLOStatic]
)

Parameters

hModule
Specifies the hModule.
ResourceName
Specifies the ResourceName.
ResourceType
Specifies the ResourceType.
LanguageId
Specifies the LanguageId.
LoadOption
[Optional] Specifies whether the grammar is to be loaded for static or dynamic use. The default is static.

Return Value

None.


Remarks

The grammar resource must be a compiled SAPI 5 binary version of a context-free grammar (CFG).

Using this method will unload the currently loaded CFG or proprietary grammar.

Example

The following Visual Basic form code demonstrates the use of the CmdLoadFromResource method. Before attempting to run this code, you must:

The Form_Load procedure creates a grammar object and loads it with the compiled Solitaire grammar contained in the DLL. There are no controls on this form; simply speak into your microphone. Phrases like "Move the red ten" or "Play the queen of hearts" will be recognized.


Option Explicit

Dim WithEvents C As SpSharedRecoContext
Dim G As ISpeechRecoGrammar
Dim hndRes As Long

' Change this constant to match the path 
' of the SpeechDocs DLL on your machine!

Const lib As String = "C:\SpeechDocs.dll"

Const resType As String = "CFGGRAMMAR"
Const resName  As Long = 101
Const langID As Long = &H409

Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
    (ByVal lpLibFileName As String) As Long

Private Sub Form_Load()
    Set C = New SpSharedRecoContext
    Set G = C.CreateGrammar
    
    ' Obtain a handle to the executable holding the grammar as a resource
    hndRes = LoadLibrary(lib)
    
    ' Load the grammar from the resource
    G.CmdLoadFromResource hndRes, resName, resType, langID, SLOStatic
    
    ' Set all DefaultToActive rules active
    ' NOTE: The solitaire grammar happens to have DefaultToActive rules
    ' which is why we can activate them this way.
    G.CmdSetRuleState "", SGDSActive

End Sub

Private Sub C_FalseRecognition( _
        ByVal StreamNumber As Long, _
        ByVal StreamPosition As Variant, _
        ByVal result As SpeechLib.ISpeechRecoResult _
    )
    MsgBox "(not recognized!)"
End Sub

Private Sub C_Recognition( _
        ByVal StreamNumber As Long, _
        ByVal StreamPosition As Variant, _
        ByVal RecognitionType As SpeechLib.SpeechRecognitionType, _
        ByVal result As SpeechLib.ISpeechRecoResult _
    )
    MsgBox result.PhraseInfo.GetText
End Sub


You are reading help file online using chmlib.com

If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web