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
RecognizeAsync() does a single recognition. RecognizeAsync(RecognizeMode.Multiple) will do multiple recognitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With