Types of Automation Events (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4

Types of Automation Events


Chances are you have already have used events and may not have known it. If your application has a command button, (a common interface tool) events generate the action for it. For example, clicking the command button when the application is running usually initiates a certain action. Clicking the button sends out a button Click event. However the programmer had to write the code for the action and chances are that code is contained in a procedure perhaps called Command1_click. The word click indicates that it is an action. This is an example of a user-initiated event; that is, the user must click the button to perform its action.

There are other examples of user initiated events. For example, the first time a form is displayed, a Form_Load event is generated. Perhaps not as common as a Command_Click event, the Form_Load event initializes information on a particular form. Though still considered to be a user-initiated event, the Form_Load event may or may not be a direct result of user interaction. You could have chosen a menu item that displays a new dialog box (and hence a form). Or perhaps the form could also be the result of an error handling routine initiated by an activity you caused indirectly. Regardless of what caused the event, the application can have code to handle the situation. The particular event could be ignored completely, in which case you do not need code for the event.

Background-generated events work in a similar fashion as user-initiated events. The difference is the background-generated event may be fired at anytime and is not the direct result of user interaction, at least not in the same way as clicking a button. SAPI events fall into this category. For either speech recognition or text-to-speech, SAPI returns events to the application. The application then addresses or ignores the event. Furthermore, the application can selectively reject certain types of events if there is no need to work with them. Speech recognition returns a spectrum of events from noise interference prohibiting recognition to notifications (successful or otherwise). SAPI returns additional events for activities such as the start and end of media streams, or the start or end of sound input, which are required for potential recognition attempts. Text-to-speech has events related to it as well.

Speech Recognition Events

The enumeration SpeechRecoEvents contains the speech recognition events. Upon review of these events, many appear logical and obvious. The speech recognition event SRERecognition is returned upon a successful recognition; SREPhraseStart handles the start of a new phrase. Other events are less obvious and have specialized functions. For example, SRERecoOtherContext indicates that a successful recognition occurred but cannot be associated with the current recognizer context. For a detailed explanation of events and some situations where they might be used, please see the appropriate SAPI documentation.

For a complete list of speech recognition events see ISpeechRecoContext (Events)

Text-To-Speech Events

The enumeration SpeechVoiceEvents contains all the text-to-speech events. Similar to recognition events, some voice events may seem obvious, and others less so. See the appropriate SAPI documentation.

For a complete list of text-to-speech events see SpVoice (Events)

Exploring Types of Events

In general, there are two ways to discover what events are available. First, the application programming interface (API) reference lists them and describes their use in detail. In order to gain a better understanding of any event or method, it is important to review those event topics first.

A second method is to view the Object browser from within Visual Basic. Click F2 to display the browser or select View->Object Browser from the menu. Events, like other items, have an associated icon, in this case a lightning bolt.

In any case, SAPI has only two interfaces with events associated with them: