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

VoicePurgeEvent Property


The VoicePurgeEvent property gets and sets the RecoContext event which will stop the RecoContext's voice and purge the voice queue.

Applications can use the Voice property of a RecoContext object to prompt a user for spoken input. Setting the VoicePurgeEvent to the SRESoundStart event will cause the RecoContext's voice to stop speaking when the user begins speaking.

Syntax

Set: SpeechRecoContext.VoicePurgeEvent = SpeechRecoEvents
Get: SpeechRecoEvents = SpeechRecoContext.VoicePurgeEvent

Parts

SpeechRecoContext
The owning object.
SpeechRecoEvents
Set: A SpeechRecoEvents constant that sets the VoicePurgeEvent.
Get: A SpeechRecoEvents constant that gets the VoicePurgeEvent

Example

The following Visual Basic form code demonstrates the use of the VoicePurgeEvent property. To run this code, create a form with the following controls:

  • Two command buttons, called Command1 and Command2
  • Paste this code into the Declarations section of the form.

    The code creates a RecoContext with a grammar and a voice. The grammar is loaded with a set of rules so that the RecoContext can begin recognition as soon as the grammar is activated. Both command button procedures speak text which contains a bookmark. The RecoContext's bookmark event activates the grammar, which initiates recognition, and the activated RecoContext receives an SRESoundStart event.

    In the Command1_Click procedure, the voice continues speaking after recognition has begun, because the VoicePurgeProperty has been set to zero, and the SRESoundStart event does not effect either the RecoContext or its Voice. In the Command2_Click procedure, the VoicePurgeProperty causes the SRESoundStart event to stop the voice.

    Dim WithEvents Voice As SpVoice
    Dim Context As SpSharedRecoContext
    Dim RecoGrammar As ISpeechRecoGrammar
    
    Const SpeakStr1 = "Recognition is started by the next bookmark."
    Const SpeakStr2 = "<bookmark mark='first'/> but the voice keeps speaking."
                    
    Private Sub Command1_Click()
    
        'Speak with no VoicePurgeEvent
        
        Context.VoicePurgeEvent = 0
        Voice.Speak SpeakStr1, SVSFIsXML + SVSFlagsAsync
        Voice.Speak SpeakStr2, SVSFIsXML + SVSFlagsAsync
        Voice.WaitUntilDone (999)
        RecoGrammar.CmdSetRuleState "", SGDSInactive
        
    End Sub
    
    Private Sub Command2_Click()
    
        'Speak with VoicePurgeEvent on SRESoundStart
        
        Context.VoicePurgeEvent = SRESoundStart
        Voice.Speak SpeakStr1, SVSFIsXML + SVSFlagsAsync
        Voice.Speak SpeakStr2, SVSFIsXML + SVSFlagsAsync
        Voice.WaitUntilDone (999)
        RecoGrammar.CmdSetRuleState "", SGDSInactive
        
    End Sub
    
    Private Sub Form_Load()
    
        Set Context = New SpSharedRecoContext
        Set RecoGrammar = Context.CreateGrammar(123)
        RecoGrammar.CmdLoadFromFile "c:\sol.xml"
        
        'The voice must be
        Set Voice = Context.Voice
        Voice.EventInterests = SVEBookmark + SVEEndInputStream + SVEStartInputStream
        
    End Sub
    
    Private Sub Voice_Bookmark(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Bookmark As String, ByVal BookmarkId As Long)
        
        'after the first bookmark, we activate the grammar,
        'and the SR sound start event should pause TTS voice.
        RecoGrammar.CmdSetRuleState "", SGDSActive  'active the rule
        
    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