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: ISpeechRecognizer

State Property


The State property returns the current state of the recognition engine.

The recognition engine may be in one of several states of audio processing. If active, the engine receives audio data and processes it. Likewise, if inactive, neither audio data nor additional processing takes place. See the enumeration SpeechRecognizerState for complete details of the states.


Syntax

Set: SpeechRecognizer.State = SpeechRecognizerState
Get: SpeechRecognizerState = SpeechRecognizer.State

Parts

SpeechRecognizer
The owning object.
SpeechRecognizerState
Set: A SpeechRecognizerState variable that sets the property.
Get: A SpeechRecognizerState variable that gets the property.

Example

This code sample demonstrates the State method. After creating an instance for a recognizer, State retrieves the processing state about the recognizer. The recognizer may be turned on and off with the button and the current state will be displayed afterward. Speech will be recognized and displayed but only when the engine is active.

To run this code, create a form with the following controls:

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

    The Form_Load procedure creates the recognizer. Click the button to toggle the engine on and off. Speaking while the engine is active will display the text in the second label.

    Public WithEvents RC As SpSharedRecoContext
    Public myGrammar As ISpeechRecoGrammar
    
    Private Sub Command1_Click()
        If Label1.Caption = 1 Then
            RC.Recognizer.State = SRSInactive
        Else
            RC.Recognizer.State = SRSActive
        End If
        
        ShowState
        RenameButton
    End Sub
    
    Private Sub Form_Load()
        Set RC = New SpSharedRecoContext
        
        Set myGrammar = RC.CreateGrammar
        myGrammar.DictationSetState SGDSActive
        
        Dim recoState As SpeechRecognizerState
        recoState = RC.Recognizer.State
        
        ShowState
        RenameButton
    End Sub
    
    Private Function RenameButton()
        If Label1.Caption = 1 Then
            Command1.Caption = "Turn Off Engine"
        Else
            Command1.Caption = "Turn On Engine"
        End If
    End Function
    
    Private Function ShowState()
        Dim engineState As SpeechRecognizerState
        Label1.Caption = RC.Recognizer.State
    End Function
    
    Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
        Label2.Caption = 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