floating point division by zero

解决方案 »

  1.   

    我把代码贴出来,你帮我看一下,我找了一天了,就没发现问题在哪里,麻烦你看一下,很着急
    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;
      

  2.   

    这么长代码想把人看晕提示很明白  在某个条件 0 做了 被除数XXX/0 无穷大,不允许
      

  3.   

    nRet := TTSFetchNext(objHTTSInstance, @objTtsData);
     执行到这里就执行不走了
      

  4.   

    {$ifdef TTS_LOADLIB_DECLARE}
    type Proc_TTSFetchNext = function (hTTSInst : HTTSINSTANCE; pData : PTTSData) : TTSRETVAL; cdecl;
    {$else}
    function TTSFetchNext(hTTSInst : HTTSINSTANCE; pData : PTTSData) : TTSRETVAL;
                cdecl; external 'iFlyTTS.DLL';
    {$endif}