SpeechEventInfo 结构
定义
用于指定事件的类型及其将生成的参数(如果有的话)作为文本呈现到语音一部分由自定义复合语音引擎。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.
public value class SpeechEventInfo : IEquatable<System::Speech::Synthesis::TtsEngine::SpeechEventInfo>
public struct SpeechEventInfo : IEquatable<System.Speech.Synthesis.TtsEngine.SpeechEventInfo>
type SpeechEventInfo = struct
Public Structure SpeechEventInfo
Implements IEquatable(Of SpeechEventInfo)
- 继承
- 实现
示例
下面的示例是继承自的自定义语音合成实现的一部分 TtsEngineSsml ,并使用 TextFragment 、 SpeechEventInfo 、 FragmentState 和 TtsEventIdThe example below is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, SpeechEventInfo, FragmentState, and TtsEventId
的实现 SpeakThe implementation of Speak
接收实例的数组 TextFragment ,并创建 TextFragment 要
Speak
在基础合成引擎上传递给方法的新的实例数组。Receives an array of TextFragment instances and creates a new array of TextFragment instances to be passed to theSpeak
method on an underlying synthesis engine.如果在 TtsEngineAction Action FragmentState 每个实例的属性返回的的属性中找到枚举值 State ,则 TextFragment Speak 实现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
将 Americanism 转换为要口述的文本中的 Britishisms。Translates Americanism to Britishisms in the text to be spoken.
如果 EventInterest ITtsEngineSite 提供给实现的接口上的属性支持 WordBoundary 事件类型,则 SpeechEventInfo 使用实例创建事件来驱动合成器进度计量。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.
然后,将使用修改后的数组调用语音呈现引擎 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);
}
注解
自定义语音合成引擎通过 SpeechEventInfo 向 AddEvents ITtsEngineSite 传递到、和的实现的引擎站点对象成员提供相应的实例,请求在语音平台下生成事件 Speak AddLexicon RemoveLexicon 。A custom speech synthesis 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.
构造函数
SpeechEventInfo(Int16, Int16, Int32, IntPtr) |
构造相应的 SpeechEventInfo。Constructs an appropriate SpeechEventInfo. |
属性
EventId |
获取和设置 SpeechEventInfo 实例用于请求的语音平台事件。Gets and set the Speech platform event which an instance of SpeechEventInfo is used to request. |
Param1 |
获取和设置 |
Param2 |
获取和设置 |
ParameterType |
返回当前 Param2 对象上的 SpeechEventInfo 参数返回的 IntPtr 所指向的对象的数据类型。Returns the data type of the object pointed to by the IntPtr returned by the Param2 parameter on the current SpeechEventInfo object. |
方法
Equals(Object) |
确定指定的对象是否为 |
Equals(SpeechEventInfo) |
确定指定的 |
GetHashCode() |
提供 |
运算符
Equality(SpeechEventInfo, SpeechEventInfo) |
确定两个 |
Inequality(SpeechEventInfo, SpeechEventInfo) |
确定两个 |