如何修复 SAPI 5.1 头文件中的编译器错误 [英] How to fix compiler errors in SAPI 5.1 Header Files

查看:43
本文介绍了如何修复 SAPI 5.1 头文件中的编译器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 SAPI 5.1 提供的头文件中得到了很多错误,无法弄清楚如何解决这些问题.

I got a lot of errors from SAPI 5.1 provided header files and cannot figure out how to fix those problems.

以下是来自 微软如何进行视频演示的简单文本到语音程序.主持人说,如果你安装了最新的软件包,你编译这个程序就没有问题.但他使用的是 Video Studio 2005;显然,最新"指的是几年前进行演示时.

Following is a simple Text to Speech program from Microsoft’s How to Video Presentation. The presenter said, if you have installed the most updated packages, you will have no problem compile this program. But he is using Video Studio 2005; apparently the "most updated" refers a few years ago when the presentation was given.

我认为这些错误是由于版本不匹配造成的.我使用的是 Windows XP SP3.我有 Visual Studio 2008 SP1、Visual Studio 2008 SDK 1.1、Windows SDK v6.0A(VS2008 附带)、Windows SDK v7.0 和 SAPI 5.1.有人可以帮我解决这些问题吗?

I think these errors are caused version miss match. I am using Windows XP SP3. I have Visual Studio 2008 SP1, Visual Studio 2008 SDK 1.1, Windows SDK v6.0A(come with VS2008), Windows SDK v7.0 and SAPI 5.1. Can someone help me figure out these problems?

TTSdemo.cpp

TTSdemo.cpp

#include <windows.h>
#include <atlbase.h>
#include <sapi.h>
#include <sphelper.h>
#include <string>
#include <iostream>

int wmain(int argc, wchar_t **argv)
{
    int i;
    ULONG n;
    HRESULT hr;
    std::wstring args;
    CComPtr<ISpObjecToken> token;
    CComPtr<ISpVoice> tts;
    CoInitialize(0);

    for (i = 1, args = L""; i < argc; i++ )
    {
        args.append( argv[i] );
        args.append( L" " );
    }

    tts.CoCreateInstance(CLSID_SpVoice);
    hr = SpGetDefaultTokenFromCategoryId(SPCAT_VOICES, &token, FALSE);
    hr = tts->SetVoice(token);

    if (args.length() == 0 )
        std::wcout << L"Enter @<text file name> or <text to speak>" << STD::endl;
    else if ( args(0) == L'@' )
        tts->Speak(args.c_str() + 1, SPF_IS_FILENAME | SPF_ASYNC, &n);
    else
        tts->Speak(args.c_str(), SPF_IS_XML | SPF_ASYNC, &n);

    tts->WaitUntilDone(-1);

    tts.Release();
    token.Release();

    CoUninitialize();

    return 0;
}

编译器错误

c:\program files\microsoft voice sdk 5.1\include\spdebug.h(274):警告 C4996:wcscpy":此函数或变量可能不安全.考虑改用 wcscpy_s.要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS.有关详细信息,请参阅在线帮助.

c:\program files\microsoft speech sdk 5.1\include\spdebug.h(274) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

c:\program files\microsoft visual studio 9.0\vc\include\string.h(252): 见'wcscpy'的声明

c:\program files\microsoft visual studio 9.0\vc\include\string.h(252) : see declaration of 'wcscpy'

c:\program files\microsoft voice sdk 5.1\include\sphelper.h(769):错误 C4430:缺少类型说明符 - 假定为 int.注意:C++ 没有支持 default-int

c:\program files\microsoft speech sdk 5.1\include\sphelper.h(769) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c:\program files\microsoft Speech sdk 5.1\include\sphelper.h(1419):错误 C4430:缺少类型说明符 - 假定为 int.注意:C++ 没有支持 default-int

c:\program files\microsoft speech sdk 5.1\include\sphelper.h(1419) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c:\program files\microsoft Speech sdk 5.1\include\sphelper.h(2373):错误 C2065:psz":未声明的标识符

c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2373) : error C2065: 'psz' : undeclared identifier

c:\program files\microsoft Speech sdk 5.1\include\sphelper.h(2559):错误 C2440:正在初始化":无法从CSpDynamicString"转换到 'SPPHONEID *' 没有可用的用户定义转换运算符可以执行此转换,否则无法调用运算符

c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2559) : error C2440: 'initializing' : cannot convert from 'CSpDynamicString' to 'SPPHONEID *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

c:\program files\microsoft Speech sdk 5.1\include\sphelper.h(2633):错误 C2664:wcslen":无法从SPPHONEID *"转换参数 1'const wchar_t *'指向的类型是不相关的;转换需要 reinterpret_cast、C-style cast 或 function-style cast

c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2633) : error C2664: 'wcslen' : cannot convert parameter 1 from 'SPPHONEID *' to 'const wchar_t *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

推荐答案

请使用 "\Program Files\Microsoft SDKs\Windows\v6.0A" 或 7.0 或 7.0A 任何最新可用的电脑.

Please use "\Program Files\Microsoft SDKs\Windows\v6.0A" or 7.0 or 7.0A whatever latest available on your computer.

SAPI DLL 和 libs + 头文件在那里,兼容 VS2008

The SAPI DLL's and libs + header files are there, compatible for VS2008

享受.

这篇关于如何修复 SAPI 5.1 头文件中的编译器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆