SpeechEventInfo.Param1 屬性

定義

取得和設定 integer值 (建構函式中的 param1),這個值要傳遞至語音平台以產生使用 SpeechEventInfo 之目前執行個體進行要求的事件。

public:
 property int Param1 { int get(); };
public int Param1 { get; }
member this.Param1 : int
Public ReadOnly Property Param1 As Integer

屬性值

Int32

傳回在目前的 SpeechEventInfo 執行個體所指定的事件產生時,要傳遞至語音平台的 integer

範例

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

的執行 Speak

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

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

    • 將要說出的文字中的 Americanism 轉譯為 Britishisms。

    • 如果 EventInterest 提供給實作為的介面上的屬性 ITtsEngineSite 支援 WordBoundary 事件種類,則 SpeechEventInfo 會使用實例來建立事件,以建立可驅動合成器進度計量的事件。

      上的參數 SpeechEventInfo (包括) Param1 會用來記錄透過方法所產生的事件 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);  

}  

備註

的屬性(property)和屬性(property)的需求和意義 Param1 SpeechEventInfo 是由實例的值和屬性(property)唯一決定 EventId ParameterType SpeechEventInfo

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

適用於