SpeechEventInfo.Param1 属性
定义
获取和设置 integer 值(构造函数中的 param1),此值需要传递至语音平台以生成 SpeechEventInfo 的当前实例用于请求的事件。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.
public:
property int Param1 { int get(); };
public int Param1 { get; }
member this.Param1 : int
Public ReadOnly Property Param1 As Integer
属性值
返回生成 SpeechEventInfo 的当前实例指定的事件时,要传递到语音平台的 integer。Returns the integer to be passed to Speech platform when the event specified by the current instance of SpeechEventInfo is generated.
示例
下面的示例是继承自的自定义语音合成实现的一部分 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 theSpeakmethod 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.
上的参数 SpeechEventInfo ,包括 Param1 用于记录通过方法生成的事件
LogSpeechEvent。The parameters on SpeechEventInfo, including Param1 are used to log the event generated through theLogSpeechEventmethod.
然后,将使用修改后的数组调用语音呈现引擎 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));
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);
}
注解
的属性的要求和含义由 Param1 SpeechEventInfo 实例的和属性的值唯一决定 EventId ParameterType SpeechEventInfo 。The requirements and meaning of Param1 property of SpeechEventInfo are uniquely determined by the values of the EventId and ParameterType properties the SpeechEventInfo instance.
有关如何使用的详细信息 Param1 ,请参阅文档 EventId 。For detailed information on how use Param1, see documentation for EventId.