Speech Recognition

And more code...

To declare the API put the following code at top of the form code.

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

The core of the sample is basically done, however, as you know, nothing is really done without some style with the GUI. Here is the plan, lets put a button on the form to stop the recognition engine and also to start the engine when its stopped. Also, lets put a label to show the status of the engine and the recognized word.

Place a label on the form. Next place a buttom on the form. Set it's caption property to Enable and then double click on the button to open the code. Place the following code inside:

Private Sub Command1_Click()
    Select Case Command1.Caption
    Case "Disable"
        DirectSR1.Deactivate
        Command1.Caption = "Enable"
        Label1 = "Disabled"
    Case "Enable"
        DirectSR1.Activate
        Command1.Caption = "Disable"
        Label1 = "Ready"
    End Select
End Sub

The code is straight forward. A select case to test the caption of the button. If Disable, Deactivate engine, set button caption to "Enable" and set the label caption to "Disabled". If Enable, Activate engine, set button caption to "Disable" and set the label caption to "Ready". Remember, its label caption and button caption, two different things.

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.

“The question of whether computers can think is just like the question of whether submarines can swim.” - Edsger W. Dijkstra