2017-10-05 127 views
0

朋友,如何獲得一個Alexa技巧流媒體MP3到設備

我正在努力嘗試從可公開訪問的S3存儲桶流式傳輸MP3文件的Alexa技能。我的lambda函數正常工作,並返回一個音頻指令。我正在使用npm包alexa-sdk。

但是,當響應被髮送回Echo設備時,我收到了一個「您的技能響應出現錯誤」的通用錯誤。我搜索了一些Alexa響應小組的類型來嘗試和驗證我的響應對象。

下面是我的lambda函數IntentHandler,以及從所述函數返回的響應對象。有人可以看看並指出他們看到的任何錯誤嗎?非常感謝。

var handlers = { 
'LaunchRequest': function() { 
    this.emit(':tell', 'Hello'); 
}, 
GetVoiceMailIntent: function(){ 
    this.response.audioPlayerPlay('REPLACE_ALL', 'https://s3.amazonaws.com/romevm/call_1001.mp3', 'vmtoken', 0); 
    this.emit(':responseReady'); 
}, 
SessionEndedRequest: function() { 
console.log('session ended!'); 
} 
} //end intent handlers 

*********** RESPONSE ************** 
{ 
    "version": "1.0", 
    "response": { 
    "speechletResponse": { 
    "directives": [ 
    { 
     "playBehavior": "REPLACE_ALL", 
     "audioItem": { 
     "stream": { 
      "expectedPreviousToken": "0", 
      "token": "vmtoken", 
      "url": "https://s3.amazonaws.com/romevm/call_1001.mp3", 
      "offsetInMilliseconds": 0 
     } 
     } 
    } 
    ], 
    "shouldEndSession": true 
    } 
},"sessionAttributes": {} 
} 

回答

0

按照AudioPlayer Directives Documentation,發送AudioPlayer指令到服務器時,你必須設置類型屬性,包括它的響應指令陣列英寸根據你的例子,你沒有這樣做。

在你的榜樣,關鍵playBehavior之前,您應該添加以下注冊表項:

"type": "AudioPlayer.Play", 

此外,還要確保與亞馬遜的要求,你的聲音符合以下標準:

爲支持的格式音頻文件包括AAC/MP4,MP3,HLS,PLS和M3U。比特率:16kbps至384kbps。