Ejemplo n.º 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
Ejemplo n.º 2
0
    def test_spell_slowly(self):
        s = PySSML()
        s.spell_slowly('nick', "500ms")
        self.assertEqual(s.ssml(),
                         "<speak><say-as interpret-as='spell-out'>n</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>i</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>c</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>k</say-as> <break time='500ms'/></speak>")

        s.clear()
        s.spell_slowly("<nick's>", "500ms")
        self.assertEqual(s.ssml(),
                         "<speak><say-as interpret-as='spell-out'>n</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>i</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>c</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>k</say-as> <break time='500ms'/> <say-as interpret-as='spell-out'>s</say-as> <break time='500ms'/></speak>")