TtsEngineAction 枚举

定义

指定在呈现特定 TextFragment将采用的语音合成标记语言(SSML)事件。Specifies the Speech Synthesis Markup Language (SSML) action to be taken in rendering a given TextFragment.

public enum class TtsEngineAction
public enum TtsEngineAction
type TtsEngineAction = 
Public Enum TtsEngineAction
继承
TtsEngineAction

字段

Bookmark 3

指示 TextFragment 将用作书签的内容。Indicates that TextFragment is to be used as the contents of a bookmark. 它对应于 SSML 规范中的 <mark> XML 标记。It corresponds to the <mark> XML tag in the SSML specification.

ParseUnknownTag 7

指示没有通过 SSML 输入确定的操作。Indicates that no action has been determined from SSML input. 此输出可以由合成引擎自行解释或忽略。This input that may be interpreted or ignored by at the discretion of a synthesis engine. 关联的 TextFragment 是未知的 XML 标记,不属于 SSML 标准。The associated TextFragment is an unknown XML tag not part of the SSML standard.

Pronounce 2

请求输入 TextFragment 文本将被解释为音素。Requests that input TextFragment text be interpreted as phonemes. 准确的发音由 TextFragment 实例上的 State 属性返回的 FragmentState 对象的 Phoneme 成员指定。Exact pronunciation is specified by the Phoneme member of the FragmentState object returned by the State property on TextFragment instances. 对应于 SSML 规范中的 <phoneme> XML 标记。It corresponds to the <Phoneme> XML tag in the SSML specification.

Silence 1

指示 TextFragment 不包含要作为语音呈现的文本。Indicates that a TextFragment contains no text to be rendered as speech. 安静持续时间由 State 属性在 TextFragment 实例上返回的 FragmentState 对象的 Duration 属性指定。Duration of the silence is specified by the Duration property of the the FragmentState object returned by the State property on TextFragment instances. 对应于 SSML 规范中的 <Silence> XML 标记。It corresponds to the <Silence> XML tag in the SSML specification.

Speak 0

请求应处理和通知的关联的 TextFragmentRequests that the associated TextFragment should be processed and spoken. 这是 TextFragment 的默认值。This is the default value for a TextFragment. 它对应于 SSML 规范中的 <speak> XML 标记。It corresponds to the <speak> XML tag in the SSML specification.

SpellOut 4

指示由 TextFragment 通过其 TextToSpeak 属性提供的文本值将聚合为单独的字符。Indicates that text values provided by a TextFragment through its TextToSpeak property are to be synthesize as individual characters. 此呈现包括除空格之外的标点符号以及字母数字文本。This rendering includes punctuation, other than white space, as well as alphanumeric text. 例如,关联的文本片段“word!”For example, the associated text fragment "word!" 应合成“w o r d 感叹号”。should be synthesized into "w o r d exclamation point".

StartParagraph 6

指示段落的状态。Indicates state of paragraph. 对应于 SSML 规范中的 <p> XML 标记。It corresponds to the <p> XML tag in the SSML specification.

StartSentence 5

指示句子开头。Indicates start of sentence. 对应于 SSML 规范中的 <s> XML 标记。It corresponds to the <s> XML tag in the SSML specification.

示例

下面的示例是自定义语音合成实现的一部分TtsEngineSsml, 该TextFragment实现继承自, 并使用、 FragmentStateTtsEventIdThe following example is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, FragmentState, and TtsEventId

的实现SpeakThe implementation of Speak

  1. 接收实例的TextFragment数组, 并创建Speak要在基础合成TextFragment引擎上传递给方法的新的实例数组。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. Action FragmentState State如果通过在每个TextFragment实例的属性返回的属性中找到枚举值就会说出,则实现TtsEngineActionIf 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的接口上的属性支持事件类型,则将创建一个用于驱动合成器进度计量的事件。TtsEventId.WordBoundaryIf the EventInterest property on the ITtsEngineSite interface provided to the implementation support the TtsEventId.WordBoundary event type, an event to drive a synthesizer progress meter is created.

  3. 然后, 将使用修改后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);

}

注解

TtsEngineAction表示为提供服务的TextFragment请求。TtsEngineAction represents requests for servicing a TextFragment. 操作与 SSML 规范中的元素密切对应, 并且是在TextToSpeak TextFragment上的属性返回的文本上实现的。The actions correspond closely to elements in the SSML specification and are implemented on the text returned by the TextToSpeak property on a TextFragment.

与关联的State值由属性返回。 TtsEngineAction TextFragmentThe TtsEngineAction value associated with a TextFragment is returned by the State property.

对属性返回Speak的值的处理由派生自TtsEngineSsml的类上的方法的语音合成实现处理。 TtsEngineAction StateProcessing of the TtsEngineAction value returned by the State property is handled by a speech synthesizes implementation of the Speak method on a class derived from TtsEngineSsml.

适用于