SpeechEventInfo.ParameterType プロパティ

定義

現在の Param2 オブジェクトの SpeechEventInfo パラメーターが返す IntPtr によってポイントされるオブジェクトのデータ型を返します。

public:
 property short ParameterType { short get(); };
public short ParameterType { get; }
member this.ParameterType : int16
Public ReadOnly Property ParameterType As Short

プロパティ値

EventParameterType の列挙体のメンバーに対応し、Param2 パラメーターによって返される short でポイントされるオブジェクトのデータ型を示し、現在の SpeechEventInfo オブジェクトのコンストラクターに 2 番目の引数として使用される IntPtr 値。

次の例は、 をTtsEngineSsml継承し、および を使用するカスタム音声合成実装のTextFragmentSpeechEventInfoFragmentState一部ですTtsEventId

の実装 Speak

  1. インスタンスの TextFragment 配列を受け取り、基になる合成エンジンの TextFragment メソッドに渡されるインスタンスの Speak 新しい配列を作成します。

  2. 各インスタンスの TtsEngineAction プロパティによって返される の FragmentState プロパティから Action 見つかった のState列挙値が の場合、実装は ですSpeakTextFragment

    • 話されるテキストでアメリカ主義を英国主義に翻訳します。

    • EventInterest実装に提供されるインターフェイスの ITtsEngineSite プロパティでイベントの種類がWordBoundaryサポートされている場合は、インスタンスをSpeechEventInfo使用して、シンセサイザーの進行状況メーターを駆動するイベントが作成されます。

      SpeechEventInfoParameterType パラメーターは、 メソッドを介してLogSpeechEvent生成されたイベントをログに記録するために使用されます。

  3. その後、変更された TextFragment 配列を使用して音声レンダリング エンジンが呼び出されます。

private const int WordBoundaryFlag = 1 << (int)TtsEventId.WordBoundary;  
private readonly char[] spaces = new char[] { ' ', '\t', '\r', '\n' };  
internal struct UsVsUk  
{  
  internal string UK;  
  internal string US;  
}  

override public void Speak (TextFragment [] frags, IntPtr wfx, ITtsEngineSite site)  
{  
  TextFragment [] newFrags=new TextFragment[frags.Length];  

  for (int i=0;i<frags.Length;i++){  
    newFrags[i].State=frags[i].State;  
    //truncate  
    newFrags[i].TextToSpeak = frags[i].TextToSpeak.Substring(frags[i].TextOffset,  
                               frags[i].TextLength);  
    newFrags[i].TextLength = newFrags[i].TextToSpeak.Length;  
    newFrags[i].TextOffset = 0;  
    if (newFrags[i].State.Action == TtsEngineAction.Speak) {  
      //Us to UK conversion  
      foreach (UsVsUk term in TransList) {  
      newFrags[i].TextToSpeak.Replace(term.US, term.UK);  
      }  
      //Generate progress meter events if supported  
      if ((site.EventInterest & WordBoundaryFlag) != 0) {  
      string[] subs = newFrags[i].TextToSpeak.Split(spaces);  

      foreach (string s in subs) {  
        int offset = newFrags[i].TextOffset;  
        SpeechEventInfo spEvent = new SpeechEventInfo((Int16)TtsEventId.WordBoundary,   
                (Int16)EventParameterType.Undefined,   
                 s.Length, new IntPtr(offset));  
         LogSpeechEvent(spEvent.EventId,   
                        spEvent.ParameterType,   
                        spEvent.Param1,  
                        spEvent.Param2);  
        offset += s.Length;  
        if (s.Trim().Length > 0) {  
          SpeechEventInfo[] events = new SpeechEventInfo[1];  
          events[0] = spEvent;  
          site.AddEvents(events, 1);  
        }  
      }  
      }  
    }  
  }  

  _baseSynthesize.Speak(newFrags, wfx, site);  

}  

注釈

の プロパティの参照に関System.IntPtrするParam2要件は、インスタンスの および プロパティSpeechEventInfoEventIdParameterType値によって一意にSpeechEventInfo決定されます。

の使用方法 Param2の詳細については、 のドキュメントを EventId参照してください。

適用対象