Exemplo n.º 1
0
        public void Add(ISsml element)
        {
            var invalid = new InvalidOperationException($"Unable to add {element.GetType()}");

            switch (AddStack.Peek())
            {
            case Paragraph paragraph:
                if (!(element is IParagraphSsml))
                {
                    throw invalid;
                }
                paragraph.Elements.Add((IParagraphSsml)element);
                break;

            case Sentence sentence:
                if (!(element is ISentenceSsml))
                {
                    throw invalid;
                }
                sentence.Elements.Add((ISentenceSsml)element);
                break;

            default:
                throw invalid;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempt to find a corresponding matching speech data template for the inputted ssml element.
        /// If not, we use the fallback data template.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="container"></param>
        /// <returns></returns>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is ISsml)
            {
                ISsml speech = item as ISsml;
                if (Templates.Exists(x => speech.GetType() == (x.DataType as Type)))
                {
                    return(Templates.Find(x => speech.GetType() == (x.DataType as Type)));
                }

                return(FallbackDataTemplate ?? base.SelectTemplate(item, container));
            }
            else
            {
                return(base.SelectTemplate(item, container));
            }
        }
Exemplo n.º 3
0
 protected FluentSsml(ISsml inner)
 {
     _inner = inner;
 }
Exemplo n.º 4
0
        private void CompareXml(string expected, ISsml ssml)
        {
            var actual = ssml.ToXml().ToString(SaveOptions.DisableFormatting);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 5
0
 public FluentFluentSay(string value, ISsml ssml)
     : base(ssml)
 {
     _value      = value;
     _ssmlWriter = new PlainTextWriter(value);
 }
Exemplo n.º 6
0
 public static ISsml ForAlexa(this ISsml ssml)
 {
     return(ssml.WithConfiguration(new SsmlConfiguration(true)));
 }
Exemplo n.º 7
0
 public FluentSayAsCharaters(ISsml ssml, string value)
     : base(ssml)
 {
     _value       = value;
     _innerWriter = new SayAsWriter("characters", "characters", _value);
 }
Exemplo n.º 8
0
 public SpeechBuilder Add(ISsml speechElement)
 {
     Speech.Elements.Add(speechElement);
     return(this);
 }
Exemplo n.º 9
0
 public FluentFluentSayDate(ISsml ssml, DateTime date)
     : base(ssml)
 {
     _date = date;
 }
Exemplo n.º 10
0
 public BreakWriter(ISsml ssml)
     : base(ssml)
 {
 }
Exemplo n.º 11
0
 public FluentSayTime(ISsml ssml, TimeSpan value)
 {
     _ssml  = ssml;
     _value = value;
 }