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

编程入门 行业动态 更新时间:2024-10-09 07:21:53
本文介绍了使用 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 08:02:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641582.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最简单   示例   流式   音频   Alexa

发布评论

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

>www.elefans.com

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