VB.net Voice Recognition???
am 28.11.2007 08:29:00 von SlickuserI am running Windows XP Pro SP 2, have Office 2003, installed SDK 5.1,
Visual Studio 2005 with installed .NET Frame 3.0 (re-distribution package).
System.Speech is in .NET 3.0.
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0
It doesn't contain:
Recognition.DesktopRecognizer
GrammarBuilding.SrgsDocument
GrammarBuilding.SrgsRule
GrammarBuilding.SrgsOneOf
I look at .NET 3.0, they have System.Speech.Recognition.SrgsGrammar.SrgsRule
So my best guess that the namespace/class is a little different?
source link:
http://blogs.msdn.com/robertbrown/archive/2005/06/14/428967. aspx
////////////////code
Imports System.Speech
Public Class Form1
Dim WithEvents reco As New Recognition.DesktopRecognizer
Private Sub SetColor(ByVal color As System.Drawing.Color)
Dim synth As New Synthesis.SpeechSynthesizer
synth.SpeakAsync("setting the back color to " + color.ToString)
Me.BackColor = color
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim gram As New GrammarBuilding.SrgsDocument
Dim colorRule As New GrammarBuilding.SrgsRule("color")
Dim colorsList As New GrammarBuilding.SrgsOneOf("red", "green")
colorRule.Add(colorsList)
gram.Rules.Add(colorRule)
gram.Root = colorRule
reco.LoadGrammar(New Recognition.Grammar(gram))
End Sub
Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As
System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
Select Case e.Result.Text
Case "red"
SetColor(Color.Red)
Case "green"
SetColor(Color.Green)
End Select
End Sub
End Class