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

📄 adsapien.pas

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

    {Look through all of the owned components}
    for I := 0 to C.ComponentCount - 1 do begin
      if C.Components[I] is TApdCustomSapiEngine then begin
        Result := TApdCustomSapiEngine (C.Components[I]);
        Exit;
      end;

      {If this isn't one, see if it owns other components}
      Result := FindSapiEngine (C.Components[I]);
    end;
  end;

begin
  {Search the entire form}
  Result := FindSapiEngine (C);
end;

{ EApdSapiEngineException }

constructor EApdSapiEngineException.Create (const ErrCode : Integer;
                                            const Msg : string);
begin
  inherited Create (Msg);

  FErrorCode := ErrCode;
end;

{ TApdSSVoices }

function TApdSSVoices.CheckIndex (x : Integer) : Boolean;
begin
  if not Assigned (FiDirectSS) then
    raise EApdSapiEngineException.CreateFmt (ecApdNOSS, [0]);
  if (x < 0) or (x >= FiDirectSS.CountEngines) then
    raise EApdSapiEngineException.CreateFmt (ecApdBadIndex, [0]);
  Result := True;
end;

function TApdSSVoices.Find (Criteria : string) : Integer;
begin
  Result := FiDirectSS.Find (Criteria);
end;

function TApdSSVoices.GetAge (x : Integer) : TApdTTSAge;

  function ConvertAge (v : Integer) : TApdTTSAge;
  begin
    case v of
      ApdTTSAGE_BABY       : Result := tsBaby;
      ApdTTSAGE_TODDLER    : Result := tsToddler;
      ApdTTSAGE_CHILD      : Result := tsChild;
      ApdTTSAGE_ADOLESCENT : Result := tsAdolescent;
      ApdTTSAGE_ADULT      : Result := tsAdult;
      ApdTTSAGE_ELDERLY    : Result := tsElderly;
    else
      Result := tsUnknown;
    end;
  end;

begin
  CheckIndex (x);
  Result := ConvertAge (FiDirectSS.Age (x + 1));
end;

function TApdSSVoices.GetCount : Integer;
begin
  Result := FiDirectSS.CountEngines;
end;

function TApdSSVoices.GetCurrentVoice : Integer;
begin
  result := FCurrentVoice;
end;

function TApdSSVoices.GetDialect (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSS.Dialect (x + 1);
end;

function TApdSSVoices.GetEngineFeatures (x : Integer) : Integer;
begin
  CheckIndex (x);
  Result := FiDirectSS.EngineFeatures (x + 1);
end;

function TApdSSVoices.GetEngineID (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSS.EngineID (x + 1);
end;

function TApdSSVoices.GetFeatures (x : Integer) : TApdTTSFeatures;

  function ConvertFeatures (v : Integer) :  TApdTTSFeatures;
  begin
    Result := [];
    if (v and ApdTTSFEATURE_ANYWORD) <> 0 then
      Result := Result + [tfAnyWord];
    if (v and ApdTTSFEATURE_VOLUME) <> 0 then
      Result := Result + [tfVolume];
    if (v and ApdTTSFEATURE_SPEED) <> 0 then
      Result := Result + [tfSpeed];
    if (v and ApdTTSFEATURE_PITCH) <> 0 then
      Result := Result + [tfPitch];
    if (v and ApdTTSFEATURE_TAGGED) <> 0 then
      Result := Result + [tfTagged];
    if (v and ApdTTSFEATURE_IPAUNICODE) <> 0 then
      Result := Result + [tfIPAUnicode];
    if (v and ApdTTSFEATURE_VISUAL) <> 0 then
      Result := Result + [tfVisual];
    if (v and ApdTTSFEATURE_WORDPOSITION) <> 0 then
      Result := Result + [tfWordPosition];
    if (v and ApdTTSFEATURE_PCOPTIMIZED) <> 0 then
      Result := Result + [tfPCOptimized];
    if (v and ApdTTSFEATURE_PHONEOPTIMIZED) <> 0 then
      Result := Result + [tfPhoneOptimized];
    if (v and ApdTTSFEATURE_FIXEDAUDIO) <> 0 then
      Result := Result + [tfFixedAudio];
    if (v and ApdTTSFEATURE_SINGLEINSTANCE) <> 0 then
      Result := Result + [tfSingleInstance];
    if (v and ApdTTSFEATURE_THREADSAFE) <> 0 then
      Result := Result + [tfThreadSafe];
    if (v and ApdTTSFEATURE_IPATEXTDATA) <> 0 then
      Result := Result + [tfIPATextData];
    if (v and ApdTTSFEATURE_PREFERRED) <> 0 then
      Result := Result + [tfPreferred];
    if (v and ApdTTSFEATURE_TRANSPLANTED) <> 0 then
      Result := Result + [tfTransplanted];
    if (v and ApdTTSFEATURE_SAPI4) <> 0 then
      Result := Result + [tfSAPI4];
  end;

begin
  CheckIndex (x);
  Result := ConvertFeatures (FiDirectSS.Features (x + 1));
end;

function TApdSSVoices.GetGender (x : Integer) : TApdTTSGender;

  function ConvertGender (v : Integer) : TApdTTSGender;
  begin
    case v of
      ApdGENDER_NEUTRAL : Result := tgNeutral;
      ApdGENDER_FEMALE  : Result := tgFemale;
      ApdGENDER_MALE    : Result := tgMale;
    else
       Result := tgUnknown;
    end;
  end;

begin
  CheckIndex (x);
  Result := ConvertGender (FiDirectSS.Gender (x + 1));
end;

function TApdSSVoices.GetInterfaces (x : Integer) : TApdTTSInterfaces;

  function ConvertInterfaces (v : Integer) : TApdTTSInterfaces;
  begin
    Result := [];
    if (v and ApdTTSI_ILEXPRONOUNCE) <> 0 then
      Result := Result + [tiLexPronounce];
    if (v and ApdTTSI_ITTSATTRIBUTES) <> 0 then
      Result := Result + [tiTTSAttributes];
    if (v and ApdTTSI_ITTSCENTRAL) <> 0 then
      Result := Result + [tiTTSCentral];
    if (v and ApdTTSI_ITTSDIALOGS) <> 0 then
      Result := Result + [tiTTSDialogs];
    if (v and ApdTTSI_ATTRIBUTES) <> 0 then
      Result := Result + [tiAttributes];
    if (v and ApdTTSI_IATTRIBUTES) <> 0 then
      Result := Result + [tiIAttributes];
    if (v and ApdTTSI_ILEXPRONOUNCE2) <> 0 then
      Result := Result + [tiLexPronounce2];
  end;

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

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

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

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

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

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

function TApdSSVoices.GetSpeaker (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSS.Speaker (x + 1);
end;

function TApdSSVoices.GetStyle (x : Integer) : string;
begin
  CheckIndex (x);
  Result := FiDirectSS.Style (x + 1);
end;

procedure TApdSSVoices.SetCurrentVoice (v : Integer);
begin
  if v <> FCurrentVoice then begin
    CheckIndex (v);
    FiDirectSS.Select (v + 1);
    FCurrentVoice := v;
  end;
end;

{ TApdSREngines }

function TApdSREngines.CheckIndex (x : Integer) : Boolean;
begin
  if not Assigned (FiDirectSR) then
    raise EApdSapiEngineException.CreateFmt (ecApdNoSR, [0]);
  if (x < 0) or (x >= FiDirectSR.CountEngines) then
    raise EApdSapiEngineException.CreateFmt (ecApdBadIndex, [0]);
  Result := True;
end;

function TApdSREngines.GetCount : Integer;
begin
  Result := FiDirectSR.CountEngines;
end;

function TApdSREngines.GetCurrentEngine : Integer;
begin
  Result := FCurrentEngine;
end;

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

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

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

function TApdSREngines.GetFeatures (x : Integer) : TApdSRFeatures;

  function ConvertFeatures (v : Integer) : TApdSRFeatures;
  begin
    Result := [];
    if (v and ApdSRFEATURE_INDEPSPEAKER) <> 0 then
      Result := Result + [sfIndepSpeaker];
    if (v and ApdSRFEATURE_INDEPMICROPHONE) <> 0 then
      Result := Result + [sfIndepMicrophone];
    if (v and ApdSRFEATURE_TRAINWORD) <> 0 then
      Result := Result + [sfTrainWord];
    if (v and ApdSRFEATURE_TRAINPHONETIC) <> 0 then
      Result := Result + [sfTrainPhonetic];
    if (v and ApdSRFEATURE_WILDCARD) <> 0 then
      Result := Result + [sfWildcard];
    if (v and ApdSRFEATURE_ANYWORD) <> 0 then
      Result := Result + [sfAnyWord];
    if (v and ApdSRFEATURE_PCOPTIMIZED) <> 0 then
      Result := Result + [sfPCOptimized];
    if (v and ApdSRFEATURE_PHONEOPTIMIZED) <> 0 then
      Result := Result + [sfPhoneOptimized];
    if (v and ApdSRFEATURE_GRAMLIST) <> 0 then
      Result := Result + [sfGramList];
    if (v and ApdSRFEATURE_GRAMLINK) <> 0 then
      Result := Result + [sfGramLink];
    if (v and ApdSRFEATURE_MULTILINGUAL) <> 0 then
      Result := Result + [sfMultiLingual];
    if (v and ApdSRFEATURE_GRAMRECURSIVE) <> 0 then
      Result := Result + [sfGramRecursive];
    if (v and ApdSRFEATURE_IPAUNICODE) <> 0 then
      Result := Result + [sfIPAUnicode];
    if (v and ApdSRFEATURE_SINGLEINSTANCE) <> 0 then
      Result := Result + [sfSingleInstance];
    if (v and ApdSRFEATURE_THREADSAFE) <> 0 then
      Result := Result + [sfThreadSafe];
    if (v and ApdSRFEATURE_FIXEDAUDIO) <> 0 then
      Result := Result + [sfFixedAudio];
    if (v and ApdSRFEATURE_IPAWORD) <> 0 then
      Result := Result + [sfIPAWord];
    if (v and ApdSRFEATURE_SAPI4) <> 0 then
      Result := Result + [sfSAPI4];
  end;

begin
  CheckIndex (x);
  Result := ConvertFeatures (FiDirectSR.Features (x + 1));
end;

function TApdSREngines.GetGrammars (x : Integer) : TApdSRGrammars;

  function ConvertGrammars (v : Integer) : TApdSRGrammars;
  begin
    Result := [];
    if (v and ApdSRGRAM_CFG) <> 0 then
      Result := Result + [sgCFG];
    if (v and ApdSRGRAM_DICTATION) <> 0 then
      Result := Result + [sgDictation];
    if (v and ApdSRGRAM_LIMITEDDOMAIN) <> 0 then
      Result := Result + [sgLimitedDomain];
  end;

⌨️ 快捷键说明

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