def test_speak_randomly(self):
        response_factory = self.response_factory.speak_randomly(
            speeches=[None, "Hello World"])

        assert response_factory.response.output_speech in [
            SsmlOutputSpeech(ssml="<speak></speak>"),
            SsmlOutputSpeech(ssml="<speak>Hello World</speak>")
        ], ("The speak_randomly method of ResponseFactory fails to set one of the given speeches"
            )
Exemplo n.º 2
0
    def ask(self, reprompt, play_behavior=None):
        # type: (str, PlayBehavior) -> 'ResponseFactory'
        """Provide reprompt speech to the user, if no response for
        8 seconds.

        The should_end_session value will be set to false except when
        the video app launch directive is present in directives.

        :param reprompt: the output speech to reprompt.
        :type reprompt: str
        :param play_behavior: attribute to control alexa's speech
            interruption
        :type play_behavior: ask_sdk_model.ui.play_behavior.PlayBehavior
        :return: response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        ssml = "<speak>{}</speak>".format(self.__trim_outputspeech(
            speech_output=reprompt))
        output_speech = SsmlOutputSpeech(
            ssml=ssml, play_behavior=play_behavior)
        self.response.reprompt = Reprompt(output_speech=output_speech)
        if not self.__is_video_app_launch_directive_present():
            self.response.should_end_session = False
        return self
    def test_ask(self):
        response_factory = self.response_factory.ask(reprompt=None)

        assert response_factory.response.reprompt == Reprompt(
            output_speech=SsmlOutputSpeech(ssml="<speak></speak>")), (
                "The ask method of ResponseFactory fails to set reprompt")
        assert response_factory.response.should_end_session is False, (
            "The ask method of ResponseFactory fails to set the "
            "should_end_session to False")
Exemplo n.º 4
0
    def test_speak_with_play_behavior(self):
        test_play_behavior = PlayBehavior.ENQUEUE
        response_factory = self.response_factory.speak(
            speech=None, play_behavior=test_play_behavior)

        assert response_factory.response.output_speech == SsmlOutputSpeech(
            ssml="<speak></speak>", play_behavior=test_play_behavior), (
            "The speak method of ResponseFactory fails to set play behavior "
            "on output speech")
    def test_ask_with_play_behavior(self):
        test_play_behavior = PlayBehavior.REPLACE_ALL
        response_factory = self.response_factory.ask(
            reprompt=None, play_behavior=test_play_behavior)

        assert response_factory.response.reprompt == Reprompt(
            output_speech=SsmlOutputSpeech(ssml="<speak></speak>",
                                           play_behavior=test_play_behavior)
        ), ("The ask method of ResponseFactory fails to set play behavior "
            "on reprompt output speech")
Exemplo n.º 6
0
    def test_response_with_reprompt_directive(self):
        directive = RenderDocumentDirective()
        expected_response = Response(
            output_speech=SsmlOutputSpeech(ssml="<speak>Hello World</speak>"),
            reprompt=Reprompt(directives=[directive]),
            should_end_session=False)

        response_factory = self.response_factory.set_should_end_session(True).add_directive_to_reprompt(
            directive=directive).speak('Hello World')
        assert response_factory.response == expected_response, (
            "The add_directive_to_reprompt method of ResponseFactory fails to add directive")
    def present_article(self, intro, title, body):
        # type: (str) -> 'ResponseFactory'
        """Say the provided speech to the user.

        :param speech: the output speech sent back to the user.
        :type speech: str
        :return: response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        ssml = '<speak>' + intro + title + body + '</speak>'
        self.response.output_speech = SsmlOutputSpeech(ssml=ssml)
        return self
    def speak(self, speech):
        # type: (str) -> 'ResponseFactory'
        """Say the provided speech to the user.

        :param speech: the output speech sent back to the user.
        :type speech: str
        :return: response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        ssml = '<speak>' + speech + '</speak>'
        self.response.output_speech = SsmlOutputSpeech(ssml=ssml)
        return self
    def speak(self, speech):
        # type: (str) -> 'ResponseFactory'
        """Say the provided speech to the user.

        :param speech: the output speech sent back to the user.
        :type speech: str
        :return response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        ssml = "<speak>{}</speak>".format(self.__trim_outputspeech(
            speech_output=speech))
        self.response.output_speech = SsmlOutputSpeech(ssml=ssml)
        return self
Exemplo n.º 10
0
    def speak(self, speech, play_behavior=None):
        # type: (str, PlayBehavior) -> 'ResponseFactory'
        """Say the provided speech to the user.

        :param speech: the output speech sent back to the user.
        :type speech: str
        :param play_behavior: attribute to control alexa's speech
            interruption
        :type play_behavior: ask_sdk_model.ui.play_behavior.PlayBehavior
        :return: response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        ssml = "<speak>{}</speak>".format(self.__trim_outputspeech(
            speech_output=speech))
        self.response.output_speech = SsmlOutputSpeech(
            ssml=ssml, play_behavior=play_behavior)
        return self
    def ask(self, reprompt):
        # type: (str) -> 'ResponseFactory'
        """Provide reprompt speech to the user, if no response for
        8 seconds.

        The should_end_session value will be set to false except when
        the video app launch directive is present in directives.

        :param reprompt: the output speech to reprompt.
        :type reprompt: str
        :return: response factory with partial response being built and
            access from self.response.
        :rtype: ResponseFactory
        """
        reprompt = self.__encode_ssml(reprompt)
        ssml = "<speak>{}</speak>".format(self.__trim_outputspeech(
            speech_output=reprompt))
        output_speech = SsmlOutputSpeech(ssml=ssml)
        self.response.reprompt = Reprompt(output_speech=output_speech)
        return self
    def test_speak(self):
        response_factory = self.response_factory.speak(speech=None)

        assert response_factory.response.output_speech == SsmlOutputSpeech(
            ssml="<speak></speak>"
        ), ("The speak method of ResponseFactory fails to set output speech")