使用Alexa流音频的最简单示例

编程入门 行业动态 更新时间:2024-10-07 10:24:32
本文介绍了使用Alexa流音频的最简单示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用新的流音频API。以下回应有效吗?在设备上进行测试时,出现技能有问题错误。

I'm trying to get the new streaming audio API going. Is the following response valid? I'm getting a "there was a problem with the skill" error when I test it on my device.

这是我的AWS-lambda函数的代码:

Here is the code for my AWS-lambda function:

def lambda_handler(event, context): return { "response": { "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", "audioItem": { "stream": { "token": "12345", "url": "emit-media-production.s3.amazonaws/pbs/the-afterglow/2016/08/24/1700/201608241700_the-afterglow_64.m4a", "offsetInMilliseconds": 0 } } } ], "shouldEndSession": True } }

推荐答案

以下代码对我有用:

def lambda_handler(event, context): return { "response": { "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", "audioItem": { "stream": { "token": "12345", "url": "emit-media-production.s3.amazonaws/pbs/the-afterglow/2016/08/24/1700/201608241700_the-afterglow_64.m4a", "offsetInMilliseconds": 0 } } } ], "shouldEndSession": True } } ]

唯一的区别是URL是https而不是http。

The only difference is that the URL is https rather than http.

请勿放置如果在技能模拟器中不起作用,请关闭。尚未升级,无法与流音频一起使用。您甚至在那里都看不到指令。但是,当与您的设备一起使用时,它应该可以工作。

Don't be put off if it doesn't work in the skill simulator. That hasn't been upgraded yet to work with streaming audio. You won't even see your directives there. But it should work when used with your device.

更多推荐

使用Alexa流音频的最简单示例

本文发布于:2023-11-28 04:31:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640974.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:流音   最简单   示例   Alexa

发布评论

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

>www.elefans.com

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