public void AppendText(string textToSpeak, PromptEmphasis emphasis) { Helpers.ThrowIfNull(textToSpeak, "textToSpeak"); if (emphasis < PromptEmphasis.NotSet || emphasis > PromptEmphasis.Reduced) { throw new ArgumentOutOfRangeException("emphasis"); } ValidateElement(_elementStack.Peek(), SsmlElement.Text); Element element = new Element(ElementType.Emphasis, textToSpeak); _elements.Add(element); if (emphasis != 0) { element._attributes = new Collection <AttributeItem>(); element._attributes.Add(new AttributeItem("level", emphasis.ToString().ToLowerInvariant())); } }
public void AppendText(string textToSpeak, PromptEmphasis emphasis) { Helpers.ThrowIfNull(textToSpeak, nameof(textToSpeak)); if (emphasis < PromptEmphasis.NotSet || emphasis > PromptEmphasis.Reduced) { throw new ArgumentOutOfRangeException(nameof(emphasis)); } // Validate that text can be added in this context ValidateElement(_elementStack.Peek(), SsmlElement.Text); Element emphasisElement = new(ElementType.Emphasis, textToSpeak); _elements.Add(emphasisElement); if (emphasis != PromptEmphasis.NotSet) { emphasisElement._attributes = new Collection <AttributeItem>(); emphasisElement._attributes.Add(new AttributeItem("level", emphasis.ToString().ToLowerInvariant())); } }
public PromptStyle(PromptEmphasis emphasis) { Emphasis = emphasis; }
public new void AppendText(string textToSpeak, PromptEmphasis emphasis) { StartStyle(new PromptStyle(emphasis)); HebrewPromptReader.ReadInto(this, textToSpeak); EndStyle(); }
//parse the entire thing out and say the stuff. public void parse(string filename) { //Load the file lines = System.IO.File.ReadAllLines(filename); //Parse the anchors Parse_Anchors(); while (index < lines.Length) { string input = lines[index]; index++; //Parse the context if (input.StartsWith("SetRate:")) { string rate = input.Substring(8); if (Ratevalues.ContainsKey(rate)) { PromptRate pmt_rate = Ratevalues[rate]; style_.Rate = pmt_rate; } } if (input.StartsWith("SetEmp:")) { string Empsetting = input.Substring(7); if (Emphasisvalues.ContainsKey(Empsetting)) { PromptEmphasis emp_val = Emphasisvalues[Empsetting]; style_.Emphasis = emp_val; } } if (input.StartsWith("<Deepener>")) { //Make note of the deepender here. if (!random_lines.ContainsKey(index)) { random_lines.Add(index, "<Deepener>"); } //now we will run a Deepener script here. int Deepener_Count = Deepener_names.Count(); Random r = new Random(); int next_Deepener = r.Next(Deepener_Count); string Deepener_name = Deepener_names[next_Deepener]; //Some recursive magic now SpeechScriptInterpreter Deepener_interpreter = new SpeechScriptInterpreter(); Deepener_interpreter.init(); //Initialize the new interpreter instance Deepener_interpreter.parse(Deepener_name); } if (input.StartsWith("<Goto:")) { string command = "Goto"; //Get the anchor object. Anchor A = FetchAnchor(input, command); //The '!' character is reserved and anchors cannot use it //It is used to denote a failed fetch. To prevent NullErrors. if (A.name != "!") { int line_index = A.line_number; //Assign indirectly the index of this trance to the Anchor index. index = line_index; } } //Change inputs by setting functions for them for more efficient parsing and //Templating of code blocks. if (input.StartsWith("<QueryMulti:")) { QueryMulti(input); } if (input.StartsWith("<QueryDeepEnough>")) { Dialouge get_state = new Dialouge(); say_default("Are you deep enough yet?"); get_state.ShowDialog(); //Find out yes or no string result = get_state.ReturnValue; if (result == "Yes") { continue; } if (result == "No") { for (int i = index; i > 0; i--) { //search backwards for the previous Deepener //Did we find a '<Deepener> tag? if (random_lines.ContainsKey(i)) { if (random_lines[i] == "<Deepener>") { //does it match? //if it does, we go backwards in the script //All the way to this point index = i - 1; break; //We want to quit the search } } } } } //Generic Query if (input.StartsWith("<QueryGeneric:")) { HandleQuery(input); } //Say the stuff, treating our rate and emphasis as part of a state machine //Which we re-apply each time something is to be spoken. if (input.StartsWith("Say:")) { string voice_string = input.Substring(4); builder.ClearContent(); builder.StartSentence(); builder.StartStyle(style_); builder.AppendText(voice_string); builder.EndStyle(); builder.EndSentence(); //lastly let the ball roll and see if we can hear some chatter. reader.Speak(builder); } } }
public new void AppendText(string textToSpeak, PromptEmphasis emphasis) { StartStyle(new PromptStyle(emphasis)); HebrewPromptReader.ReadInto(this, textToSpeak); EndStyle(); }