Speech Recognition

The Basics

Now in the code window of the form with the DirectSR, select DirectSR1 on the top left pull down menu. Pull down the menu to the right of that and you can see the various methods, events and properties the DirectSR component provides. In this article the one DirectSR we will concern ourselves with is the PhraseFinish procedure. This is the procedure that will be called by DirectSR when it has finish processing a voice command.



(Pic. 3) With the Code Window Select DirectSR1 in top left pull down menu and select PhraseFinish in the top right pull down menu.

When you select PhraseFinish, the code that is put in place for you is the following:

Private Sub DirectSR1_PhraseFinish(ByVal flags As Long, _
ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, _
ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long)
'''' End Code

There's a lot of parameters you say. But don't be frightened! We only need to be concerned with the Phrase parameter; this will contain the recognized word that was processed by the DirectSR engine.

Now that we got that set up, we will have to input a set of words for the Speech Engine to recognize. The job is very simple, we just feed in the set of words during the Form's Onload procedure. But how do we do that you ask? Simple, DirectSR have two ways for you to feed the words in, they are DirectSR1.GrammarFromString which takes in a String variable that contains the words and DirectSR1.GrammarFromFile which takes in a file path to a file that contains the words in a text file. Simple enough? The method we will use is DirectSR1.GrammarFromString because this provides the greatest flexibility because you can dynamically add additional words to the engine and still add words in from a file like DirectSR1.GrammarFromFile by putting the text in the file into a variable.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra