EventParameterType Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Enumerates the types of data pointers passed to speech synthesis events.
public enum class EventParameterType
public enum EventParameterType
type EventParameterType =
Public Enum EventParameterType
- Inheritance
Fields
Name | Value | Description |
---|---|---|
Undefined | 0 | Indicates that the |
Token | 1 | Indicates that the |
Object | 2 | Currently not supported. |
Pointer | 3 | Currently not supported. |
String | 4 | Indicates that the |
Examples
The following example 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
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.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 ParameterType, are used to log the event generated through the
LogSpeechEvent
method.
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));
LogSpeechEvent(spEvent.EventId,
spEvent.ParameterType,
spEvent.Param1,
spEvent.Param2);
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
The EventParameterType
enumeration is used when constructing a SpeechEventInfo object. An EventParameterType
enumeration member passed as the parameterType
argument to the constructor for SpeechEventInfo specifies how the param2
argument of the constructor (which must be an IntPtr) is interpreted.
The choice of EventParameterType
is dictated by the type of event being requested, as specified by a member of System.Speech.Synthesis.TtsEngine.TtsEventId.
For detailed information on how use EventParameterType
, see the documentation for EventId
Note
Currently, instances of a managed synthetic speech engines written using the members of the System.Speech.Synthesis namespace cannot change resources after construction.
Applies to
See also
.NET