示例和工具google assistant sdk
google-assistant-sdk的Python项目详细描述
此软件包包含一组示例和工具,可帮助您 使用Python开始使用Google Assistant SDK。
安装
您可以使用pip:
pip install --upgrade google-assistant-sdk[samples]
用法
谷歌oauthlib工具
此工具创建测试凭据以授权设备调用 原型设计时使用google assistant api。
按照步骤configure the Actions Console project and the Google account。
按照步骤register a new device model and download the client secrets file。
使用google-oauthlib-tool:
生成设备凭据pip install –upgrade google-auth-oauthlib[tool] google-oauthlib-tool –client-secrets path/to/client_secret_<client-id>.json –scope https://www.googleapis.com/auth/assistant-sdk-prototype –save –headless
googlesamples助手听力测试
此工具验证音频录制和播放的设备设置。
安装示例的依赖项:
sudo apt-get install portaudio19-dev libffi-dev libssl-dev pip install --upgrade google-assistant-sdk[samples]
录制10秒音频样本并播放:
googlesamples-assistant-audiotest --record-time 10
为吞吐量有限的声卡调整声音设备块大小和刷新大小:
googlesamples-assistant-audiotest --record-time 10 --audio-block-size=3200 --audio-flush-size=6400
相同的--audio-block-size和--audio-flush-size选项可以 用于sdk中包含的gRPC示例。
googlesamples辅助设备工具
此工具允许您注册google助手设备模型和 实例并将它们与设备操作特征相关联。
安装示例的依赖项:
sudo apt-get install portaudio19-dev libffi-dev libssl-dev pip install --upgrade google-assistant-sdk[samples]
显示cli工具的用法:
googlesamples-assistant-devicetool --help
注册新设备型号和新设备实例(在替换引号之间的“占位符值”之后):
googlesamples-assistant-devicetool --project-id PROJECT_ID register --model 'my-model-identifier' \ --type LIGHT --trait action.devices.traits.OnOff \ --manufacturer 'Assistant SDK developer' \ --product-name 'Assistant SDK light' \ --description 'Assistant SDK light device' \ --device 'my-device-identifier' \ --nickname 'My Assistant Light'
用支持的特征注册或覆盖设备型号(在替换引号之间的“占位符值”之后):
googlesamples-assistant-devicetool --project-id PROJECT_ID register-model --model 'my-model-identifier' \ --type LIGHT --trait action.devices.traits.OnOff \ --manufacturer 'Assistant SDK developer' \ --product-name 'Assistant SDK light' \ --description 'Assistant SDK light device'
注意:模型标识符必须是全局唯一的。
使用设备型号注册或覆盖设备实例(在替换引号之间的“占位符值”之后):
googlesamples-assistant-devicetool --project-id PROJECT_ID register-device --device 'my-device-identifier' \ --model 'my-model-identifier' \ --nickname 'My Assistant Light'
注意:设备实例标识符在与设备关联的google开发人员项目中应该是唯一的。
验证设备型号和实例是否已正确注册:
googlesamples-assistant-devicetool --project-id PROJECT_ID get --model 'my-model-identifier' googlesamples-assistant-devicetool --project-id PROJECT_ID get --device 'my-device-identifier'
列出所有设备型号和实例:
googlesamples-assistant-devicetool --project-id PROJECT_ID list --model googlesamples-assistant-devicetool --project-id PROJECT_ID list --device
googlesamples助手pushtotalk
这个参考示例为Google Assistant Service实现了一个简单但实用的客户端。
安装示例的依赖项:
sudo apt-get install portaudio19-dev libffi-dev libssl-dev pip install --upgrade google-assistant-sdk[samples]
运行push-to-talk示例。此示例记录按键后的语音查询,并回放Google助手的答案:
googlesamples-assistant-pushtotalk --device-model-id 'my-device-model' --device-id 'my-device-identifier'
试试google助手的语音查询,比如“现在几点了?”或者“我是谁?“。
尝试“启用昵称/型号产品名”之类的设备操作查询。
以详细模式运行以查看GRPC与Google助手API的通信:
googlesamples-assistant-pushtotalk --device-model-id 'my-device-model' --device-id 'my-device-identifier' -v
另请参见grpc sample README。
googlesamples助手热词
此引用示例为Google Assistant Library(linux_arm7l和linux_x86_64)实现了一个简单但功能性强的客户端。
安装google-assistant-library包:
pip install --upgrade google-assistant-library pip install --upgrade google-assistant-sdk[samples]
尝试Hotword示例:
googlesamples-assistant-hotword --device_model_id 'my-model-identifier'
另请参见示例library sample README。
对于维护人员
有关 python包本身的开发、维护和发布。
许可证
版权所有(c)2017 Google Inc.
由一个或多个贡献者授权给apache软件基金会(asf) 许可协议。请参阅随本工作一起分发的通知文件 有关版权所有权的其他信息。ASF授权此 根据apache许可证2.0版(“许可证”)向您提交文件;您不能 除非符合许可证,否则请使用此文件。你可以得到一份 在
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则软件 根据许可证分发的是按“原样”分发的,而不是 明示或默示的任何形式的保证或条件。见 管理以下权限和限制的特定语言的许可证 执照。