TtsEventId TtsEventId TtsEventId TtsEventId Enum

定義

列舉語音合成器事件的類型。Enumerates types of speech synthesis events.

public enum class TtsEventId
public enum TtsEventId
type TtsEventId = 
Public Enum TtsEventId
繼承

欄位

AudioLevel AudioLevel AudioLevel AudioLevel 9

識別語音合成引擎在說出時完成音訊層級變更時所產生的事件。Identifies events generated when a speech synthesize engine completes an audio level change while speaking.

Bookmark Bookmark Bookmark Bookmark 4

識別語音合成引擎在說出時遇到書籤時所產生的事件。Identifies events generated when a speech synthesize engine encounters a bookmark while speaking.

EndInputStream EndInputStream EndInputStream EndInputStream 2

識別語音合成引擎在說出時遇到輸入資料流結尾時所產生的事件。Identifies events generated when a speech synthesize engine encounters the end of its input stream while speaking.

Phoneme Phoneme Phoneme Phoneme 6

識別語音合成引擎完成說出音素時所產生的事件。Identifies events generated when a speech synthesize engine completes a phoneme while speaking.

SentenceBoundary SentenceBoundary SentenceBoundary SentenceBoundary 7

識別語音合成引擎完成說出句子時所產生的事件。Identifies events generated when a speech synthesize engine completes a sentence while speaking.

StartInputStream StartInputStream StartInputStream StartInputStream 1

識別語音合成引擎開始說出資料流時所產生的事件。Identifies events generated when a speech synthesize engine a begins speaking a stream.

Viseme Viseme Viseme Viseme 8

識別語音合成引擎完成說出視素 (Viseme) 時所產生的事件。Identifies events generated when a speech synthesize engine completes a viseme while speaking.

VoiceChange VoiceChange VoiceChange VoiceChange 3

識別語音合成引擎在說出時遇到語音變更時所產生的事件。Identifies events generated when a speech synthesize engine encounters a change of Voice while speaking.

WordBoundary WordBoundary WordBoundary WordBoundary 5

識別語音合成引擎完成說出單字時所產生的事件。Identifies events generated when a speech synthesize engine completes a word while speaking.

範例

下列範例是繼承自客製化語音合成器實作的一部分TtsEngineSsml,並使用將TextFragmentSpeechEventInfoFragmentState,及 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. 如果TtsEngineAction列舉值,藉由從找到Action屬性上的Action所傳回State屬性的每個State執行個體是TtsEngineAction,實作If the TtsEngineAction enumeration value by found from the Action property on the Action returned by the State property of each State instance is TtsEngineAction, the implementation

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

    • 如果EventInterest上的屬性EventInterest支援 WordBoundary 事件類型,提供給實作的介面SpeechEventInfo執行個體用來建立事件,以便建立合成進度計量表的磁碟機。If the EventInterest property on the EventInterest 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);  

}  

備註

客製化語音合成引擎定義的事件提交至語音平台合成器基礎結構,具有類型TtsEventIdCustom speech synthesis engines define the types of events submitted to the Speech platform synthesizer infrastructure with the TtsEventId.

藉由設定執行規格EventId屬性SpeechEventInfo執行個體會傳遞至AddEvents的實作類別成員ITtsEngineSite介面傳遞至Speak客製化語音引擎上的方法實作TtsEngineSsmlSpecification is performed by setting the EventId property of SpeechEventInfo instances passed to the AddEvents member of the class implementing the ITtsEngineSite interface passed to the Speak method on a custom speech engine's implementation of TtsEngineSsml.

語音平台基礎結構表示它目前正在處理透過事件的類型EventInterest屬性上的ITtsEngineSite傳遞至語音讀出; 實作。The Speech platform infrastructure indicates the type of events it is currently handling through the EventInterest property on the ITtsEngineSite passed to the speak implementation.

EventInterest的位元遮罩,其中的成員TtsEventId定義對應的事件類型的位元的位置。The value of EventInterest is a bitmask, where the members of TtsEventId define the location of the bit corresponding to the event type. 比方說,WordBoundary 其值為五 (5),這表示在所傳回的值中的第五個位元EventInterest指出是否站台支援的事件類型。For example, WordBoundary has a value of five (5), meaning the fifth bit in the value returned by EventInterest indicates if the site supports the event type.

適用於