You are reading help file online using chmlib.com
|
Interface: ISpeechRecoContext
The Bookmark method sets a bookmark within the current recognition stream.
A bookmark relates an audio stream position with an occurrence significant to the application. The speech recognition (SR) engine has a latency period between the speech and the recognition. This latency may be caused by a long speech period (the engine must have all the phrase before processing it) or other events may already be queued and the engine must finishing process those first. However, during that latent period, the user or application may continue operations (such as moving the mouse or speaking). As a result, the condition of the application may be different when the recognition comes back than it was when recognition was initiated. A bookmark allows the application to mark or record a condition of the application to a particular recognition attempt.
Bookmark is a convenient alternative to polling the engine for stream position (see ISpeechRecognizer.Status). A Bookmark event is returned when the bookmark has been processed by the engine. See ISpeechRecoContext.Bookmark for further information.
SpeechRecoContext.Bookmark(
Options As SpeechBookmarkOptions,
StreamPos As Variant,
BookmarkId As Variant
)
None.
This code snippet demonstrates initiation of a Bookmark event at the start of the each speech recognition stream by setting the StreamPos to zero. Each event is identified with BookmarkId of "10" and that value may be used inside the event for additional processing. Additional events may be indicated by adding new Bookmarks. After the grammar is closed, a Bookmark event with BookmarkId of "99" is sent.
This example assumes valid speech processing support and that FileName points to a valid grammar file.
Dim SharedRecognizer As Object
Dim WithEvents SharedReco As SpSharedRecoContext
Dim RecoGrammar As Object
Set RecoGrammar = Context.CreateGrammar(123)
RecoGrammar.CmdLoadFromFile FileName
'This bookmark is initiated before speech recognition
SharedReco.Bookmark SBONone, 0, "10"
'Speech processing code here
RecoGrammar.CmdSetRuleState "", SGDSInactive
SharedReco.Bookmark SBONone, 0, "99"
The corresponding Bookmark could be defined as this. This allows further refinement of the processing after the event occurs. Notice BookmarkId is converted to a numeric value.
Private Sub InProcRecoContext_Bookmark(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal BookmarkId As Variant, ByVal Options As SpeechLib.SpeechBookmarkOptions)
If BookmarkId = 10 Then
'Some processing code goes here
ElseIf BookmarkId = 99 Then
'Some processing code goes here
End If
End Sub
You are reading help file online using chmlib.com
|