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: ISpeechRecoContext Events

RecognitionForOtherContext Event


The RecognitionForOtherContext event occurs when the recognition context encounters a recognition result that belongs to another recognition context.

A RecognitionForOtherContext event indicates a successful recognition but that another application currently running claims it. This is a useful event if multiple shared instances are running at the same time. If the owning application cannot use or claim the recognition, the recognition event is sent to another context that can claim it. In that case, the recognition context claiming it receives the Recognition event and all other contexts receive a RecognitionForOtherContext event.

This event is more applicable to command and control grammars than to dictation. For example, the current recognition context returns a recognition result such as "file." If that recognition context does not have the word "file" in its active grammar, the speech recognition engine searches all the other open and active grammars, even if they belong to other applications. If another context has the word "file" available, the recognition event is sent there instead.

If other recognition contexts should not receive recognition events, because the window or application is not the current one for example, change state of those contexts using ISpeechRecoContext.State.


SpeechRecoContext.RecognitionForOtherContext(
     StreamNumber As Long,
     StreamPosition As Variant
)

Parameters

StreamNumber
Specifies the stream number.
StreamPosition
Specifies the position within the stream.

Remarks

There are three possible results from a recognition attempt:

  1. The first, a Recognition event is the result of a successful recognition. This event indicates that the word or phrase was matched to elements in an open grammar, and that the match had a sufficiently high confidence rating.
  2. The second possible result is a FalseRecognition event. This event indicates that speech was detected but it either did not match words in an open grammar, or the match did not merit a high enough confidence rating. The recognition result returned with a FalseRecognition is still valid and contains all the information of a Recognition event, including the text.
  3. The third possible result is RecognitionForOtherContext event. This event indicates a successful recognition result, but a different recognition context was used to match words. SAPI attempts to match the word or phrase in the current recognition context. However, if no match is possible (perhaps the recognition context is currently inactive, the rule is inactive, or the word or phrase is simply not included in the grammar), SAPI then attempts to find a match in other recognition contexts. If a match is found in another application whose grammar is available, the Recognition event is sent to that application instead and the current application receives a RecognitionForOtherContext event.

Example

The following Visual Basic form code demonstrates the use of the RecognitionForOtherContext event. The application displays the text of a successful recognition or indicates that the recognition belongs to another application.

The setup for this scenario is somewhat complex. To duplicate two applications running command and control instances, the following code must be compiled into two different applications. Create a form with the following controls:

  • Two labels called Label1 and Label2
  • Paste this code into the Declarations section of the form.

    The Form_Load procedure creates and activates a dictation grammar. Create the grammar file sol.xml and use the XML code from the RecoCC sample application. The second application should open sol2.xml. This will be the only modification.

    The xml files have only one phrase each that can be recognized. Run both applications. Now speak, "new game." The first application gets the recognition while the second application displays "For another context." Now speak "file game" and the situation reverses. These applications will assign and display commands properly regardless of the front-most application.

    Public WithEvents RC As SpSharedRecoContext
    Public myGrammar As ISpeechRecoGrammar
    
    Private Sub Form_Load()
        Set RC = New SpSharedRecoContext
        
        Set myGrammar = RC.CreateGrammar
        myGrammar.CmdLoadFromFile "sol.xml", SLODynamic
        myGrammar.CmdSetRuleIdState 0, SGDSActive
    End Sub
    
    Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
        Label1.Caption = Result.PhraseInfo.GetText
        Label4.Caption = ""
    End Sub
    
    Private Sub RC_RecognitionForOtherContext(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
        Label4.Caption = "For another context"
        Label1.Caption = ""
    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