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; } }
/// <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)); } }
protected FluentSsml(ISsml inner) { _inner = inner; }
private void CompareXml(string expected, ISsml ssml) { var actual = ssml.ToXml().ToString(SaveOptions.DisableFormatting); Assert.Equal(expected, actual); }
public FluentFluentSay(string value, ISsml ssml) : base(ssml) { _value = value; _ssmlWriter = new PlainTextWriter(value); }
public static ISsml ForAlexa(this ISsml ssml) { return(ssml.WithConfiguration(new SsmlConfiguration(true))); }
public FluentSayAsCharaters(ISsml ssml, string value) : base(ssml) { _value = value; _innerWriter = new SayAsWriter("characters", "characters", _value); }
public SpeechBuilder Add(ISsml speechElement) { Speech.Elements.Add(speechElement); return(this); }
public FluentFluentSayDate(ISsml ssml, DateTime date) : base(ssml) { _date = date; }
public BreakWriter(ISsml ssml) : base(ssml) { }
public FluentSayTime(ISsml ssml, TimeSpan value) { _ssml = ssml; _value = value; }