def say(self, text_or_ssml: str): if is_text_ssml(text_or_ssml=text_or_ssml) is True: self.say_ssml(ssml=text_or_ssml) else: self.outputSpeech.set_text( text=f'{self.outputSpeech.text}\n{text_or_ssml}' if self. outputSpeech.text is not None else text_or_ssml)
def say_reprompt(self, text_or_ssml: str): if is_text_ssml(text_or_ssml=text_or_ssml) is True: self.reprompt.outputSpeech.ssml += ( "\n" if self.reprompt.outputSpeech.ssml is not None else "" + text_or_ssml) else: self.reprompt.outputSpeech.text += ( "\n" if self.reprompt.outputSpeech.text is not None else "" + text_or_ssml)
def say(self, text_or_ssml: str): if is_text_ssml(text_or_ssml=text_or_ssml) is True: new_speech = ("\n" if self.outputSpeech.ssml is not None else "") + text_or_ssml if self.outputSpeech.ssml is None: self.outputSpeech.ssml = new_speech else: self.outputSpeech.ssml += new_speech else: new_speech = ("\n" if self.outputSpeech.text is not None else "") + text_or_ssml if self.outputSpeech.text is None: self.outputSpeech.text = new_speech else: self.outputSpeech.text += new_speech
def dict(self, **kwargs): data = super().dict(**kwargs) if self.ssml is not None and not is_text_ssml(self.ssml): data['ssml'] = f"<speak>{self.ssml}</speak>" return data