⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adsapien.pas

📁 Async Professional 4.04
💻 PAS
📖 第 1 页 / 共 5 页
字号:

begin
  CheckIndex (x);
  Result := ConvertGrammars (FiDirectSR.Grammars (x + 1));
end;

function TApdSREngines.GetInterfaces (x : Integer) : TApdSRInterfaces;

  function ConvertInterfaces (v : Integer) : TApdSRInterfaces;
  begin
    Result := [];
    if (v and ApdSRI_ILEXPRONOUNCE) <> 0 then
      Result := Result + [siLexPronounce];
    if (v and ApdSRI_ISRATTRIBUTES) <> 0 then
      Result := Result + [siSRAttributes];
    if (v and ApdSRI_ISRCENTRAL) <> 0 then
      Result := Result + [siSRCentral];
    if (v and ApdSRI_ISRDIALOGS) <> 0 then
      Result := Result + [siSRDialogs];
    if (v and ApdSRI_ISRGRAMCOMMON) <> 0 then
      Result := Result + [siSRGramCommon];
    if (v and ApdSRI_ISRGRAMCFG) <> 0 then
      Result := Result + [siSRGramCFG];
    if (v and ApdSRI_ISRGRAMDICTATION) <> 0 then
      Result := Result + [siSRGramDictation];
    if (v and ApdSRI_ISRGRAMINSERTIONGUI) <> 0 then
      Result := Result + [siSRGramInsertionGui];
    if (v and ApdSRI_ISRESBASIC) <> 0 then
      Result := Result + [siSREsBasic];
    if (v and ApdSRI_ISRESMERGE) <> 0 then
      Result := Result + [siSREsMerge];
    if (v and ApdSRI_ISRESAUDIO) <> 0 then
      Result := Result + [siSREsAudio];
    if (v and ApdSRI_ISRESCORRECTION) <> 0 then
      Result := Result + [siSREsCorrection];
    if (v and ApdSRI_ISRESEVAL) <> 0 then
      Result := Result + [siSREsEval];
    if (v and ApdSRI_ISRESGRAPH) <> 0 then
      Result := Result + [siSREsGraph];
    if (v and ApdSRI_ISRESMEMORY) <> 0 then
      Result := Result + [siSREsMemory];
    if (v and ApdSRI_ISRESMODIFYGUI) <> 0 then
      Result := Result + [siSREsModifyGui];
    if (v and ApdSRI_ISRESSPEAKER) <> 0 then
      Result := Result + [siSREsSpeaker];
    if (v and ApdSRI_ISRSPEAKER) <> 0 then
      Result := Result + [siSRSpeaker];
    if (v and ApdSRI_ISRESSCORES) <> 0 then
      Result := Result + [siSREsScores];
    if (v and ApdSRI_ISRESAUDIOEX) <> 0 then
      Result := Result + [siSREsAudioEx];
    if (v and ApdSRI_ISRGRAMLEXPRON) <> 0 then
      Result := Result + [siSRGramLexPron];
    if (v and ApdSRI_ISRRESGRAPHEX) <> 0 then
      Result := Result + [siSREsGraphEx];
    if (v and ApdSRI_ILEXPRONOUNCE2) <> 0 then
      Result := Result + [siLexPronounce2];
    if (v and ApdSRI_IATTRIBUTES) <> 0 then
      Result := Result + [siAttributes];
    if (v and ApdSRI_ISRSPEAKER2) <> 0 then
      Result := Result + [siSRSpeaker2];
    if (v and ApdSRI_ISRDIALOGS2) <> 0 then
      Result := Result + [siSRDialogs2];
  end;

begin
  CheckIndex (x);
  Result := ConvertInterfaces (FiDirectSR.Interfaces (x + 1));
end;

function TApdSREngines.GetLanguageID (x : Integer) : Integer;
begin
  CheckIndex (x);
  Result := FiDirectSR.LanguageID (x + 1);
end;

function TApdSREngines.GetMaxWordsState (x : Integer) : Integer;
begin
  CheckIndex (x);
  Result := FiDirectSR.MaxWordsState (x + 1);
end;

function TApdSREngines.GetMaxWordsVocab (x : Integer) : Integer;
begin
  CheckIndex (x);
  Result := FiDirectSR.MaxWordsVocab (x + 1);
end;

function TApdSREngines.GetMfgName (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSR.MfgName (x + 1);
end;

function TApdSREngines.GetModeID (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSR.ModeID (x + 1);
end;

function TApdSREngines.GetModeName (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSR.ModeName (x + 1);
end;

function TApdSREngines.GetProductName (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSR.ProductName (x + 1);
end;

function TApdSREngines.GetSequencing (x : Integer) : TApdSRSequences;

  function ConvertSequencing (v : Integer) : TApdSRSequences;
  begin
    case v of
      ApdSRSEQUENCE_DISCRETE        : Result := ssDiscrete;
      ApdSRSEQUENCE_CONTINUOUS      : Result := ssContinuous;
      ApdSRSEQUENCE_WORDSPOT        : Result := ssWordSpot;
      ApdSRSEQUENCE_CONTCFGDISCDICT : Result := ssContCFGDiscDict;
    else
      Result := ssUnknown;
    end;
  end;

begin
  CheckIndex (x);
  Result := ConvertSequencing (FiDirectSR.Sequencing (x + 1));
end;

procedure TApdSREngines.SetCurrentEngine (v : Integer);
begin
  if v <> FCurrentEngine then begin
    CheckIndex (v);
    FiDirectSR.Select (v + 1);
    FCurrentEngine := v;
  end;
end;

{ TApdCustomSapiEngine }                     

constructor TApdCustomSapiEngine.Create (AOwner : TComponent);
begin
  inherited Create (AOwner);

  FInitSR := True;                                                     {!!.04}
  FInitSS := True;                                                     {!!.04}

  FHandle := AllocateHWnd (WndProc);

  (*if not IsSapi4Installed then begin                                 {!!.04}
    if Assigned (FOnSRError) then                                      {!!.04}
      FOnSRError (Self, 0, '', ApdStrE_NOSAPI4);                       {!!.04}
    if Assigned (FOnSSError) then                                      {!!.04}
      FOnSSError (Self, 0, '', ApdStrE_NOSAPI4);                       {!!.04}
  end; *)                                                              {!!.04}

  FSpeaking := False;
  FListening := False;
  FDuplex := sdHalfDelayed;
  FWaitMode := wmNone;

  { Create needed classes }

  FWordList := TStringList.Create;
  FSSVoices := TApdSSVoices.Create;
  FSREngines := TApdSREngines.Create;

  { Create Registers }

  FPhraseFinishClients := TList.Create;

  FiDirectSS := nil;
  FiDirectSR := nil;

  FAutoTrain := False;
end;

destructor TApdCustomSapiEngine.Destroy;
var
  i : Integer;
  
begin
  FWordList.Free;

  FSSVoices.Free;
  FSREngines.Free;

  for i := 0 to FPhraseFinishClients.Count - 1 do begin
    Dispose (FPhraseFinishClients[i]);
  end;
  FPhraseFinishClients.Free;

  if Assigned (FiDirectSS) then
    FiDirectSS.Free;
  if Assigned (FiDirectSR) then
    FiDirectSR.Free;

  if FHandle <> 0 then
    DeallocateHWnd (FHandle);
  inherited Destroy;
end;

procedure TApdCustomSapiEngine.CheckError (ErrorCode : DWORD);
begin
  case ErrorCode of
    ApdSRERR_NONE                       :
      begin
      end;

  { SS }

    ApdTTSERR_INVALIDINTERFACE          :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDINTERFACE);
    ApdTTSERR_OUTOFDISK                 :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_OUTOFDISK);
    ApdTTSERR_NOTSUPPORTED              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_NOTSUPPORTED);
    ApdTTSERR_VALUEOUTOFRANGE           :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_VALUEOUTOFRANGE);
    ApdTTSERR_INVALIDWINDOW             :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDWINDOW);
    ApdTTSERR_INVALIDPARAM              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDPARAM);
    ApdTTSERR_INVALIDMODE               :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDMODE);
    ApdTTSERR_INVALIDKEY                :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDKEY);
    ApdTTSERR_WAVEFORMATNOTSUPPORTED    :
      raise EApdSapiEngineException.Create (ErrorCode,
                                          ApdStrTTSERR_WAVEFORMATNOTSUPPORTED);
    ApdTTSERR_INVALIDCHAR               :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_INVALIDCHAR);
    ApdTTSERR_QUEUEFULL                 :
      raise EApdSapiEngineException.Create (ErrorCode, ApdStrTTSERR_QUEUEFULL);
    ApdTTSERR_WAVEDEVICEBUSY            :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_WAVEDEVICEBUSY);
    ApdTTSERR_NOTPAUSED                 :
      raise EApdSapiEngineException.Create (ErrorCode, ApdStrTTSERR_NOTPAUSED);
    ApdTTSERR_ALREADYPAUSED             :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrTTSERR_ALREADYPAUSED);

  { SR }

    ApdSRERR_NOTENOUGHDATA              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_NOTENOUGHDATA);
    ApdSRERR_GRAMMARTOOCOMPLEX          :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARTOOCOMPLEX);
    ApdSRERR_GRAMMARWRONGTYPE           :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARWRONGTYPE);
    ApdSRERR_TOOMANYGRAMMARS            :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_INVALIDLIST);
    ApdSRERR_INVALIDLIST                :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_INVALIDLIST);
    ApdSRERR_GRAMTOOLARGE               :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMTOOLARGE);
    ApdSRERR_INVALIDFLAG                :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_INVALIDFLAG);
    ApdSRERR_GRAMMARERROR               :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARERROR);
    ApdSRERR_INVALIDRULE                :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_INVALIDRULE);
    ApdSRERR_RULEALREADYACTIVE          :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_RULEALREADYACTIVE);
    ApdSRERR_RULENOTACTIVE              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_RULENOTACTIVE);
    ApdSRERR_NOUSERSELECTED             :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_NOUSERSELECTED);
    ApdSRERR_BAD_PRONUNCIATION          :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_BAD_PRONUNCIATION);
    ApdSRERR_DATAFILEERROR              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_DATAFILEERROR);
    ApdSRERR_GRAMMARALREADYACTIVE       :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARALREADYACTIVE);
    ApdSRERR_GRAMMARNOTACTIVE           :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARNOTACTIVE);
    ApdSRERR_GLOBALGRAMMARALREADYACTIVE :
      raise EApdSapiEngineException.Create (ErrorCode,
                                       ApdStrSRERR_GLOBALGRAMMARALREADYACTIVE);
    ApdSRERR_LANGUAGEMISMATCH           :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_LANGUAGEMISMATCH);
    ApdSRERR_MULTIPLELANG               :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_MULTIPLELANG);
    ApdSRERR_LDGRAMMARNOWORDS           :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_LDGRAMMARNOWORDS);
    ApdSRERR_NOLEXICON                  :
      raise EApdSapiEngineException.Create (ErrorCode, ApdStrSRERR_NOLEXICON);
    ApdSRERR_SPEAKEREXISTS              :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_SPEAKEREXISTS);
    ApdSRERR_GRAMMARENGINEMISMATCH      :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_GRAMMARENGINEMISMATCH);
    ApdSRERR_BOOKMARKEXISTS             :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_BOOKMARKEXISTS);
    ApdSRERR_BOOKMARKDOESNOTEXIST       :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_BOOKMARKDOESNOTEXIST);
    ApdSRERR_MICWIZARDCANCELED          :
      raise EApdSapiEngineException.Create (ErrorCode,
                                            ApdStrSRERR_MICWIZARDCANCELED);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -