TtsEventId TtsEventId TtsEventId TtsEventId Enum

Definition

Enumerates types of speech synthesis events.

public enum class TtsEventId
public enum TtsEventId
type TtsEventId = 
Public Enum TtsEventId
Inheritance

Fields

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

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.

Examples

The example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId

The implementation of Speak

  1. 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. 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

    • Translates Americanism to Britishisms in the text to be spoken.

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

}  

Remarks

Custom speech synthesis engines define the types of events submitted to the Speech platform synthesizer infrastructure with the TtsEventId.

Specification 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.

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.

The value of EventInterest is a bitmask, where the members of TtsEventId define the location of the bit corresponding to the event type. 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.

Applies to