Reputation: 433
I'm trying to use SSML in my Alexa Skill. I use Lambda as my service endpoint and Js to program it. Now my question is, how do I correctly implement this in my skill? I'm using the following function to use SSML:
function buildSSMLSpeechletResponse(title, output, repromptText, shouldEndSession) {
return {
outputSpeech: {
type: "SSML",
ssml: output
},
card: {
type: "Simple",
title: "SessionSpeechlet - " + title,
content: "SessionSpeechlet - " + output
},
reprompt: {
outputSpeech: {
type: "SSML",
text: repromptText
}
},
shouldEndSession: shouldEndSession
};
}
My code:
function onLaunch(launchRequest, session, callback) {
console.log("onLaunch requestId=" + launchRequest.requestId
+ ", sessionId=" + session.sessionId);
var cardTitle = "Hello, World!";
var speechOutput = { type: "SSML",
ssml: "<speak>Welcome to Hubo help. <amazon:effect name='whispered'>You can ask questions like</amazon:effect>: 'How do I paint a wall?'. Now what can I help you with?.</speak>", };
callback(session.attributes,
buildSSMLSpeechletResponse(cardTitle, speechOutput, "", true));
}
I think I made a mistake at the callback? Thanks in advance!
Upvotes: 1
Views: 1784
Reputation: 3809
If you are using the Alexa Skills Kit SDK for Node.js you can just include the SSML markup in the text to emit.
For example:
this.emit(':tell', 'Sometimes when I look at the Alexa skills you have all taught me, I just have to say, <say-as interpret-as="interjection">Bazinga.</say-as><break time="0.3s"/><amazon:effect name="whispered"> I love it. </amazon:effect>')
this.emit(':tell', '<say-as interpret-as="interjection">Oh boy</say-as><break time="1s"/> this is just an example.')
It will be included in the README.md file, there's this PR for that now
Upvotes: 4