热词.py在自定义操作中无法运行

2024-10-06 11:45:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将自定义操作添加到googleassistant SDK中。 我已经修改了操作.json文件和热词.py按我的操作所需的文件,并已保存它们。。你知道吗

我的操作.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" } } } ] } } } } ] }

我的手机被修改了热词.py是:

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

gactions工具成功地更新了我的代码,并在测试模式下部署了它。但是,当我运行热词.py文件,它给了我某些模块丢失的错误。例如,它首先告诉我faulthandler模块丢失了。然后,我运行pip install faulthandler,它被解决了。然后,它告诉我pathlib2不见了。然后,我做了pip install pathlib2,它也被解决了。现在,它说谷歌.oauth2。缺少凭据本身。哈哈,虽然我知道这不会有任何好处,但我尝试了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。还是和以前一样。 然后,我试着运行热词.py以Google Developers Page中提到的股票形式归档。它给出了完全相同的问题。 我跑了as exactly like in this json file

所以,我假设我的代码没有问题。不管怎样,如果你最终发现我的代码中有任何错误,请告诉我,因为我在JSON中是个十足的傻瓜。 现在,我仍然能够通过googlesamples-assistant-hotword --device-model-id 'model-identifier'命令运行助手服务,因为我已经预先安装了所有需要的文件。 我做错什么了?请帮帮我。。你知道吗


Tags: 模块pip文件thetextnamepycom