AWS Polly - Getting Started

amazon-alexa

#1

I know Jovo has been adding some middleware to help add in customization to Alexa skills like AWS Polly voices (https://aws.amazon.com/polly/)

I wasn’t able to find any documentation on how to add Polly from the Jovo website. Has anyone successfully used AWS Polly and willing to provide a code example of how to implement?


#2

Have you seen the example code here?


#3

That’s what I was looking for :slight_smile: thank you!

for everyone else, here’s an example Jan pointed out:

// Example: Wrap Alexa Skill output in a Polly voice SSML tag
// before the response JSON is created in the platform.output middleware
app.hook('before.platform.output', (error, host, jovo) => {
    const pollyName = 'Hans';

    if (jovo.isAlexaSkill()) {
        if (jovo.$output.tell) {
            jovo.$output.tell.speech = `<voice name="${pollyName}">${jovo.$output.tell.speech}</voice>`;
        }

        if (jovo.$output.ask) {
            jovo.$output.ask.speech = `<voice name="${pollyName}">${jovo.$output.ask.speech}</voice>`;
            jovo.$output.ask.reprompt = `<voice name="${pollyName}">${jovo.$output.ask.reprompt}</voice>`;
        }
    }
});

#4

It is SUPER easy to use now. But I LOVE that hook!!!
Just a note because I haven’t tried it yet… if you have audio tags in with the speech payload, I wonder if this particular approach would cause an error?


#5

Wouldn’t be catched by the framework. I think Alexa will return an error request.