floating point division by zero
解决方案 »
- 怎样“屏蔽键盘的方向键”?急!谢谢!
- 问一个数据库查询中显示树型结构的问题!有点难度!来者有分!
- 请问如何将OLEVariant类型转为自定义类型
- 一般进入一些商用软件后主界面的背景动态图形菜单是怎么做的?
- 求助Delphi SMS短信开发应用的有关资料
- intraweb的控件刷新问题
- 菜鸟问题.
- 关于Fastreport2.47的问题!在线等待!!!(今天晚上10:00结帖!响应CSDN的号召!)
- 在有delphi client/server suite版本,并且本机有网卡的单机环境下,能不能制作并测试多层数据库?
- 可以用DELPHI做点对点传输吗?
- 如何得到窗口Z序
- word 文件头用delphi怎么读,它的格式有资料吗?
procedure TfrmMainForm.btnStartClick(Sender: TObject); //开始合成
var
sFileName :Array[0..244] of char;
sTemp :Array[0..244] of char;
sDrive :Array[0..244] of char;
sDir :Array[0..244] of char;
sFname :Array[0..244] of char;
sPath :Array[0..244] of char;
iTxtHandle:integer;
nRet,nSynthBufSize,nReadSize,nMaxInBufSize:integer;
label OK;
label Exception1,Exception2;
begin
if memo1.text<>'' then
begin
button2.Click;
timer1.Enabled:=false;
end;
if(strcomp(PChar(trim(edtTxtFile.Text)),'')=0) then
Begin
Application.MessageBox('待合成的文本为空,请在文本框中输入要合成的内容','提示!',MB_OK);
Exit;
End;
if((strcomp(PChar(trim(edtWavFile.Text)),'')=0) and (chbCreateWavFile.Checked = true) and (rbtTradition.Checked = false)) then
Begin
Application.MessageBox('新Wav文件未指定','错误!',MB_OK);
Exit;
End;
bComplete := true;
btnDisconnect.Enabled := false;
btnStart.Enabled := false;
btnStop.Enabled := true;
tbSpeed1.Enabled := false;
rbtTradition.Enabled := false;
rbtSynCh.Enabled := false;
rbtAsynch.Enabled := false;
strpcopy(sFileName,edtWavFile.Text);
if(chbCreateWavFile.Checked = false) then
bOutToAudioFile := false
else
bOutToAudioFile := true; if(SetSynthParam() = false) then
exit; //获得合成系统要求的最大输入文本长度
nRet := TTSGetSynthParam(objHTTSInstance, TTS_PARAM_INBUFSIZE,nMaxInBufSize);
if(nRet <> TTSERR_OK) then
Begin
strpcopy(sTemp,Format('在取系统参数时出现错误, 错误代码为%d. ', [nRet]));
Application.MessageBox(sTemp,'错误!',MB_OK);
goto exception2;
End;
strpcopy(sFileName,edtTxtFile.Text);
if((bOutToAudioFile = true) and (bTradition = false) and (FileExists(sFileName) = false)) then
Begin
strpcopy(sDrive,ExtractFileDrive(sFileName));
strpcopy(sDir,ExtractFileDir(sFileName));
strpcopy(sFname,ExtractFileDir(sFileName));
strpcopy(sPath,Format('%s',[sDir]));
if(sPath[strlen(sPath)-1] = '\') then
sPath[strlen(sPath)-1] := char(0)
else
sPath[strlen(sPath)] := char(0);
if(DirectoryExists(sPath) = false) then
Begin
if(Application.MessageBox('指定的wav文件路径不存在,您要创建新路径吗?',PChar(Application.MainForm.Caption),MB_OKCANCEL) =IDCANCEL) then
Begin
goto exception2;
end;
CreateDirectory(sPath,nil);
End;
End; //打开要合成的文本文件
strpcopy(sFileName,edtTxtFile.Text);
iTxtHandle := fileopen(Trim(sFileName), fmOpenRead);
if(iTxtHandle = -1) then
Begin
strpcopy(sTemp,Format('在打开文件%s时出现错误... ', [sFileName]));
Application.MessageBox(sTemp,'错误!',MB_OK);
goto exception2;
End;
nSynthBufSize := fileseek(iTxtHandle, 0, 2);
if(nSynthBufSize > nMaxInBufSize) then
Begin
strpcopy(sTemp,Format('文件%s的数据量超过系统所支持的最大数据量!', [sFileName]));
Application.MessageBox(sTemp,'错误!',MB_OK);
fileclose(iTxtHandle);
goto exception2;
End; //读取要合成的文本信息
objTtsData.szInBuf :=PChar(AllocMem(nSynthBufSize + 1));
fileseek(iTxtHandle, 0, 0);
nReadSize := fileread(iTxtHandle,objTtsData.szInBuf^, sizeof(char)*nSynthBufSize);
if(nReadSize = 0) then
Begin
strpcopy(sTemp,Format('在读取文件%s时出现错误...', [sFileName]));
Application.MessageBox(sTemp,'错误!',MB_OK);
fileclose(iTxtHandle);
goto exception1;
End;
objTtsData.dwInBufSize := nReadSize;
fileclose(iTxtHandle); bPlaying := true;
if(bTradition) then
Begin // 传统调用方式
//mInfo.Lines.Add('使用传统调用方式合成文本.');
nRet := TTSSynthText(objHTTSInstance, @objTtsData);
if(nRet <> 0) then
Begin
strpcopy(sTemp,Format('在执行函数TTSSynthText时出现错误, 错误代码为%d.', [nRet]));
Application.MessageBox(sTemp,'错误!',MB_OK);
goto Exception1;
End;
if(objTtsData.dwOutBufSize > 0) then
Begin
sndPlaySound(objTtsData.pOutBuf , SND_SYNC or SND_MEMORY);
Application.ProcessMessages();
End; while(objTtsData.dwOutFlags = TTS_FLAG_STILL_HAVE_DATA) do
Begin
nRet := TTSFetchNext(objHTTSInstance, @objTtsData);
if(nRet <> 0) then
Begin
strpcopy(sTemp,Format('在执行函数TTSFetchNext时出现错误, 错误代码为%d.', [nRet]));
Application.MessageBox(sTemp,'错误!',MB_OK);
goto Exception1;
End;
if(objTtsData.dwOutBufSize > 0) then
Begin
// meminfo.Lines.add('正在播放声音...');
meminfo.Lines.LoadFromFile(edttxtfile.Text);
sndPlaySound(objTtsData.pOutBuf, SND_SYNC or SND_MEMORY);
Application.ProcessMessages();
End;
if(bStop <> false) then
Begin
bStop := false;
TTSClean(objHTTSInstance);
goto OK;
End;
End;
End
else
Begin // 回调方式
//mInfo.Lines.Add('使用回调调用方式合成文本.');
objTtsCallBacks.nNumCallbacks := 1;
objTtsCallBacks.pfnTTSProcessCB := SynthProcessProc;
bStop := false;
// memInfo.Lines.Add('正在播放声音... ');
meminfo.Lines.LoadFromFile(edttxtfile.Text);
if(bSynchro <> false) then
Begin // 同步
TTSSynthTextEx(objHTTSInstance,@objTtsData,@objTtsCallBacks,FALSE,nil);
End
else
Begin // 异步
bComplete := false;
TTSSynthTextEx(objHTTSInstance, @objTtsData, @objTtsCallBacks, TRUE,nil);
End;
End; while(bComplete<>true) do
Begin
sleep(10);
Application.ProcessMessages();
End;
执行到这里就执行不走了
type Proc_TTSFetchNext = function (hTTSInst : HTTSINSTANCE; pData : PTTSData) : TTSRETVAL; cdecl;
{$else}
function TTSFetchNext(hTTSInst : HTTSINSTANCE; pData : PTTSData) : TTSRETVAL;
cdecl; external 'iFlyTTS.DLL';
{$endif}