Beispiel #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
Beispiel #2
0
 def test_concat(self):
     s1 = PySSML()
     s2 = PySSML()
     s1.say('This')
     s2.say('works!')
     s1.concat(s2)
     self.assertEqual(s1.ssml(), "<speak>This works!</speak>")
Beispiel #3
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>"
     })
Beispiel #4
0
    def test_ssml(self):
        s = PySSML()

        s.say('Hello')
        self.assertEqual(s.ssml(True), "Hello")
        self.assertEqual(s.ssml(False), "<speak>Hello</speak>")

        s.clear()
        s.say("<Cat's> & <Dog's>")
        self.assertEqual(s.ssml(False), "<speak>Cats and Dogs</speak>")
Beispiel #5
0
    def test_say(self):
        s = PySSML()
        s.say('star')
        self.assertEqual(s.ssml(), "<speak>star</speak>")

        s.clear()
        s.say("star's")
        self.assertEqual(s.ssml(), "<speak>stars</speak>")

        s.clear()
        s.say('star"s')
        self.assertEqual(s.ssml(), "<speak>stars</speak>")

        s.clear()
        s.say('hi')
        self.assertEqual(s.ssml(), "<speak>hi</speak>")
Beispiel #6
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>")