如何在Visual c++ 2010 Express中设置SAPI

How to setup SAPI with Visual C++ 2010 Express?

本文关键字:Express 设置 SAPI 2010 c++ Visual      更新时间:2023-10-16

我需要知道如何使用visual c++ 2010 express设置SAPI (Windows Speech API)。我知道Windows 7带有内置的SAPI库,我正在使用Windows 7。但是,我下载了SAPI 5.1,以防需要。MS关于在VS中设置SAPI的说明相当旧,这对我不起作用。

我怎么能设置它与VS 2010 Express,因为我需要将这些设置应用到QT和继续我的最后一年的项目。

你知道什么?我从你之前的问题中提取了代码,并删除了ATL的东西(Visual Studio Express 2010不支持ATL)。我留下了这个

#include <windows.h>
#include <sapi.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
    cout << "Hello" << endl;
    ISpVoice * pVoice = NULL;
    if (FAILED(::CoInitialize(NULL)))
        return FALSE;
    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
    if( SUCCEEDED( hr ) )
    {
        cout << "Succeeded" << endl;
        hr = pVoice->Speak(L"Hello world", 0, NULL);
        pVoice->Release();
        pVoice = NULL;
    }
    else
    {
        cout << "Not succeeded" << endl;
    }
    ::CoUninitialize();
    return TRUE;
}

我创建了一个标准的Windows控制台应用程序项目,并使用此代码作为唯一的源文件。编译并运行它,它工作了。它说!用女声演唱

我没有做任何设置。所以很明显这是可行的。我以前从来不知道这个图书馆。

我有Windows 7和vs2010 express.