Reputation: 2654
I want to be able to do the following:
I have tried the following code which does not work:
const IntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === "IntentRequest" &&
handlerInput.requestEnvelope.request.intent.name === "MyIntent";
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak("Say something")
.addAudioPlayerPlayDirective('REPLACE_ALL', audioFile, 'token', 0)
.speak("Say something else")
.getResponse();
}
}
The result of the code above is this:
How can I achieve this?
Upvotes: 2
Views: 508
Reputation: 2654
I solved this by using the ssml-builder
package to create a SSML string and modifying the response sent back with that string.
const AmazonSpeech = require('ssml-builder/amazon_speech');
const speech = new AmazonSpeech();
speech.say('Start of the story')
.audio(audioFile)
.say('Finish the story');
const ssml = speech.ssml();
const response = handlerInput.responseBuilder.getResponse();
response.outputSpeech = {
type: 'SSML',
ssml: ssml
};
return response;
Upvotes: 1