R
ryguy72
Guest
I ran this code; got no errors, but nothing works either . . . .
Imports System
Imports System.Speech.Recognition
Public Class Form1
Dim WithEvents recognizer As SpeechRecognitionEngine
Dim Allow As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Initialize an in-process speech recognition engine and set its input.
recognizer = New SpeechRecognitionEngine()
recognizer.SetInputToDefaultAudioDevice()
Create a dictation grammar.
Dim dictation As Grammar = New DictationGrammar()
dictation.Name = "Dictation"
recognizer.LoadGrammarAsync(dictation)
Start asynchronous, continuous recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple)
End Sub
Private Sub recognizer_LoadGrammarCompleted(sender As Object, e As LoadGrammarCompletedEventArgs) Handles recognizer.LoadGrammarCompleted
Dim grammarName As String = e.Grammar.Name
Dim grammarLoaded As Boolean = e.Grammar.Loaded
If e.[Error] IsNot Nothing Then
Add exception handling code here.
Label2.Text = "LoadGrammar for " & grammarName & " failed with a " & e.[Error].[GetType]().Name & "."
End If
Label2.Text = ("Grammar " & grammarName & " " & If((grammarLoaded), "Is", "Is Not") & " loaded.")
End Sub
Handle the SpeechRecognized event.
Private Sub recognizer_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
If Allow = 1 Then
TextBox1.AppendText(e.Result.Text)
End If
End Sub
Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(32) Then
e.Handled = True
End If
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As EventArgs) Handles TextBox1.KeyDown
If Keys.Space Then
Allow = 1
End If
End Sub
Private Sub TextBox1_KeyUp(sender As Object, e As EventArgs) Handles TextBox1.KeyUp
If Keys.Space Then
Allow = 0
End If
End Sub
End Class
I have my headset plugged in, and Im speaking into the microphone, but nothing shows up in the TextBox. I thought, when I speak into the microphone, the text would appear in the TextBox.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.
Continue reading...
Imports System
Imports System.Speech.Recognition
Public Class Form1
Dim WithEvents recognizer As SpeechRecognitionEngine
Dim Allow As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Initialize an in-process speech recognition engine and set its input.
recognizer = New SpeechRecognitionEngine()
recognizer.SetInputToDefaultAudioDevice()
Create a dictation grammar.
Dim dictation As Grammar = New DictationGrammar()
dictation.Name = "Dictation"
recognizer.LoadGrammarAsync(dictation)
Start asynchronous, continuous recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple)
End Sub
Private Sub recognizer_LoadGrammarCompleted(sender As Object, e As LoadGrammarCompletedEventArgs) Handles recognizer.LoadGrammarCompleted
Dim grammarName As String = e.Grammar.Name
Dim grammarLoaded As Boolean = e.Grammar.Loaded
If e.[Error] IsNot Nothing Then
Add exception handling code here.
Label2.Text = "LoadGrammar for " & grammarName & " failed with a " & e.[Error].[GetType]().Name & "."
End If
Label2.Text = ("Grammar " & grammarName & " " & If((grammarLoaded), "Is", "Is Not") & " loaded.")
End Sub
Handle the SpeechRecognized event.
Private Sub recognizer_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
If Allow = 1 Then
TextBox1.AppendText(e.Result.Text)
End If
End Sub
Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(32) Then
e.Handled = True
End If
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As EventArgs) Handles TextBox1.KeyDown
If Keys.Space Then
Allow = 1
End If
End Sub
Private Sub TextBox1_KeyUp(sender As Object, e As EventArgs) Handles TextBox1.KeyUp
If Keys.Space Then
Allow = 0
End If
End Sub
End Class
I have my headset plugged in, and Im speaking into the microphone, but nothing shows up in the TextBox. I thought, when I speak into the microphone, the text would appear in the TextBox.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.
Continue reading...