本文介绍了使用 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": "http://emit-media-production.s3.amazonaws.com/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": "https://emit-media-production.s3.amazonaws.com/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 流式传输音频的最简单示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!