Question Safely stop and start a Speech engine

phil1950

New member
Joined
Jan 2, 2015
Messages
4
Programming Experience
1-3
My purpose is to Stop the SAPI Speech engine (called "MainEngine") when I open a secondary .ShowDialog window, and Start it again when i close the .ShowDialog window.

VB.NET:
    Dim Completed a sBoolean

    Private Sub TestCommandsToolStripMenuItem_Click(sender As System.Object, _
                                e As System.EventArgs) Handles TestCommandsToolStripMenuItem.Click

        Completed = False

        'I stop the engine...
        MainEngine.RecognizeAsyncCancel()

        Do Until Completed 
             Sleep(200)
            Application.DoEvents()
            Debug.Print("waiting to complete...")
        Loop
        Debug.Print("completed = true!!")
      
        FrmTestCommands.ShowDialog()
       
        'I start the engine again
        MainEngine.RecognizeAsync(RecognizeMode.Multiple)

    End Sub

    Private Sub Speech_Completed(ByVal sender As Object, ByVal e As RecognizeCompletedEventArgs) Handles MainEngine.RecognizeCompleted
 
       Completed = True
 
    End Sub

Well... I don't show the FrmTestCommand window until I am not sure that any recognition is completed.

But........... every time I close the window the code Stops with a error at the line:

VB.NET:
MainEngine.RecognizeAsync(RecognizeMode.Multiple)

'Cannot perform this operation while the recognizer is doing recognition' :blue:

Is doing a recognition??? But If I have checked before to open the window!!! :erm:
 
Back
Top