Answered by:
How can I use Speech Recognition in VB.net with voice only triggering commands in the VB.net program I made?

Question
-
Hello,
I am using system.speech currently.
I want to use speech recognition to make a program. However, while the program is running, I noticed that some of the commands for windows (like saying "run") would trigger other program functions. Thus, while the VB.net program is running I do not want this to happen. Also, when the computer starts up, I speech to start listening right away rather than me having to say "start listening". How can I do this? Can someone help me do this? I am pretty sure that it is simple. THANKS!
This is my code so far:
Imports System.Speech
Public Class Form1
Dim WithEvents reco As New Recognition.SpeechRecognizer
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 Recognition.SrgsGrammar.SrgsDocument
Dim colorRule As New Recognition.SrgsGrammar.SrgsRule("color")
Dim colorsList As New Recognition.SrgsGrammar.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
Wednesday, August 11, 2010 9:23 PM
Answers
-
Hi There,
Here is an example in VB.NET.
http://www.codeguru.com/csharp/.net/net_general/patterns/article.php/c12941
Cheers,
Mubi | www.mrmubi.com | Mark The Best Replies As Answers!- Marked as answer by Guang-Ming Bian - MSFT Friday, August 20, 2010 7:07 AM
Wednesday, August 18, 2010 5:33 PM
All replies
-
Hi There,
Here is an example in VB.NET.
http://www.codeguru.com/csharp/.net/net_general/patterns/article.php/c12941
Cheers,
Mubi | www.mrmubi.com | Mark The Best Replies As Answers!- Marked as answer by Guang-Ming Bian - MSFT Friday, August 20, 2010 7:07 AM
Wednesday, August 18, 2010 5:33 PM -
Microsoft speech SDK enables a developer to add speech capability in to an application. Speech SDK can be used in either C#, VB.NET language, and applicable to WinForms and WebForms applications.
Here are some tutorial and code samples about Speech Recognition:
1. This document (including demo project) demonstrates how to apply Microsoft Speech 5.1 SDK to Visual Studio .NET.
Text to Speech in VB .NET
http://www.vbdotnetheaven.com/UploadFile/scottlysle/TTSinVB08282006014731AM/TTSinVB.aspx
Figure: Add the Microsoft Speech Object Library Reference
2. Speech sample in VB.NET
http://blogs.msdn.com/robertbrown/archive/2005/06/14/428967.aspx3. Speech Recognition using C# and Speech SDK 5.1
http://www.c-sharpcorner.com/UploadFile/ssrinivas/SpeeechRecognitionusingCSharp11222005054918AM/SpeeechRecognitionusingCSharp.aspx
4. Using MS Agent to write speech recognition applications in C# and. NET
http://www.c-sharpcorner.com/UploadFile/ggaganesh/UsingMSAgentinCSharpPartIISpeechRecognition11232005011052AM/UsingMSAgentinCSharpPartIISpeechRecognition
5. System.Speech.Recognition Namespace
http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx
6. Speech SDK 5.1
http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en
Please remember to mark the replies as answers if they help and unmark them if they provide no helpThursday, August 19, 2010 11:15 AM