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文件夹。