Jump to content

Featured Replies

Posted

Back to the original question......

 

 

 

If you are developing your own program, (you probably are if you're

 

concerned with grammar files), then yes you can use Speech Recognition

 

without enabling the Windows Commands:

 

 

 

Heya Mike,

 

 

 

 

 

Not sure if you'll still be interested, but there is a solution to your

 

question. If you've moved on, it'll still be relevant to the rest of us,

 

so I'll post away....

 

 

 

 

 

There's two ways to instance a speech recogniser using SAPI. The most

 

common, and the simplest is through simply using the shared recogniser:

 

 

 

hr = pRecognizerEngine.CoCreateInstance( CLSID_SpSharedRecognizer )

 

 

 

The more complicated way is to create your own recogniser:

 

 

 

hr = pRecognizerEngine.CoCreateInstance( CLSID_SpInprocRecognizer )

 

 

 

The shared recogniser requires that you enable the shared recogniser,

 

which turns on the Windows command recognition grammar. You can't avoid

 

it, this is disappointing and frustrating. The solution is the second

 

option, creating your own recogniser.

 

 

 

You do not need to turn on the Windows Speech recognition, instead you

 

end up with your own recognition engine, completely independant of the

 

Windows command recogniser.

 

 

 

This MSDN guide is for using WAV -> SR, but most of it applies:

 

 

 

'Using WAV File Input with SR Engines (SAPI 5.3)'

 

(http://msdn.microsoft.com/en-us/library/ms717071%28VS.85%29.aspx)

 

 

 

Replace the Stream object wit han spAudio object and you're almost

 

there, here's the Audio Object Code(shortened, no HRESULT checks):

 

 

 

CComPtr pAudioToken

 

CComPtr pAudio

 

 

 

// Try the default

 

hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &pAudioToken)

 

 

 

 

 

// Connect the Device

 

hr = pRecognizerEngine->SetInput(pAudioToken, TRUE)

 

 

 

hr = SpCreateDefaultObjectFromCategoryId(SPCAT_AUDIOIN, &pAudio)

 

 

 

hr = pRecognizerEngine->SetInput(pAudio, TRUE)

 

 

 

After that you can continue using the MSDN link above, and will be

 

almost finished, except you need to manually activate the Audio Stram

 

from a microphone / Line-In:

 

 

 

hr = pGrammar->SetGrammarState(SPGS_ENABLED)

 

hr = pNavGrammar->SetDictationState(SPRS_ACTIVE)

 

 

 

 

 

Assuming you are careful in checking the errors, you'll have your own

 

voice recognition, and NO windows commands going off!

 

 

 

 

 

Have funz0r!

 

 

 

-Dr Black Adder

 

 

 

 

 

--

 

Dr Black Adder

 

Posted via http://www.vistaheads.com

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...