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));
            }
        }