BTW I forgot to mention the error I am getting on the ISpObjectTokenCategory_SetId call is:
800703e6 (Invalid access to memory location.)
I don't know why yet but I'll save it for tomorrow.
Posted on 2002-12-06 20:09:23 by Wayne
I might know why...

Do you have the Speech control panel installed (you should), and if you do, does it look like "Image #1" below:
Posted on 2002-12-06 20:13:50 by NaN
.
Posted on 2002-12-06 20:14:38 by NaN
You should have #2.. (i hope) cause its the SAPI 5 Control Panel. If you have Image #1, you have the SAPI 4 control panel. Which for some reason not understood by me, Microsoft decided to not superceed the SAPI 4, but still develop SAPI 5 as a "new" SAPI. The SAPI.COM file that i transcribed is the SAPI 5 file.

However, this maybe me touting hot air, cause the very nature of GUID's insist that the interaces be unique.....???

Confused... Wish the DDK included info on how to poperly distribute this stuff....

NaN
Posted on 2002-12-06 20:20:18 by NaN
Speech Panel is like Image#2.
I have the following Directories:
C:\Program Files\Common Files\Microsoft Shared\Speech\1033
C:\Program Files\Common Files\Microsoft Shared\SpeechEngines\TTS
Posted on 2002-12-06 20:25:51 by Wayne
Afternoon, Nan.

I'm getting the same error as Wayne.

I have SAPI 5.1 installed.

Since you posted this thread, I've begun mucking about with SAPI 5 in a C++ proggy I'm building.
The code is based upon the Coffee01 and 02 examples.
So far, there hasn't been a problem. I can now tell the 'puter to move an object up/down/left/right.
Also implemented is the text-to-speech stuff, so the proggy welcomes the user to the application, and gives audio(speech) feedback on all voice commands.

It'll be interesting to find out why your examples are failing. The GUIDs *are* the same, so it *should* be working, dammit:mad:

Cheers,
Scronty
Posted on 2002-12-06 20:30:43 by Scronty
Check the LL Macro??

Change the code to DYNAMICALLY do MuiltByteToWideChar and create a unicode string... Cause The Token is gotten using this data... (u_TokenIn).

(( If you have the SDK, i based this first version (essentiall) off the "SimpleDict" source))

Also, note that there is tutorial/descriptions in the SAPI5.CHM file for the Coffee Series of examples.

((( Oddest part is, even with my COM macro fixed, i still get no errors? )))

:NaN:
Posted on 2002-12-06 20:44:07 by NaN
Afternoon, Nan.

Just checked it with dynamic code between posts.
Same result/error:/

I just had a little comparison between the coffee code and your example (as you say...based upon the SimpleDict source).

Seems to be quite a difference in how the thing is set up.
i.e. in my (C++) code, it's set up as (comments and error checking cut out):
g_cpEngine.CoCreateInstance(CLSID_SpSharedRecognizer);

g_cpEngine->CreateRecoContext( &g_cpRecoCtxt );
g_cpRecoCtxt->SetNotifyWindowMessage( hWnd, WM_RECOEVENT, 0, 0 );
g_cpRecoCtxt->SetInterest( SPFEI(SPEI_RECOGNITION), SPFEI(SPEI_RECOGNITION) );
g_cpRecoCtxt->CreateGrammar(GRAMMARID1, &g_cpCmdGrammar);
g_cpCmdGrammar->LoadCmdFromResource(NULL, MAKEINTRESOURCEW(IDR_CMD_CFG),
L"SRGRAMMAR", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
SPLO_DYNAMIC);
g_cpCmdGrammar->SetRuleState(NULL, NULL, SPRS_ACTIVE );

cpRecoEngine.CoCreateInstance(CLSID_SpInprocRecognizer);

cpRecoEngine->CreateRecoContext( &m_cpRecoCtxt );
m_cpRecoCtxt->SetNotifyWindowMessage( hDlg, WM_RECOEVENT, 0, 0 );
m_cpRecoCtxt->SetInterest(ullInterest, ullInterest);
SpCreateDefaultObjectFromCategoryId(SPCAT_AUDIOIN, &cpAudio);
cpRecoEngine->SetInput(cpAudio, TRUE);
cpRecoEngine->SetRecoState( SPRST_ACTIVE );
m_cpRecoCtxt->CreateGrammar( GID_DICTATION, &m_cpDictationGrammar );
m_cpDictationGrammar->LoadDictation(NULL, SPLO_STATIC);
m_cpDictationGrammar->SetDictationState( SPRS_ACTIVE );


Cheers,
Scronty
Posted on 2002-12-06 20:52:52 by Scronty
It Lives !!! or listens anyway.

Using MuiltByteToWideChar to build the UNICODE string did the trick. Everything seems to be working fine.

Cool !

Thanks Wayne
Posted on 2002-12-06 21:03:33 by Wayne
Afternoon, Nan.

dammit!

WideCharToMuiltByte != MuiltByteToWideChar .

Listens also. Doesn't shutdown correctly though.
I have the mic coming out of the headphone speakers so that I can tell if it works or not.
The mic feedback switches off now, however it doesn't come back on after the applcation is closed.

Cheers,
Scronty
Posted on 2002-12-06 21:13:58 by Scronty
Afternoon, Nan.

Yep. Works fine now :grin: .

Cheers,
Scronty
Posted on 2002-12-06 21:19:11 by Scronty
Like i said, i followed the SimpleDict example. (simple dictation)

This was before there was also a second recognition context type (Command an Control). As well, for some reason beyond me, their example uses the InProcRecognizer, instead of the SharedRecognizer.

If you go thu the tutorials, it mentions the difference (basically the scope of control over the Microphone), however, if you use InProc, you have to do alot of setup stuff, like the Token business yourself. If you choose the SharedRecognizer, it will do all this stuff automatically.

I didnt find these tuts until i finished transcribing SimpleDict, or I too would have started with Coffee1 + 2.

So this is why there is a dramatic difference in code...

As for your error, I dunno... seems Wayne got it working.. What is your OS type?

As well, im surprised Wayne cant access a unicode string from the .data section. (invalid memory type error??). Wayne, did you alloc memory off the heap for the DYNAMIC result, or did you just guess and make a rather large buffer in the .data segment?

Thanx both of you for you help so far!
:alright:
NaN
Posted on 2002-12-06 21:32:04 by NaN
Afternoon, Nan.

It's working fine now (except for the audio feedback from the mic in the speakers not coming back on).

I just did another check of the code.

I took out the dynamic code, and just put:
.data

UNI_AudioIn UNICODE_TEXT
%LL SPCAT_AUDIOIN
dw 0
.code
ole32 pTokenCategory, ISpObjectTokenCategory_SetId, offset UNI_AudioIn, FALSE
IF_COM_ERROR 'Failed to Set Audio ID from Unicode Registry Key'

...and it worked fine:) .

So the problem actually lies in where "u_AudioIn" is plcaed, *or* there's a problem where those macros are used (UNICODE_TEXT or %LL ).

Oh...and I'm on XP prof.

Cheers,
Scronty
Posted on 2002-12-06 21:53:31 by Scronty
I bet i know the problem (me grins)

I remember reading somewhere that NT os's like to have their kernal stuff alligned on DWORD boundries. I bet if you put: ALIGN 4 before the macro it will work...

Or maybe im smoking crack, and i simply forgot :)
:nAn:
Posted on 2002-12-06 22:00:38 by NaN
Afternoon, Nan.

Just moved:
         u_AudioIn   UNICODE_TEXT

%LL SPCAT_AUDIOIN
dw 0
inside the sr.inc file, up until it's at the beginning of the .data section.

Works fine, again.

Just seems to fail if it's defined lower down in the .data section.

Cheers,
Scronty
Posted on 2002-12-06 22:01:38 by Scronty
Afternoon, Nan.


I bet i know the problem (me grins)

I remember reading somewhere that NT os's like to have their kernal stuff alligned on DWORD boundries. I bet if you put: ALIGN 4 before the macro it will work...

Or maybe im smoking crack, and i simply forgot :)
:nAn:

:alright:
Yep!
That's what the problem was :)

Cheers,
Scronty
Posted on 2002-12-06 22:10:23 by Scronty
Thanx.. i will try and work this into the macro...
Posted on 2002-12-06 22:58:16 by NaN
For your Enjoyment, i should have a translated Coffee2 ready before the day is up.. With full commenting etc. etc. :)

NaN
Posted on 2002-12-08 09:26:47 by NaN
hi NaN,
the program crashed and gave me:
Posted on 2002-12-09 00:28:33 by amr
Crashed on me too.:(
I am using XP Pro.

I have the SAPI 4.0 runtime support ,speech recognition and sppech control panel installed from this page which you gave a link to-
http://www.microsoft.com/msagent/downloads.htm

Hell, i even downloaded the Speech Sdk 5.1.:)
Posted on 2002-12-09 00:55:06 by clippy