2727 from ask_sdk_model import Directive
2828 from ask_sdk_model .ui import Card
2929 from ask_sdk_model .canfulfill import CanFulfillIntent
30+ from ask_sdk_model .ui .play_behavior import PlayBehavior
3031
3132
3233PLAIN_TEXT_TYPE = "PlainText"
@@ -51,23 +52,27 @@ def __init__(self):
5152 directives = None , should_end_session = None ,
5253 can_fulfill_intent = None )
5354
54- def speak (self , speech ):
55- # type: (str) -> 'ResponseFactory'
55+ def speak (self , speech , play_behavior = None ):
56+ # type: (str, PlayBehavior ) -> 'ResponseFactory'
5657 """Say the provided speech to the user.
5758
5859 :param speech: the output speech sent back to the user.
5960 :type speech: str
61+ :param play_behavior: attribute to control alexa's speech
62+ interruption
63+ :type play_behavior: ask_sdk_model.ui.play_behavior.PlayBehavior
6064 :return: response factory with partial response being built and
6165 access from self.response.
6266 :rtype: ResponseFactory
6367 """
6468 ssml = "<speak>{}</speak>" .format (self .__trim_outputspeech (
6569 speech_output = speech ))
66- self .response .output_speech = SsmlOutputSpeech (ssml = ssml )
70+ self .response .output_speech = SsmlOutputSpeech (
71+ ssml = ssml , play_behavior = play_behavior )
6772 return self
6873
69- def ask (self , reprompt ):
70- # type: (str) -> 'ResponseFactory'
74+ def ask (self , reprompt , play_behavior = None ):
75+ # type: (str, PlayBehavior ) -> 'ResponseFactory'
7176 """Provide reprompt speech to the user, if no response for
7277 8 seconds.
7378
@@ -76,13 +81,17 @@ def ask(self, reprompt):
7681
7782 :param reprompt: the output speech to reprompt.
7883 :type reprompt: str
84+ :param play_behavior: attribute to control alexa's speech
85+ interruption
86+ :type play_behavior: ask_sdk_model.ui.play_behavior.PlayBehavior
7987 :return: response factory with partial response being built and
8088 access from self.response.
8189 :rtype: ResponseFactory
8290 """
8391 ssml = "<speak>{}</speak>" .format (self .__trim_outputspeech (
8492 speech_output = reprompt ))
85- output_speech = SsmlOutputSpeech (ssml = ssml )
93+ output_speech = SsmlOutputSpeech (
94+ ssml = ssml , play_behavior = play_behavior )
8695 self .response .reprompt = Reprompt (output_speech = output_speech )
8796 if not self .__is_video_app_launch_directive_present ():
8897 self .response .should_end_session = False
0 commit comments