speech sdk 中 为什么一添加 sphelper.h 头文件 就报错

seeyousmile 2007-06-15 01:45:00
如上, 急啊 一大堆的显示 sphelper.h 里面有错误。微软的sdk 头文件应该没错啊 谁做过的说下啊
...全文
1525 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjpa7 2011-01-06
  • 打赏
  • 举报
回复
【转】SAPI 包含sphelper.h编译错误解决方案 在使用Microsoft Speech SDK 5.1开发语音识别程序时,包含了头文件“sphelper.h”和库文件“sapi.lib”。编译时出错: 1>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 1>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 1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2373) : error C2065: 'psz' : undeclared identifier 1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2559) : error C2440: 'initializing' : cannot convert from 'CSpDynamicString' to 'SPPHONEID *' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>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 *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 搜索了一圈,根据大家的经验汇总,应该是Speech代码编写时间太早,语法不严密。而VS2005对于语法检查非常严格,导致编译无法通过。修改头文件中的以下行即可正常编译:

Ln 769 const ulLenVendorPreferred = wcslen(pszVendorPreferred);

const unsigned long ulLenVendorPreferred = wcslen(pszVendorPreferred);

Ln 1418 static CoMemCopyWFEX(const WAVEFORMATEX * pSrc, WAVEFORMATEX ** ppCoMemWFEX)

static HRESULT CoMemCopyWFEX(const WAVEFORMATEX * pSrc, WAVEFORMATEX ** ppCoMemWFEX)

Ln 2372 for (const WCHAR * psz = (const WCHAR *)lParam; *psz; psz++) {}

const WCHAR * psz; for (psz = (const WCHAR *)lParam; *psz; psz++) {}

Ln 2559 SPPHONEID* pphoneId = dsPhoneId;

SPPHONEID* pphoneId = (SPPHONEID*)((WCHAR *)dsPhoneId);

Ln 2633 pphoneId += wcslen(pphoneId) + 1;

pphoneId += wcslen((const wchar_t *)pphoneId) + 1; 好了,编译通过,下面可以正式编写程序逻辑了。



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wangyangtao/archive/2010/10/11/5933734.aspx
cloudyi 2009-10-18
  • 打赏
  • 举报
回复
VC6.0g上已经调试成功:
#define DLL_API _declspec(dllexport)
#include "Speech.h"

#pragma comment(lib, "export_lib/sapi.lib")
#include "include/sapi.h"
#include "include/sapiddk.h"
#include "include/sperror.h"
#include "include/spdebug.h"
#include "include/sphelper.h" //SpEnumTokens
#include "include/spuihelp.h"
#include "afxwin.h"

int m_VoiceType;
BOOL IsSuccess = true;
CString msg;
CComPtr<ISpVoice> pSpVoice;
CComPtr<ISpObjectToken> pLangType;

CSpeech::CSpeech()
{

}
CSpeech::~CSpeech()
{

}
void CSpeech::Free()
{
pSpVoice.Release();
pLangType.Release();
CoUninitialize();
}
BOOL CSpeech::TxtToSpeech(CString m_txtInput)
{

}

CString CSpeech::GetErrorMsg()
{
}
生成的是一个dll, 以前毕业论文做过的,TxtToSpeech可以将文字转化成语音输出.
cloudyi 2009-10-18
  • 打赏
  • 举报
回复
VC6.0g上已经调试成功:
#define DLL_API _declspec(dllexport)
#include "Speech.h"

#pragma comment(lib, "export_lib/sapi.lib")
#include "include/sapi.h"
#include "include/sapiddk.h"
#include "include/sperror.h"
#include "include/spdebug.h"
#include "include/sphelper.h" //SpEnumTokens
#include "include/spuihelp.h"
#include "afxwin.h"

int m_VoiceType;
BOOL IsSuccess = true;
CString msg;
CComPtr<ISpVoice> pSpVoice;
CComPtr<ISpObjectToken> pLangType;
BOOL GetCngOrEngChar(CString m_str, CString &m_Char, int &CharType);

CSpeech::CSpeech()
{

}
CSpeech::~CSpeech()
{

}
void CSpeech::Free()
{
pSpVoice.Release();
pLangType.Release();
CoUninitialize();
}
BOOL CSpeech::TxtToSpeech(CString m_txtInput)
{

}

CString CSpeech::GetErrorMsg()
{
}
生成的是一个dll, 以前毕业论文做过的,TxtToSpeech可以将文字转化成语音输出.
an_bachelor 2009-10-18
  • 打赏
  • 举报
回复
你的ULONG之类都没定义
如果不是mfc 在那些include之前加上#include <windows.h>
mfc的#include <afx.h>
loadingspace 2009-10-18
  • 打赏
  • 举报
回复
倒数第三个error:

const WCHAR * PropertyStringValue() const
{
// Search for the first NULL and return pointer to the char past it.
SPDBG_ASSERT(eEventId == SPEI_PROPERTY_STRING_CHANGE);
for (const WCHAR * psz = (const WCHAR *)lParam; *psz; psz++) {}
return psz + 1;
}
返回一个const WCHAR 的指针,但这个指针的定义在for循环里,这在2005下是不行的
菜牛 2008-04-04
  • 打赏
  • 举报
回复
你这个头文件放在其它头文件最后,或者stdafx.h文件最后。
chenyu2202863 2008-04-04
  • 打赏
  • 举报
回复
我也遇到了一样的问题

d:\files\microsoft visual studio 8\vc\platformsdk\speech\include\sphelper.h(2561) : error C2440: “初始化”: 无法从“CSpDynamicString”转换为“SPPHONEID *”
1> 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
1>d:\files\microsoft visual studio 8\vc\platformsdk\speech\include\sphelper.h(2635) : error C2664: “wcslen”: 不能将参数 1 从“SPPHONEID *”转换为“const wchar_t *”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换


明明就是头文件 的问题吧
seeyousmile 2007-06-17
  • 打赏
  • 举报
回复
SpeechSDK51 在XP下面开发
在使用sapi。h的时候不会有问题 但是一添加sphelper.h 就出现一堆的错误。
是提供的sdk 的头文件有问题
菜牛 2007-06-15
  • 打赏
  • 举报
回复
你这个开发包是什么平台的?
seeyousmile 2007-06-15
  • 打赏
  • 举报
回复
我有 include的里面的顺序怎么调 还是那样
seeyousmile 2007-06-15
  • 打赏
  • 举报
回复
倒数第三个error:

const WCHAR * PropertyStringValue() const
{
// Search for the first NULL and return pointer to the char past it.
SPDBG_ASSERT(eEventId == SPEI_PROPERTY_STRING_CHANGE);
for (const WCHAR * psz = (const WCHAR *)lParam; *psz; psz++) {}
return psz + 1;
}
这个语句是在他的。h 怎么看也没错
seeyousmile 2007-06-15
  • 打赏
  • 举报
回复
1>c:\program files\microsoft speech sdk 5.1\include\spdebug.h(274) : warning C4996: 'wcscpy' was declared deprecated
1> c:\program files\microsoft visual studio 8\vc\include\string.h(250) : see declaration of 'wcscpy'
1> Message: 'This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(89) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(150) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(169) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(226) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(227) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(334) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>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
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(769) : warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(772) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>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
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2373) : error C2065: 'psz' : undeclared identifier
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2544) : warning C4267: '+=' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:\program files\microsoft speech sdk 5.1\include\sphelper.h(2559) : error C2440: 'initializing' : cannot convert from 'CSpDynamicString' to 'SPPHONEID *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>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 *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

我换了还是找不到 原因 微软提供开发包一概不会错啊
CathySun118 2007-06-15
  • 打赏
  • 举报
回复
是的,应该是include files顺序的问题
  • 打赏
  • 举报
回复
没做过,你先贴出来错误信息
ouyh12345 2007-06-15
  • 打赏
  • 举报
回复
看是否为头文件包含次序的问题。
在tools - options - directories - include files里调整次序

16,546

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧