【问题标题】:Alexa skill image not showingAlexa技能图像未显示
【发布时间】:2018-02-09 06:09:52
【问题描述】:

我正在写一个简单的技能,我想显示一个全屏图像。我在Alexa skill pages上找到了一段示例代码

def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
"outputSpeech": {"type":"PlainText","text":"This is your cow!"},
"card": {
  "type": "Standard",
  "title": "Cow picture",
  "text": "This is your cow",
  "image": {
    "smallImageUrl": "https://s3.amazonaws.com/icepick-alexa/cow.jpg",
    "largeImageUrl": "https://s3.amazonaws.com/icepick-alexa/cow.jpg"
           }
       } 
}

我知道我的图像托管是可以的,因为当我使用模板时,我可以将图像显示为背景图像..但我只想要它全屏而不是背景。

此代码在 Alexa 技能在线模拟器中运行良好,我在那里看到了图像。但是,当我在我的 Alexa Echo Spot 上运行代码时,它会显示文本但没有图像。我尝试了不同尺寸的不同图像,但没有帮助。

【问题讨论】:

标签: python alexa


【解决方案1】:

我想将此作为评论发布,但由于我的声誉不够高而无法发布。

您在模拟器中看到图像是因为它设置为模拟 Echo Show。您的代码需要根据设备的类型进行优化。查看this了解更多信息

【讨论】:

    【解决方案2】:

    如果您使用的是 alexa-sdk,那么这里有一个代码 sn-p 可以帮助您在现场显示全屏图像。如果您不使用 sdk,则只能参考此 sn-p 的 JSON 部分。

    const Alexa = require('ask-sdk');
    

    如果您使用的是 Alexa SDK,请创建 Image 对象。

    const myImage = new Alexa.ImageHelper().withDescription('Image').addImageInstance(IMG_URL_PATH + 'Image.jpg').getImage();
    

    正文模板 1,其背景类似于全屏图像。

    var displayTemplate = {
        type: 'BodyTemplate1',
        token: 'Your Token',
        backButton: 'hidden',
        backgroundImage: myImage,
        title: '',
        textContent: {
            primaryText : {
                type : 'RichText',
                text : '<div align=\'center\'><br/><br/><br/><br/><font size=\'2\'>Some Text</font></div>'
            }
        }    
    };
    

    在您的处理程序中,您可以通过以下方式返回响应。

    handlerInput.responseBuilder.speak(speechText).addRenderTemplateDirective(displayTemplate).getResponse();
    

    【讨论】:

      【解决方案3】:

      要在您的 Alexa 技能中显示图像,您可以使用标准卡作为实现它的方法。 https://developer.amazon.com/docs/alexa-voice-service/display-cards-overview.html

      【讨论】:

        【解决方案4】:

        您可以使用任何显示模板来呈现图像以及一些文本。此外,如果您只想拥有一张图片,请使用“卡片”方法。

        【讨论】:

          【解决方案5】:

          你可以使用简单的alexa函数来显示卡片—— 1.问带卡 2.tellWithCard 3.使用展示模板

          【讨论】:

            猜你喜欢
            • 2021-11-08
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-08-15
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2019-07-03
            相关资源
            最近更新 更多