Download 3 Voice API installation packages http://www.microsoft.com/en-us/download/details.aspx?id=10121
need to install the Microsoft Voice API installation package: Speechsdk51langpack, SpeechSDK51, and msttss22l,
In order to use this SDK in VC, it is necessary to add the SDK's include and LIB directories in the project, in order to avoid adding directories to each project, the best way is the VC
Option->directoris plus the include and Lib directories of the SDK. The sapi.h Sapi.lib can also be placed directly into the VC6 header file library file
One of the simplest examples
Let's look at an example of getting started:
#include <sapi.h>
#pragma comment (lib, "Ole32.lib")//coinitialize CoCreateInstance need to call Ole32.dll
#pragma comment (lib, "Sapi.lib")//sapi.lib in the Lib directory of the SDK, must be configured correctly
int main (int argc, char* argv[])
{
Ispvoice * Pvoice = NULL;
COM initialization:
if (FAILED (:: CoInitialize (NULL)))
return FALSE;
Get Ispvoice Interface:
HRESULT hr = CoCreateInstance (Clsid_spvoice, NULL, Clsctx_all, Iid_ispvoice, (void * *) &pvoice);
if (SUCCEEDED (HR))
{
hr = Pvoice->speak (L "Hello World", 0, NULL);
Pvoice->release ();
Pvoice = NULL;
}
Don't forget:
:: CoUninitialize ();
return TRUE;
}
VC6.0 C + + How to invoke the Microsoft Windows System SDK Speech API