SpeechEventInfo SpeechEventInfo SpeechEventInfo SpeechEventInfo Struct

定義

用來指定要在自訂合成語音引擎將文字轉譯為語音過程中產生之事件的型別及其引數 (如果有的話)。Used to specify the type of event, and its arguments (if any) to be generated as part of the rendering of text to speech by a custom synthetic speech engine.

public value class SpeechEventInfo : IEquatable<System::Speech::Synthesis::TtsEngine::SpeechEventInfo>
public struct SpeechEventInfo : IEquatable<System.Speech.Synthesis.TtsEngine.SpeechEventInfo>
type SpeechEventInfo = struct
Public Structure SpeechEventInfo
Implements IEquatable(Of SpeechEventInfo)
繼承
SpeechEventInfoSpeechEventInfoSpeechEventInfoSpeechEventInfo
實作

範例

以下範例是自訂語音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.

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

}  

備註

自訂語音合成引擎會向傳遞SpeechEventInfo至之Speak執行的ITtsEngineSite引擎網站物件成員提供適當的實例AddEvents , 以要求在語音平臺下產生事件。AddLexicon、和RemoveLexiconA custom speech synthesis engine requests the generation of events under the Speech Platform by providing an appropriate SpeechEventInfo instance to AddEvents member of the ITtsEngineSite engine site object passed to implementations of Speak, AddLexicon, and RemoveLexicon.

建構函式

SpeechEventInfo(Int16, Int16, Int32, IntPtr) SpeechEventInfo(Int16, Int16, Int32, IntPtr) SpeechEventInfo(Int16, Int16, Int32, IntPtr) SpeechEventInfo(Int16, Int16, Int32, IntPtr)

建構適當的 SpeechEventInfoConstructs an appropriate SpeechEventInfo.

屬性

EventId EventId EventId EventId

取得和設定使用 SpeechEventInfo 之執行個體進行要求的語音平台事件。Gets and set the Speech platform event which an instance of SpeechEventInfo is used to request.

Param1 Param1 Param1 Param1

取得和設定 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.

Param2 Param2 Param2 Param2

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

ParameterType ParameterType ParameterType ParameterType

傳回目前 Param2 物件上 SpeechEventInfo 參數所傳回的 IntPtr 所指向之物件的資料型別。Returns the data type of the object pointed to by the IntPtr returned by the Param2 parameter on the current SpeechEventInfo object.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否為 SpeechEventInfo 的執行個體且等於 SpeechEventInfo 目前的執行個體。Determines whether a specified object is an instance of SpeechEventInfo and equal to the current instance of SpeechEventInfo.

Equals(SpeechEventInfo) Equals(SpeechEventInfo) Equals(SpeechEventInfo) Equals(SpeechEventInfo)

判斷指定的 SpeechEventInfo 物件是否等於 SpeechEventInfo 目前的執行個體。Determines whether a specified SpeechEventInfo object is equal to the current instance of SpeechEventInfo.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

提供 SpeechEventInfo 物件的雜湊碼。Provides a hash code for a SpeechEventInfo object.

運算子

Equality(SpeechEventInfo, SpeechEventInfo) Equality(SpeechEventInfo, SpeechEventInfo) Equality(SpeechEventInfo, SpeechEventInfo) Equality(SpeechEventInfo, SpeechEventInfo)

判斷 SpeechEventInfo 的兩個執行個體是否相等。Determines whether two instances of SpeechEventInfo are equal.

Inequality(SpeechEventInfo, SpeechEventInfo) Inequality(SpeechEventInfo, SpeechEventInfo) Inequality(SpeechEventInfo, SpeechEventInfo) Inequality(SpeechEventInfo, SpeechEventInfo)

判斷 SpeechEventInfo 的兩個執行個體是否不相等。Determines whether two instances of SpeechEventInfo are not equal.

適用於