TtsEngineAction TtsEngineAction TtsEngineAction TtsEngineAction Enum

定義

指定呈現指定之 TextFragment 要採取的語音合成標記語言 (SSML) 動作。Specifies the Speech Synthesis Markup Language (SSML) action to be taken in rendering a given TextFragment.

public enum class TtsEngineAction
public enum TtsEngineAction
type TtsEngineAction = 
Public Enum TtsEngineAction
繼承
TtsEngineActionTtsEngineActionTtsEngineActionTtsEngineAction

欄位

Bookmark Bookmark Bookmark Bookmark 3

表示 TextFragment 是做為書籤的內容。Indicates that TextFragment is to be used as the contents of a bookmark. 它會對應於 SSML 規格中的 <mark> XML 標記。It corresponds to the <mark> XML tag in the SSML specification.

ParseUnknownTag ParseUnknownTag ParseUnknownTag ParseUnknownTag 7

表示尚未從 SSML 輸入決定採取任何動作。Indicates that no action has been determined from SSML input. 根據合成引擎的判斷,可能會解譯或忽略這項輸入。This input that may be interpreted or ignored by at the discretion of a synthesis engine. 關聯的 TextFragment 是未知的 XML 標記,不是 SSML 標準的一部分。The associated TextFragment is an unknown XML tag not part of the SSML standard.

Pronounce Pronounce Pronounce Pronounce 2

要求輸入 TextFragment 文字被解譯為音素。Requests that input TextFragment text be interpreted as phonemes. 確切發音是由 TextFragment 執行個體上 State 屬性所傳回 FragmentState 物件的 Phoneme 成員指定。Exact pronunciation is specified by the Phoneme member of the FragmentState object returned by the State property on TextFragment instances. 它會對應於 SSML 規格中的 <Phoneme> XML 標記。It corresponds to the <Phoneme> XML tag in the SSML specification.

Silence Silence Silence Silence 1

表示 TextFragment 不包含要轉譯為語音的文字。Indicates that a TextFragment contains no text to be rendered as speech. 靜音持續時間是由 TextFragment 執行個體上 State 屬性所傳回 FragmentState 物件的 Duration 屬性指定。Duration of the silence is specified by the Duration property of the the FragmentState object returned by the State property on TextFragment instances. 它會對應於 SSML 規格中的 <Silence> XML 標記。It corresponds to the <Silence> XML tag in the SSML specification.

Speak Speak Speak Speak 0

要求相關的 TextFragment 應該加以處理並讀出。Requests that the associated TextFragment should be processed and spoken. 這是 TextFragment 的預設值。This is the default value for a TextFragment. 它會對應於 SSML 規格中的 <speak> XML 標記。It corresponds to the <speak> XML tag in the SSML specification.

SpellOut SpellOut SpellOut SpellOut 4

表示由 TextFragment 透過其 TextToSpeak 屬性提供的文字值要當做個別字元進行合成。Indicates that text values provided by a TextFragment through its TextToSpeak property are to be synthesize as individual characters. 這個轉譯包括空白字元以外的標點符號,以及英數文字。This rendering includes punctuation, other than white space, as well as alphanumeric text. 例如,關聯的文字片段 "word!"For example, the associated text fragment "word!" 應該合成為 "w o r d exclamation point"。should be synthesized into "w o r d exclamation point".

StartParagraph StartParagraph StartParagraph StartParagraph 6

表示段落的狀態。Indicates state of paragraph. 它會對應於 SSML 規格中的 <p> XML 標記。It corresponds to the <p> XML tag in the SSML specification.

StartSentence StartSentence StartSentence StartSentence 5

表示句子的開頭。Indicates start of sentence. 它會對應於 SSML 規格中的 <s> XML 標記。It corresponds to the <s> XML tag in the SSML specification.

範例

下列範例是從TtsEngineSsml繼承的自訂語音合成實作為的一部分, 以及使用TextFragmentFragmentState和的TtsEventIdThe following example is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, 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如果在每個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 給執行EventInterest的介面上的屬性支援事件種類,則會建立一個事件來驅動合成器進度計量表。TtsEventIdIf the EventInterest property on the EventInterest interfaces provided to the implementation support the TtsEventId event type, 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);  

}  

備註

TtsEngineAction表示服務的TextFragment要求。TtsEngineAction represents requests for servicing a TextFragment. 動作會與 SSML 規格中的元素緊密對應, 並在TextToSpeak TextFragment上由屬性所傳回的文字上執行。The actions correspond closely to elements in the SSML specification and are implemented on the text returned by the TextToSpeak property on a TextFragment.

與相關聯StateTtsEngineAction值是TextFragment由屬性傳回。The TtsEngineAction value associated with a TextFragment is returned by the State property.

屬性所傳回TtsEngineAction Speak的值處理是由衍生自之TtsEngineSsml類別上的方法語音合成執行所處理。 StateProcessing of the TtsEngineAction value returned by the State property is handled by a speech synthesizes implementation of the Speak method on a class derived from TtsEngineSsml.

適用於