Alexa自定义技能-与其他技能互动

问题描述 投票:0回答:1

我想以特定的方式播放特别的歌曲。

 let speechText = ``;//Happy ${currentYear - year}th birthday!`;
    if (currentDate.getTime() !== nextBirthday.getTime()) {
        if(currentDate.getTime() > nextBirthday.getTime()){
            speechText = `Ciao Alberto! Hai già festeggiato il tuo compleanno quest'anno!!, Ti sei divertito?`;
        } else {
            const diffDays = Math.round(Math.abs((currentDate.getTime() - nextBirthday.getTime())/oneDay));
            speechText = `Ciao Alberto! Mancano ${diffDays} giorni al tuo primo compleanno!! Sei emozionato?`;
            //speechText = `Welcome back. It looks like there are ${diffDays} days until your ${currentYear - year}th birthday.`
        }
    } else {
        // PLAY THAT SONG
    }

如果可以的话,您能在正确的文件上给我讲话吗?谢谢。

aws-lambda spotify alexa-skills-kit alexa-skill
1个回答
0
投票

我找到了解决方法:

else{
        expectedPreviousToken = 'sometoken' + Math.random();
        return handlerInput.responseBuilder
            //.speak('start playing sound')
                .addAudioPlayerPlayDirective('REPLACE_ALL', podcastURL, expectedPreviousToken, 0, null)
                 .withSimpleCard('Example', 'Example')
                 .getResponse();}
© www.soinside.com 2019 - 2024. All rights reserved.