讯飞语音合成C++转Delphi问题。

sz100wwb 2015-06-06 05:47:42
msc.dll中的函数原型为:MSPAPI const char* QTTSSessionBegin(const char* params, int* errorCode)

用法示例(其中的MSP_SUCCESS为数字0):
const char* params= “ssm=1, ent=intp65, aue=speex-wb;7,auf=audio/L16;rate=16000”;

int ret = MSP_SUCCESS;

const char* session_id = QTTSSessionBegin( params, &ret );

if(MSP_SUCCESS != ret )

{
printf( “QTTSSessionBegin failed, error code is: %d”, ret );
}



请大家看看我转成delphi的代码哪里有问题,先谢谢大家了!

function QTTSSessionBegin(Params: PChar; ErrorCode: PInteger):string; stdcall; external 'msc.dll';


procedure TForm1.Button1Click(Sender: TObject);
var
SessionStr, SessionID: string;
r: PInteger;
a: Integer;
begin
a := 0;
r := @a;
SessionStr := 'ssm=1, ent=intp65, aue=speex-wb;7, auf=audio/L16;rate=16000';
SessionID := QTTSSessionBegin(PChar(SessionStr), r);
ShowMessage(SessionID);
end;


点击Button1执行到调用QTTSSessionBegin就报错:Access violation at address ...... in module 'msc.dll'. Write of address ......
...全文
547 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijenyun 2015-07-18
  • 打赏
  • 举报
回复
ErrorCode: PInteger 改成var errorCode: integer QTTSSessionBegin(PChar(SessionStr), r)改成QTTSSessionBegin(PChar(SessionStr), a)
sz100wwb 2015-07-13
  • 打赏
  • 举报
回复
问题依旧,大侠来帮帮忙吧。
lijenyun 2015-06-25
  • 打赏
  • 举报
回复
SessionStr:string改成SessionStr:array[0..255] of char
yct0605 2015-06-24
  • 打赏
  • 举报
回复
以前用过讯飞的Delphi版的DLL,不过需要安装N多的软件才能用,现在基本上都是C的DLL了。
sz100wwb 2015-06-22
  • 打赏
  • 举报
回复
都不是这些原因,提问前我就试过了,还是谢谢你们! 还有没有高手来帮我看看是啥问题?
看那山瞧那水 2015-06-22
  • 打赏
  • 举报
回复
调用其它语言的DLL,最好不用string,用pchar或pansichar function QTTSSessionBegin(Params: PChar; ErrorCode: PInteger):pchar; stdcall; external 'msc.dll';
tippchlj 2015-06-18
  • 打赏
  • 举报
回复
把 stdcall 改为 cdecl 试试。 可参考: http://blog.csdn.net/huang_xw/article/details/7524359
智联海信 2015-06-17
  • 打赏
  • 举报
回复
PChar改为PAnsiChar

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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