SpeechEventInfo Structure
Used to specify the type of event, and its arguments (if any) to be generated as part of the rendering of text to speech by a custom synthetic speech engine.
Assembly: System.Speech (in System.Speech.dll)
The SpeechEventInfo type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | EventId | Gets and set the Speech platform event which an instance of SpeechEventInfo is used to request. |
![]() | Param1 | Gets and set the integer value (param1 in the constructor) to be passed to the Speech platform to generate an event the current instance of SpeechEventInfo is used to request. |
![]() | Param2 | Gets and set the System.IntPtr instance (param2 in the constructor) referencing the object to be passed to the Speech platform to generate an event the current instance of SpeechEventInfo is used to request. |
![]() | ParameterType | Returns the data type of the object pointed to by the IntPtr returned by the Param2 parameter on the current SpeechEventInfo object. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueType::Equals(Object).) |
![]() | Equals(SpeechEventInfo) | |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Overrides ValueType::GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.) |
A custom synthetic speech engine requests the generation of events under the Speech platform by providing an appropriate SpeechEventInfo instance to AddEvents member of the ITtsEngineSite engine site object passed to implementations of Speak, AddLexicon, and RemoveLexicon.
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()
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.
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);
}
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.
