Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speech To text In Visual Basic

I have the code for speech to text written in Visual Basic, but it recognizes only first word or sentence spoken, then it stops recognizing. I want it to keep listening. How can I do that? What is the problem? Here's the code I have for now:

Imports System.Speech

Public Class Form1

    Public synth As New Speech.Synthesis.SpeechSynthesizer
    Public WithEvents recognizer As New Speech.Recognition.SpeechRecognitionEngine
    Dim gram As New System.Speech.Recognition.DictationGrammar()

    Public Sub GotSpeech(ByVal sender As Object, ByVal phrase As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
        words.Text += phrase.Result.Text & vbNewLine
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        recognizer.LoadGrammar(gram)
        recognizer.SetInputToDefaultAudioDevice()
        recognizer.RecognizeAsync()
    End Sub
End Class
like image 325
Guru Shankar Avatar asked Jul 01 '13 16:07

Guru Shankar


1 Answers

RecognizeAsync() does a single recognition. RecognizeAsync(RecognizeMode.Multiple) will do multiple recognitions.

like image 56
Eric Brown Avatar answered Nov 15 '22 08:11

Eric Brown