שתף באמצעות


TtsEngineAction Enum

Definition

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
Inheritance
TtsEngineAction

Fields

Name Value Description
Speak 0

Requests that the associated TextFragment should be processed and spoken. This is the default value for a TextFragment. It corresponds to the <speak> XML tag in the SSML specification.

Silence 1

Indicates that a TextFragment contains no text to be rendered as speech. Duration of the silence is specified by the Duration property of the FragmentState object returned by the State property on TextFragment instances. It corresponds to the <Silence> XML tag in the SSML specification.

Pronounce 2

Requests that input TextFragment text be interpreted as phonemes. Exact pronunciation is specified by the Phoneme member of the FragmentState object returned by the State property on TextFragment instances. It corresponds to the <Phoneme> XML tag in the SSML specification.

Bookmark 3

Indicates that TextFragment is to be used as the contents of a bookmark. It corresponds to the <mark> XML tag in the SSML specification.

SpellOut 4

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. For example, the associated text fragment "word!" should be synthesized into "w o r d exclamation point".

StartSentence 5

Indicates start of sentence. It corresponds to the <s> XML tag in the SSML specification.

StartParagraph 6

Indicates state of paragraph. It corresponds to the <p> XML tag in the SSML specification.

ParseUnknownTag 7

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. The associated TextFragment is an unknown XML tag not part of the SSML standard.

Examples

The following example is part of a custom speech synthesis implementation inheriting from TtsEngineSsml, and using the use of TextFragment, FragmentState, and TtsEventId

The implementation of Speak

  1. 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. 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 interface provided to the implementation support the TtsEventId.WordBoundary event type, an event to drive a synthesizer progress meter is created.

  3. 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);

}

Remarks

TtsEngineAction represents requests for servicing a 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.

The TtsEngineAction value associated with a TextFragment is returned by the State property.

Processing 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.

Applies to