我希望能够执行以下操作:
我尝试了以下无效的代码:
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();
}
}
上面的代码的结果是这样的:
我该如何实现?
答案 0 :(得分:0)
我通过使用ssml-builder
包创建了SSML字符串并修改了用该字符串返回的响应来解决了这个问题。
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;