Search code examples
amazon-web-servicesaudiotagsalexa-skills-kit

How do I add more then two audio(tag) files in same Alexa intent function?


HI I am trying to use more than two audio tags in my Alexa skill and audio is edited as Alexa requirement and audio is not more than 250 seconds now I want Alexa to speak audio I have five audio files so five audio tags so how can I make Alexa speak 5 audio tags continuously I have renamed the website link. due to some reason, by the way website link is working perfectly

const Thiriller = {
canHandle(handlerInput) {
    return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
        && Alexa.getIntentName(handlerInput.requestEnvelope) === 'Thiriller';
},
handle(handlerInput) {
    var audio = "<audio src='https://lul.com/wp-content/uploads/2019/Flight%20PT1.mp3?_t=1567452928'/>";
    var audio1 = "<audio src='https://lul.com/wp-content/uploads/2019/Flight%20Pt2.mp3?_t=1567452928'/>";   
    return handlerInput.responseBuilder
        .speak(audio)
        .speak(audio1)
        //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
        .getResponse();
}

};


Solution

  • Try this.

        return handlerInput.responseBuilder
            .speak(audio + audio1)
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
            .getResponse();
    

    If you need 5 back to back .speak(audio + audio1 + audio2 + audio3)

    just make sure that the total duration doesn't go over the SSML audio limit which is 240 seconds.