Google上的操作 - 使用操作sdk以德语自定义操作

时间:2018-03-19 11:01:08

标签: google-assistant-sdk multiple-languages

我正在使用Google智能助理SDK为自定义设备开发语音识别功能。我正在使用Action SDK来创建自定义操作。

在我的示例中,如果这些操作标有src=[{"a":{"name":"abc","age":2}}, {"b":{"name":"xyz","age":3}}, {"c":{"name":"pqr","age":4}}] result=[] for arr in src: for d in arr: result.append(arr[d]) 并且助理语言设置为德语,则Google智能助理无法识别德语操作。我认识到清楚地理解查询模式,但事件不会被触发。如果所有内容都设置为英语,则会触发事件。

action.json

"locale": "de"

hotword.py - 剪切事件处理

{
    "locale": "de",
    "manifest": {
        "displayName": "Blink Licht",
        "invocationName": "Blink Licht",
        "category": "PRODUCTIVITY"
    },
    "actions": [
        {
            "name": "com.acme.actions.blink_light",
            "availability": {
                "deviceClasses": [
                    {
                        "assistantSdkDevice": {}
                    }
                ]
            },
            "intent": {
                "name": "com.acme.intents.blink_light",
                "parameters": [
                    {
                        "name": "number",
                        "type": "SchemaOrg_Number"
                    },
                    {
                        "name": "light_target",
                        "type": "LightType"
                    }
                ],
                "trigger": {
                    "queryPatterns": [
                        "lasse das $LightType:light_target $SchemaOrg_Number:number mal blinken"
                    ]
                }
            },
            "fulfillment": {
                "staticFulfillment": {
                    "templatedResponse": {
                        "items": [
                            {
                                "simpleResponse": {
                                    "textToSpeech": "Das Licht $light_target.raw blinkt $number mal"
                                }
                            },
                            {
                                "deviceExecution": {
                                    "command": "com.acme.commands.blink_light",
                                    "params": {
                                        "lightKey": "$light_target",
                                        "number": "$number"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        }
    ],
    "types": [
        {
            "name": "$LightType",
            "entities": [
                {
                    "key": "LIGHT",
                    "synonyms": [
                        "Licht",
                        "LED",
                        "Glühbirne"]
                }
            ]
        }
    ]
}

操作控制台中的项目语言是德语: enter image description here

要更新并使操作可用于测试,我使用了" gaction CLI"。

问题:为什么在使用德语时没有触发hotword.py中的事件/命令def process_event(event, device_id): """Pretty prints events. Prints all events that occur with two spaces between each new conversation and a single space between turns of a conversation. Args: event(event.Event): The current event to process. device_id(str): The device ID of the new instance. """ if event.type == EventType.ON_CONVERSATION_TURN_STARTED: print() print(event) if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and event.args and not event.args['with_follow_on_turn']): print() if event.type == EventType.ON_DEVICE_ACTION: for command, params in process_device_actions(event, device_id): print('Do command', command, 'with params', str(params)) # if command == "com.acme.commands.blink_light": number = int(params['number']) for i in range(int(number)): print('Device is blinking.')

感谢您的期待!

1 个答案:

答案 0 :(得分:0)

这是我解决此问题的方法: 1.在Google控制台上执行操作,然后选择遇到问题的项目。 2.在“概述”部分中,您会看到一个窗口,上面带有您的操作的语言,在其右侧是蓝色的“修改语言”。单击它,然后删除您不使用的语言,在这种情况下为英语。

至少对我有用。