AudioPlayer“ PlaybackNearlyFinished”要求Alexa技能套件,但不起作用

编程入门 行业动态 更新时间:2024-10-09 12:26:44
本文介绍了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':'s3.amazonaws/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/media.ense.nyc/enses/violetindigoviolet/30034/0,令牌: 33530, offsetInMilliseconds:0 } } } response.justUseThisJsonPlease({响应:第二个}); },

解决方案

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

查看确切的有效载荷也可以有所帮助。您可以使用它在本地进行测试并获得以下内容: 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': 's3.amazonaws/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": "s3.amazonaws/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: developer.amazon/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: 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技能套件,但不起作用

本文发布于:2023-11-28 04:08:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640896.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:套件   但不   技能   AudioPlayer   PlaybackNearlyFinished

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!