AudioPlayer Alexa 技能套件的“PlaybackNearlyFinished”请求无法正常工作

2024-04-28

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

名为“PlayAudio”的 Intent 正在运行,并播放来自 JSON 格式 API 的第一个音频项目。

名为“PlaybackNearlyFinished”的意图不起作用,也就是说,不播放我正在提供的音频文件。有人能确切地破解为什么这不起作用吗?

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

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 } );
    },

您似乎在回复中包含了outputSpeech。

这对于常规意图是可以的,但对于 AudioPlayer 请求则不行,根据此页面: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

And this note specifically: enter image description here

查看确切的有效负载也会有所帮助。您可以使用在本地测试它并获取这些:https://bespoken.tools/blog/2016/08/24/introducing-bst-proxy-for-alexa-skill-development https://bespoken.tools/blog/2016/08/24/introducing-bst-proxy-for-alexa-skill-development

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AudioPlayer Alexa 技能套件的“PlaybackNearlyFinished”请求无法正常工作 的相关文章

随机推荐