SpeechEventInfo.Param1 SpeechEventInfo.Param1 SpeechEventInfo.Param1 SpeechEventInfo.Param1 Property

定義

取得和設定 integer值 (建構函式中的 param1),這個值要傳遞至語音平台以產生使用 SpeechEventInfo 之目前執行個體進行要求的事件。Gets and set the integer value (param1 in the constructor) to be passed to the Speech platform to generate an event the current instance of SpeechEventInfo is used to request.

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

屬性值

傳回在目前的 SpeechEventInfo 執行個體所指定的事件產生時,要傳遞至語音平台的 integerReturns the integer to be passed to Speech platform when the event specified by the current instance of SpeechEventInfo is generated.

範例

以下範例是自訂語音TtsEngineSsml合成實作為繼承自的一部分, 並使用TextFragmentSpeechEventInfo FragmentState、和TtsEventIdThe example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId

的執行SpeakThe implementation of Speak

  1. 接收實例的TextFragment陣列, 並建立要傳遞至基礎TextFragment合成引擎上方法的Speak新實例陣列。Receives an array of TextFragment instances and creates a new array of TextFragment instances to be passed to the Speak method on an underlying synthesis engine.

  2. Action FragmentState Speak如果在每個State實例的屬性所傳回之的屬性中找到的列舉值為,則會執行TtsEngineAction TextFragmentIf the TtsEngineAction enumeration value by found from the Action property on the FragmentState returned by the State property of each TextFragment instance is Speak, the implementation

    • 在要讀出的文字中, 將 Americanism 轉譯為 Britishisms。Translates Americanism to Britishisms in the text to be spoken.

    • 如果提供EventInterest ITtsEngineSite 給實SpeechEventInfo作為之介面上的屬性支援事件種類,則會使用實例來建立事件,以驅動合成器進度計量器的建立。WordBoundaryIf the EventInterest property on the ITtsEngineSite interfaces provided to the implementation support the WordBoundary event type, a SpeechEventInfo instance is used to create an event to drive a synthesizer progress meter is created.

      SpeechEventInfo的參數 (包括Param1 ) 會用來記錄透過LogSpeechEvent方法所產生的事件。The parameters on SpeechEventInfo, including Param1 are used to log the event generated through the LogSpeechEvent method.

  3. 然後使用修改過TextFragment的陣列呼叫語音轉譯引擎。A speech rendering engine is then called with the modified TextFragment array.

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);  

}  

備註

Param1屬性EventIdSpeechEventInfo需求和意義, 是由SpeechEventInfo實例的和ParameterType屬性值唯一決定。The requirements and meaning of Param1 property of SpeechEventInfo are uniquely determined by the values of the EventId and ParameterType properties the SpeechEventInfo instance.

如需如何使用Param1的詳細資訊, 請參閱的EventId檔。For detailed information on how use Param1, see documentation for EventId.

適用於