自定义操作中的hotword.py无法运行

时间:2019-05-03 06:42:58

标签: python raspberry-pi google-assistant-sdk

我正在尝试将自定义操作添加到Google Assistant SDK中。 我已根据需要修改了action.json文件和hotword.py文件,并保存了它们。.

我的action.json看起来像:

{ "manifest": { "displayName": "Play Music", "invocationName": "Play Music", "category": "PRODUCTIVITY" }, "actions": [ { "name": "com.example.actions.PlayMusic", "availability": { "deviceClasses": [ { "assistantSdkDevice": {} } ] }, "intent": { "name": "com.example.intents.PlayMusic", "parameters": [ { "name": "text", "type": "SchemaOrg_Text" } ], "trigger": { "queryPatterns": [ "play the song $SchemaOrg_Text:text", "sing the song $SchemaOrg_Text:text" ] } }, "fulfillment": { "staticFulfillment": { "templatedResponse": { "items": [ { "simpleResponse": { "textToSpeech": "Playing the song $text" } }, { "deviceExecution": { "command": "com.example.commands.BlinkLight", "params": { "speed": "$speed", "number": "$number" } } } ] } } } } ] }

而我修改后的hotword.py是:

`if command == "com.examples.actions.PlayMusic":
            print("Custom action is running")
            music = int( params['text'] )
            os.system("mpg123 'music.mp3' ")`

gactions工具成功更新了我的代码并将其部署在测试模式下。但是,当我运行hotword.py文件时,它给我一些某些模块丢失的错误。例如,它首先告诉我故障处理程序模块丢失了。然后,我运行pip install faulthandler并解决了。然后,它告诉我pathlib2丢失了。然后,我做了pip install pathlib2,它也得到解决。现在,它说google.oauth2.credentials本身丢失了。大声笑。即使我知道这样做不会有任何好处,我还是尝试了pip install google.oauth2.credentials并返回了预期的Could not find a version that satisfies the requirement google.oauth2.credentials (from versions: ) No matching distribution found for google.oauth2.credentials对话,因为pip不维护任何此类模块,而仅仅是由开发的自定义模块Google在SDK中。我究竟做错了什么?我最初以为这是SDK安装的问题,因此,我重新安装了整个SDK。还是和以前一样。 然后,我尝试以Google Developers Page中提到的普通形式运行hotword.py文件。它给出了完全相同的问题。            我运行了as exactly like in this json file

因此,我假设这不是我的代码有问题。无论如何,如果您最终发现我的代码中存在任何错误,请告诉我,因为我是JSON中的完整菜鸟。 现在,由于我已经预先安装了所有必需的文件,因此我仍然可以通过googlesamples-assistant-hotword --device-model-id 'model-identifier'命令运行助手服务。 我究竟做错了什么?请帮助我。

0 个答案:

没有答案
相关问题