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?"
Comments