![]() |
|
[.NET] Voice Recognition - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Voice Recognition (/showthread.php?tid=3275428) Pages: Pages
1
2
|
Voice Recognition - SIM-1456245 - Feb 21, 2013 This tutorial is about Voice Recognition using "Microsoft Speech SDK 5.1". It will listen for your voice from a microphone, and then it will check if the recorded voice is similar to the given words, if yes then it does something, in this case you say a color and the background color of the form will change accordingly(sorry no MsgBox tutorial today, or at least not here, in this tutorial). 1. Download and install the Microsoft Speech SDK : NOTE: The link is from Microsoft, so I almost can guarantee that it is safe to download. http://www.microsoft.com/en-us/download/details.aspx?id=10121 ![]() 2. First thing is first, we need to make a new project : You need to have Framework 3.0 or 3.5, not 4.0 or 4.5 because this SDK is a bit old. ![]() 3. As you can see, we don't need to add anything to the form. You also don't need to edit any properties. ![]() 4. Lets add the Speech library to our program : Project > Add Reference > .NET (tab) > System.Speech (select from the list). ![]() ![]() 5. And now to the code: First we need to import the SDK to the code : Code Imports System.SpeechNow lets declare the class that we are using here, in this case System.Speech: Code Dim WithEvents listen As New Recognition.SpeechRecognizerHere we set up some stuff, this needs to be in the Form Load sub: Code Dim gram As New Recognition.SrgsGrammar.SrgsDocumentThis is the sub that actually detects when you say something and then it recognizes what you sat. Code Private Sub speech(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles listen.SpeechRecognizedIn the newly created sub add the following code, it will just change the color of the form We are using here a Select Case statement, but you can use If as well. Code Select Case (e.Result.Text)And that was actually it, see a very simple thing. Now double check your code and run it, it should change the color of the form accordingly on that what you say on the microphone. Here is the final code: Code 'Code by: Electroalek <http://www.electroalek.blogspot.com/>, 2013![]() I hope you liked it 😉 [img]http://electroalek.comoj.com/ElectroalekLogo.gif[/img] * - iDuL - Feb 21, 2013 Looks like an incredible Tutorial, thank you for the contribution!! * - tweety - Feb 21, 2013 (Feb 21, 2013 10:59 AM)Electroalek Wrote: Now lets declare the the recognition sub : That's not a sub, it's a declaration of the class your using. Also you didn't really explain what your doing to be honest, nevertheless, decent tutorial.. Just about. * - SIM-1456245 - Feb 21, 2013 (Feb 21, 2013 11:09 AM)Tweety. Wrote: That's not a sub, it's a declaration of the class your using. Ooops, mistake. Fixed. You don't really need to explain much more. Please replay to keep this thread up. * - XvI Beta IvX - Feb 21, 2013 I will test this out later. Thanks /thirtyfivechar * - Cait Snow - Feb 21, 2013 Great tutorial, OP! Thanks for sharing this to the community! PunkoHead 🤝 * - SIM-1456245 - Feb 21, 2013 Thanks a lot :) Tomorrow I will post a tutorial for a speech program(the program says something to you). And later on I will combine them together and make something cool, because this SDK is very cool. And I just realized that Microsoft Speech SDK 5.1 is a bit outdated. There are newer versions of it, maybe in the near future I will make something else. * - Foursenal - Feb 21, 2013 Very detailed tutorial. Easy to go through as well. Nice tutorial. * - Meteen - Feb 22, 2013 Got an error: "System.PlatformNotSupportedException" on this line: "listen.LoadGrammar(New Recognition.Grammar(gram))" Please help? * - Support. - Feb 22, 2013 I like this but I've found SpeechRecognitionEngine better with bigger projects. Would make a good tut with good explaining of Grammar, GrammarBuilder, Choices, Confidence & how easy it is to get devices like your phone to work with it sending wav recordings. * - x2SiKJaYzZ - Feb 22, 2013 Very HQ tutorial , well explained and not that much to read , and with photo's haha. thanks * - Xyzo - Feb 22, 2013 Nice tutorial, will try it out now! :) * - 4RG0S - Feb 22, 2013 Thanks for the Tut, looks great. I will try it :) * - SIM-1456245 - Feb 22, 2013 (Feb 22, 2013 05:46 AM)Meteen Wrote: Got an error: "System.PlatformNotSupportedException" on this line: "listen.LoadGrammar(New Recognition.Grammar(gram))" LOL, I had the same error, but I fixed it. The funny thing here is that I don't remember how. If I remember I will post. Have you installed all of the files from the SDK ? Have you done everything as it says ? Try downloading and installing this:http://activex.microsoft.com/activex/controls/agent2/tv_enua.exe (This is not a virus, it can solve your problem. I downloaded it, it is clean, but if you don't trust me don't download it. Not my server, Microsoft website. * - Debroski - Feb 23, 2013 Instead of having a huge switch case, why not just Code Me.BackColor = Color.FromName(e.Result.Text)so you don't have to continuously add as you want more colors. |