音频播放器“播放接近完成"请求 Alexa Skills Kit,不工作 [英] AudioPlayer "PlaybackNearlyFinished" Request of Alexa Skills Kit, Not Working

查看:24
本文介绍了音频播放器“播放接近完成"请求 Alexa Skills Kit,不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 Alexa Skill,它使用 Lambda 函数播放来自给定 URL 的独特音频.

名为PlayAudio"的 Intent 正在运行并播放来自我们 JSON 格式 API 的第一个音频项.

名为PlaybackNearlyFinished"的 Intent 不起作用,也就是不播放我提供给它的音频文件.任何人都可以破解到底为什么这不起作用?

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

Fact.prototype.intentHandlers = {PlayAudio":函数(事件、上下文、响应){fetchEnseParse("/latest", function(body) {如果(正文==错误"){}别的 {var 指令 = body.enses.map(function(ense) {var a = ense[1].fileUrl;返回 {'playBehavior': 'REPLACE_ALL','音频项目':{'溪流':{'url': 'https://s3.amazonaws.com/media.ense.nyc/enses/2017_01_13T16_57_20.190Z/30312/0','令牌':'33529','offsetInMilliseconds':0}},'type': 'AudioPlayer.Play'};})}var jsonresponse = {'输出语音':{'文本': '','type': '纯文本'},'指令':[指令[0]]};response.justUseThisJsonPlease( { response: jsonresponse } );});},AudioPlayer.PlaybackNearlyFinished":函数(事件、上下文、响应){var 秒 ={"type": "AudioPlayer.Play","playBehavior": "REPLACE_ENQUEUED",音频项目":{溪流": {"url": "https://s3.amazonaws.com/media.ense.nyc/enses/violetindigoviolet/30034/0","令牌": "33530","offsetInMilliseconds": 0}}}response.justUseThisJsonPlease( { response: second } );},

解决方案

您的回复中似乎包含 outputSpeech.

这适用于常规意图,但不适用于 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.

这篇关于音频播放器“播放接近完成"请求 Alexa Skills Kit,不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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