VB.net Voice Recognition???

S

Slickuser

I 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top