This documentation is archived and is not being maintained.

EventParameterType Enumeration

Enumerates the types of data pointers passed to speech synthesis events.

Namespace:  System.Speech.Synthesis.TtsEngine
Assembly:  System.Speech (in System.Speech.dll)

public enum EventParameterType

Member nameDescription
UndefinedIndicates that the param2 argument to the SpeechEventInfo is undefined.

Generally, param1 and param2 are then ignored. However, ifTtsEventId is WordBoundary, a progress meter event can be generated param1 should be an integer containing the length of the current word, and param2 a System.IntPtr referencing an integer containing the offset of the current word.

TokenIndicates that the param2 argument to the SpeechEventInfo is a

is a System.IntPtr created using System.Runtime.InteropServices.Marshal.PtrToStructure

referencing a Windows Desktop Speech Technology token --a Windows Desktop Speech Technology object representing a resource, such as a voice (VoiceInfo); param1 may take on any value.

Currently instances of a managed synthetic speech engines, written using the members of the System.Speech.Synthesis name space, cannot change resources after construction
ObjectCurrently not supported.
PointerCurrently not supported.
StringIndicates that the param2 argument to the SpeechEventInfo is a System.IntPtr created using System.Runtime.InteropServices.Marshal.StringToCoTaskMemUni referencing a System.String object; param1 may take on any value.

EventParameterType is used when constructing a SpeechEventInfo object. An instance of EventParameterType passed as the parameterType argument to the constructor for SpeechEventInfo specifies how the param2 argument of the constructor (which must be a System.IntPtr) is interpreted.

The choice of EventParameterType is dictated by the type of event being requested, as specified by a member of TtsEventId.

For detailed information on how use EventParameterType, see documentation for EventId

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 FragmentState returned by the State property of each TextFragment instance is Speak, the implementation

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

    • If 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.

      The parameters on SpeechEventInfo, including the EventParameterType member value returned by [P:System.Speech.Synthesis.TtsEngine.SpeechEventInfo.ParameterType,] are used to log the event generated through the LogSpeechEvent method.

  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].TextToSpeak = frags[i].TextToSpeak.Substring(frags[i].TextOffset,
    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, 
                 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);

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.