Example #1
0
def handle_story_intent(intent, alexa_session):
    s = PySSML()
    s.paragraph(
        "Once upon a time there was an old woman who loved baking gingerbread. She would bake gingerbread cookies, cakes, houses and gingerbread people, all decorated with chocolate and peppermint, caramel candies and colored frosting."
    )
    s.pause("200ms")
    s.say("Give me a")
    s.spell_slowly("Tigers", "100ms")
    s.say("Go Tigers!")

    result = {
        'version': '1.0',
        'sessionAttributes': {},
        'response': {
            'outputSpeech': s.to_object(),
            'card': {
                'type': 'Simple',
                'title': 'Story',
                'content': s.card()
            },
            'reprompt': {
                'outputSpeech': {
                    'type': 'PlainText',
                    'text': 'Are you there?'
                }
            },
            'shouldEndSession': False
        }
    }
    return result
Example #2
0
 def test_to_object(self):
     s = PySSML()
     s.say("Hello")
     s.paragraph("Nick")
     self.assertEqual(s.to_object(), {
         "type": 'SSML',
         "speech": "<speak>Hello <p>Nick</p></speak>"
     })
Example #3
0
    def test_compound_examples(self):
        s = PySSML()
        s.say("Hello")
        s.paragraph("Nick")
        self.assertEqual(s.ssml(), "<speak>Hello <p>Nick</p></speak>")

        s.clear()
        s.say("How")
        s.paragraph("are")
        s.say("you")
        self.assertEqual(s.ssml(), "<speak>How <p>are</p> you</speak>")
Example #4
0
 def _build_ssml_title(self, title):
     """Wrap article title in SSML-compatible markup with pause at the end"""
     s = PySSML()
     s.paragraph(title)
     s.pause('500ms')
     return s.ssml(True)
Example #5
0
 def test_paragraph(self):
     s = PySSML()
     s.paragraph('hi')
     self.assertEqual(s.ssml(), "<speak><p>hi</p></speak>")