共用方式為


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

屬性值

Int16

對應至 EventParameterType 列舉成員的 short值,指出Param2參數所傳回的IntPtr所指的物件的資料型別,並用來作為目前SpeechEventInfo物件的建構函式的第二個引數。

範例

下列範例是自訂語音合成衍生的一部分 TtsEngineSsml ,並使用 TextFragmentSpeechEventInfoFragmentStateTtsEventId

的執行 Speak

  1. 接收實例的陣列 TextFragment ,並建立新的實例陣列, TextFragment 以傳遞至 Speak 基礎合成引擎上的方法。

  2. 如果在 TtsEngineAction Action FragmentState State 每個實例之屬性所傳回的屬性中找到列舉值,則 TextFragmentSpeak 執行

  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 SpeechEventInfo 是由的值 EventIdParameterType 實例的屬性唯一決定 SpeechEventInfo

如需使用方式的詳細資訊 Param2 ,請參閱的檔 EventId

適用於