|
| Vista VB6 InProc Problem Loading Grammar |
 |
Wed, 19 Mar 2008 07:04:50 -070 |
Hi,
I have a working application running on XP, written in VB6 that needs
to be ran on Vista.
I have read I need to use SpInProc instead of SpShared to make it run
correctly. I have set the audio input device below to my headset, but
the code fails on the CmdLoadFromFile with error 80045052 (Method
CmdLoadFromFile or object ISpeechRecoGrammar Failed).
In the other parts of the code not shown I have changed all SpShared
to SpInProc.
.
.
.
Set audioInputProfile = SharedRecognizer.GetAudioInputs
For i = audioInputProfile.Count - 1 To 0 Step -1
Set tokenObjectAudioInputs = audioInputProfile.Item(i)
Debug.Print "Audio Input Found: " &
tokenObjectAudioInputs.GetDescription
Next i
'set the grammar recogniser
If (RecoContext Is Nothing) Then
Debug.Print "Initializing SAPI reco context object..."
Set RecoContext = New SpInProcRecoContext
Set RecoProfile = New SpInprocRecognizer
Set Grammar = RecoContext.CreateGrammar(1)
Set RecoProfile.AudioInput = tokenObjectAudioInputs
Debug.Print "Current Reco Audio Input Device: " &
RecoProfile.AudioInput.GetDescription
End If
Grammar.CmdLoadFromFile "c:\i-friend\mike-grammar.xml", SLOStatic
Grammar.DictationSetState SGDSInactive
Grammar.CmdSetRuleIdState 1, SGDSActive
RecoContext.EventInterests = SRERecognition + SREAudioLevel
.
.
.
Grammar File:
<grammar>
<rule id="1" name="number"
toplevel="active">
<l propname="number">
<p valstr="INT:STARTLISTENING">Computer</p>
</l>
</rule>
</grammar>
.
.
.
Thanks for any help you can give me.
|
| Post Reply
|
| Re: Vista VB6 InProc Problem Loading Grammar |
 |
Wed, 19 Mar 2008 07:48:29 -070 |
Hi Mike,
0x80045052 is SPERR_LANGID_MISMATCH (you can find this in sperror.h in the
Windows SDK).
/*** SPERR_LANGID_MISMATCH
0x80045052 -2147200942
* An attempt to load a CFG grammar with a LANGID different than other
loaded grammars.
*/
#define SPERR_LANGID_MISMATCH
MAKE_SAPI_ERROR(0x052)
You should check to make sure that your grammar is compiled with the same
language recognizer langid as the recognizer you're trying to load the
grammar into. You can specify the langid in the grammar XML using something
like this:
<GRAMMAR LANGID="409">
--
Rob Chambers [MSFT]
http://blogs.msdn.com/robch/default.aspx
Windows Speech Recognition - We're Listening...
This posting is provided "AS IS" with no warranties, and confers no
rights.
|
| Post Reply
|
| Re: Vista VB6 InProc Problem Loading Grammar |
 |
Thu, 20 Mar 2008 02:34:48 -070 |
Thanks for that Rob, that fixed my grammar loading problem.
The next problem I have now is that when running InProc the events are
not triggereing, like AudioLevel is not updating my VU meter. In my
code above I set my AudioInput to headset, and the debug says it has
been set correctly, is there anything else I need to do that I have
missed?
Thanks for any help,
|
| Post Reply
|
|
|
|
|
|
|
|
|
|