[英]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.我有用 Visual Basic 编写的语音到文本的代码,但它只能识别说出的第一个单词或句子,然后停止识别。 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()执行单个识别。 RecognizeAsync(RecognizeMode.Multiple) will do multiple recognitions. RecognizeAsync(RecognizeMode.Multiple)会做多次识别。
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
word.Text += phrase.Result.Text + ""
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(Recognition.RecognizeMode.Multiple)
End Sub
End Class
All Problems cleared :)所有问题都清除了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.