You are reading help file online using chmlib.com
|
ISpVoice::SetOutput sets the current output object. The object may either be a stream, audio device, or an object token for an output audio device. If pUnkOutput is NULL the default audio device will be used.
HRESULT SetOutput(
IUnknown *pUnkOutput,
BOOL fAllowFormatChanges
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_INVALIDARG | One or more parameters are invalid. |
SPERR_UNINITIALIZED | pUnkOutput is an uninitialized ISpStream object. |
E_OUTOFMEMORY | Exceeded available memory. |
The following is an example of how to enumerate all the available audio output devices registered under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioOutput.
HRESULT hr = S_OK;
CComPtr<ISpObjectToken> cpAudioOutToken;
CComPtr<IEnumSpObjectTokens> cpEnum;
CComPtr<ISpVoice> cpVoice;
ULONG ulCount = 0;
// Create the SAPI voice
if(SUCCEEDED(hr))
hr = cpVoice.CoCreateInstance( CLSID_SpVoice );
//Enumerate the available audio output devices
if(SUCCEEDED(hr))
hr = SpEnumTokens( SPCAT_AUDIOOUT, NULL, NULL, &cpEnum );
//Get the number of audio output devices
if(SUCCEEDED(hr))
hr = cpEnum->GetCount( &ulCount );
// Obtain a list of available audio output tokens, set the output to the token, and call Speak
while ( SUCCEEDED(hr) && ulCount-- )
{
if(SUCCEEDED(hr))
hr = cpEnum->Next( 1, &cpAudioOutToken, NULL );
if(SUCCEEDED(hr))
hr = cpVoice->SetOutput( cpAudioOutToken, TRUE );
if(SUCCEEDED(hr))
hr = cpVoice->Speak( L"How are you?", SPF_DEFAULT, NULL );
}
You are reading help file online using chmlib.com
|