Using Speech Recognition and Text to Speech

Page 2 of 3
  1. Introduction
  2. Initializing the Speech Recognition
  3. Hello Computer!

Initializing the Speech Recognition

The next step is to add the code. This code will load a string called SpeechGrammer into its grammer. The control only understands the grammer you put into it, if put the whole English Dictionary into it it would understand every word (although it might get some of the words confused). If you only put the word "the" into its grammer that's the only word it will understand. Add all of this code except the declaration of the constant  (which you should add to the General Declarations) to the Load event of the form:

Const YOURNAME = "Alex  'You can replace this with your name
 	 
 	 Dim SpeechGrammer As String
 	 
 	 SpeechGrammer = "[Grammar]" & vbCrLf & _
 	                                	 "langid = 1033" & vbCrLf & _
 	                                	 "type=cfg" & vbCrLf & _
 	                                	 "[<Start>]" & vbCrLf & _
 	                                	 "<start>=" & YOURNAME & vbCrLf & _
 	                                	 "<start>=What year is it?"
 	 
 	 vcrVoice.GrammarFromString SpeechGrammer
 	 vcrVoice.Activate
 	 
 	 spkSpeak.Speak "Hello. What is your name?" 

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“God could create the world in six days because he didn't have to make it compatible with the previous version.”