2
我有用Visual Basic編寫的用於語音的文本代碼,但它只識別所說的第一個單詞或句子,然後停止識別。我希望它繼續傾聽。我怎樣才能做到這一點?問題是什麼? 這裏是我的代碼現在:Speech在Visual Basic中的文本
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
非常感謝,幫助.. –