AudioPlayer“ PlaybackNearlyFinished”要求Alexa技能套件,但不起作用 [英] AudioPlayer "PlaybackNearlyFinished" Request of Alexa Skills Kit, Not Working

查看:102
本文介绍了AudioPlayer“ PlaybackNearlyFinished”要求Alexa技能套件,但不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了Alexa技能,该技能使用Lambda函数播放给定URL中的独特音频。



名为 PlayAudio的Intent正在起作用,并播放JSON格式的API中的第一个音频项。



名为 PlaybackNearlyFinished的Intent无法正常运行,也就是无法播放我正在馈送的音频文件。谁能确切解释为什么这行不通?



这是我的Lambda函数的一部分,其中包含两个Intent:

  Fact.prototype.intentHandlers = {
PlayAudio:函数(事件,上下文,响应){
fetchEnseParse( / latest,function(body){
if( body ==错误){
}
else {
var指令= body.enses.map(function(ense){
var a = ense [1] .fileUrl ;
return {
'playBehavior':'REPLACE_ALL',
'audioItem':
{
'stream':
{
' url':'https://s3.amazonaws.com/media.ense.nyc/enses/2017_01_13T16_57_20.190Z/30312/0',
'token':'33529',
'offset InMilliseconds:0
}
},
type: AudioPlayer.Play
};
})
}
var jsonresponse = {
'outputSpeech':{
'text':'',
'type':'PlainText'
},
'directives':[directives [0]]
};
response.justUseThisJsonPlease({response:jsonresponse});
});
},


AudioPlayer.PlaybackNearlyFinished:函数(事件,上下文,响应){
var second =
{
type: AudioPlayer.Play,
playBehavior: REPLACE_ENQUEUED,
audioItem:{
stream:{
url: https: //s3.amazonaws.com/media.ense.nyc/enses/violetindigoviolet/30034/0,
令牌: 33530,
offsetInMilliseconds:0
}
}
}
response.justUseThisJsonPlease({响应:第二个});
},


解决方案



对于此页面的常规意图,但对于AudioPlayer请求,则不可行,请访问以下页面:



查看确切的有效载荷也可以有所帮助。您可以使用它在本地进行测试并获得以下内容:
https://bespoken.tools/blog/2016/08/24/introducing-bst-proxy-for-alexa-skill-development



您应该看到来自Alexa的另一个请求SystemExceptionEncountered,该请求应提供有关错误原因的更多信息。当对AudioPlayer请求的响应不正确时,它将发送此消息。


I've written an Alexa Skill that uses a Lambda Function to play unique audio from a given URL.

The Intent called "PlayAudio" is working and plays the first audio item from our JSON-formatted API.

The Intent called "PlaybackNearlyFinished" does not work, aka, does not play the audio file I am feeding it. Can anybody crack exactly why this doesn't work?

Here is a section from my Lambda Function, which contains the two Intents:

Fact.prototype.intentHandlers = {
    "PlayAudio": function (event, context, response) {
          fetchEnseParse("/latest", function(body) {
            if(body == "error") {
            } 
            else {
                var directives = body.enses.map(function(ense) {
                    var a = ense[1].fileUrl;
                    return {
                         'playBehavior': 'REPLACE_ALL', 
                         'audioItem': 
                             {
                                 'stream': 
                                     {
                                         'url': 'https://s3.amazonaws.com/media.ense.nyc/enses/2017_01_13T16_57_20.190Z/30312/0', 
                                         'token': '33529', 
                                         'offsetInMilliseconds': 0
                                     }
                             }, 
                             'type': 'AudioPlayer.Play'
                    };
                })
            }
            var jsonresponse = {
                'outputSpeech': {
                     'text': '', 
                     'type': 'PlainText'
                    }, 
                'directives': [directives[0]]
            };     
            response.justUseThisJsonPlease( { response: jsonresponse } );
        });
    },


    "AudioPlayer.PlaybackNearlyFinished" : function(event, context, response) {
            var second = 
            {
              "type": "AudioPlayer.Play",
              "playBehavior": "REPLACE_ENQUEUED",
              "audioItem": {
                "stream": {
                  "url": "https://s3.amazonaws.com/media.ense.nyc/enses/violetindigoviolet/30034/0",
                  "token": "33530",
                  "offsetInMilliseconds": 0
                }
              }
            }
            response.justUseThisJsonPlease( { response: second } );
    },

解决方案

It seems that you are including outputSpeech in your response.

This is okay for regular intents, but not for AudioPlayer requests, per this page: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-audioplayer-interface-reference

And this note specifically:

Seeing the exact payload can help as well. You can use to test it locally and get those: https://bespoken.tools/blog/2016/08/24/introducing-bst-proxy-for-alexa-skill-development

You should be seeing an additional request from Alexa, SystemExceptionEncountered, that should provide more information about what was wrong. It will send this when there is improper response to an AudioPlayer request.

这篇关于AudioPlayer“ PlaybackNearlyFinished”要求Alexa技能套件,但不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆