为什么每当我在插槽中使用“白色”一词时,Alexa 都会说“请求的技能的响应有问题”?

问题描述

我正在制作带有 RaspBerry Pi 和 LED 灯条的 Alexa 小工具,在我将插槽值添加到 AMAZON.Color 插槽之前,一切都运行良好。我添加了 CSS3 指定的颜色,包括白色,但现在除了白色之外,我测试过的所有颜色。当我使用“白色”这个词时,Alexa 说“请求技能的响应有问题”,但 CloudWatch Logs 中没有显示任何内容,我的小工具上也没有出现任何错误

解决方法

  • 如果我向 'white' 槽值添加一个随机同义词,它会起作用。
  • 一旦我删除了所有插槽值,白色就会再次起作用,但我想保留这些插槽,因为它可以提高我技能的整体可靠性。
  • 制作我自己的自定义“颜色”插槽类型可以解决问题,但内置插槽类型应该可以解决问题。

Lambda 代码

# Recieves the solid_color intent and sends the solid_color directive to the gadget 
class solid_colorHandler(AbstractRequestHandler):
    
    # Determines what request type this handler handles
    def can_handle(self,handler_input):
        # type: (HandlerInput) -> bool
        return ask_utils.is_intent_name("solid_color")(handler_input)

    # Handler
    def handle(self,handler_input):
        
        logger.info("== solid_color Intent ==")
        
        response_builder = handler_input.response_builder
        
        # Get connected gadget endpoint ID.
        endpointId = get_connected_endpointId(handler_input)

        # If there are any valid endpoints,send a directive.
        if endpointId != None:
            
            # Get slots
            slots = handler_input.request_envelope.request.intent.slots
            
            response = (response_builder
                .speak('')
                .add_directive(Directive('solid_color',endpointId,payload=slots))
                .set_should_end_session(True)
                .response)

        # If there are no endpoints,fail gracefully.
        else:
            response = no_endpoint_response(response_builder)
        
        return response

小工具代码

    def on_custom_deskdisplay_solid_color(self,directive):
        slots = json.loads(directive.payload.decode("utf-8"))
        logger.info(slots)

        # YOUR CODE HERE
        print('solid_color called via Alexa with slots: \n' + str(slots))

        if self.animation != None:
            self.animation.terminate()
            self.animation = None

        colorName = getSlotValue(directive,'color')
        
        if colorName != 'rainbow':
            rgb = name_to_rgb(colorName)
            color = Color(rgb.red,rgb.green,rgb.blue)

            for i in range(self.strip.numPixels()):
                self.strip.setPixelColor(i,color)
            
            self.strip.show()

        else:
            rainbow(self.strip)

槽值

...
palevioletred,palevioletred,pale violetred
mediumvioletred,mediumvioletred,medium violetred
white,white,white
sNow,sNow,sNow
honeydew,honeydew,honeydew
...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...