1
var Response = require('alexa-response'); 

//first intent 
LaunchRequest:function(){ 
//Type 1 gives an error saying the "response is not valid" when tested in the  developers console. 
//the Response here is an npm library 
Response.directives(
AudioPlayer.play({ url: 'https://s3.amazonaws.com/sounds226/boom.mp3' }), 
AudioPlayer.enqueue({ url: 'https://s3.amazonaws.com/sounds226/boom.mp3' }         ) .build(); 

//Type 2 : gives an error when tested on echosim.io saying that the response is not valid 
speechOutput = this.t('WELCOME_MESSAGE'); this.response.audioPlayerPlay("REPLACE_ALL",audioData[1].url).speak(speechOutput); 
this.emit(':responseReady'); 

//Type 3: tried to insert the audio tag within the speech response, error again 
speechOutput = { 
speech: "<speak>" +message+ "<audio src = 'https://s3.amazonaws.com/sounds226/boom.mp3'/></speak>", 
    type : 'SSML' 
}; 
response.ask(speechOutput); 
} 

我想在alexa講我的技能之前插入音頻。音頻在90秒內。這是我對音頻標籤錯誤理解的方式還是以錯誤的方式使用指令?先謝謝你。任何幫助表示讚賞Alexa-音頻問題

+0

約SSML - 請developer.amazon.com更嚴格地檢查,例如在斯里克測試選項卡(!不AWS拉姆達測試) – nvvetal

+0

是否啓用音頻播放器方向您亞馬遜技能設置 –

+0

是的,但要求做不需要音頻指令。我試圖弄清楚如何添加一個**音頻樣本**,在Alexa發言之前應該播放這個**音頻樣本,這與**音頻指令**不相似。我通過'speechOutput = this.t('WELCOME_MESSAGE')+'

回答

0

這裏是介紹舉例:

https://developer.amazon.com/blogs/post/Tx1DSINBM8LUNHY/new-alexa-skills-kit-ask-feature-audio-streaming-in-alexa-skills

,並有明確的信息:

在回答一個LaunchRequest或IntentRequest,你的反應可以包括AudioPlayer指令和標準響應屬性,如outputSpeech,卡片和reprompt。 例如,如果您提供的outputSpeech與Play指令的響應相同,則在開始流式傳輸音頻之前,Alexa會說出提供的文本。

文件 - https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-audioplayer-interface-reference

更多開始發揮

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-audioplayer-interface-reference#play

+0

我有一個問題添加音頻標籤,但後來通過做如下:speechOutput = this.t('WELCOME_MESSAGE')+'

0

當使用在SSML響應<audio>標籤,確保MP3文件符合採樣速率(16000)和比特率(48kbps)由Alexa要求。

More details here.

+0

@ MultiplyByZer0非常感謝分享。 – Maher

0

音頻應進行編碼,以特定的格式(項目16000率和質量,採用48 kbps)的Alexa的播放。請轉換爲使用如下命令音頻,

的ffmpeg -i -ac 2 -codec:一個了libmp3lame -b:一48K -ar 16000

您可以從https://www.ffmpeg.org/

如果你是下載 '的ffmpeg'在運行上面的命令之前使用Windows CD到ffmeg的bin文件夾。