对 google 的 python SDK 的操作? [英] Actions on google's python SDK?

查看:12
本文介绍了对 google 的 python SDK 的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个基于 Python 的智能家居设备云服务,但在尝试将其与 Google 上的操作集成时,他们的 Python 库是Google Assistant Library for Python 自 2019 年 6 月 28 日起已弃用,请使用 Google代替助理服务."

我去了谷歌助手服务页面,它说 python 是你不能启动与谷歌助手 SDK 集成的商业设备.它仅可用于实验和非商业用途."

为什么会这样?这是否意味着它仍然处于测试阶段?我不应该打扰python吗?我真的很想坚持使用 python,因为我花了很多时间在它上面开发.

解决方案

我认为您混淆了一些不同但相关的事物,其中一些具有相似或重叠的名称.尝试解决问题:

Google 助理 SDK

Google 智能助理 SDK 和 Google 智能助理 gRPC 服务使您能够构建可运行的设备就像 Google Home.因此人们会直接与您的设备互动并使用它来控制 Google 助理.

  • 有用于此目的的 Python 库,因为许多爱好者在他们的设备上使用 Python.
  • 曾经有一个功能更全面的 SDK(用于 Python),但现在似乎不再受支持.
  • 即使支持有限,这也主要是针对业余爱好者的.听起来大多数面向消费者的设备都使用其他平台,这些平台要求您直接与 Google 合作.

对 Google 的操作

这是一个广义术语,描述了您可以通过 Google 助理制作人们会使用的方法,通过智能音箱或手机等设备.

大致可以分为几种不同的方法,其中一些方法重叠:

  • 与 Action SDK 和/或 Dialogflow 的对话体验
  • 智能家居操作
  • 内容操作,通过网络标记和/或模板
  • 移动集成

然而,通常当人们谈论 Actions on Google 时,他们谈论的是前两项中的一项,并且经常混淆 Action SDK 和 Dialogflow.

这些都没有明确支持或禁止 Python.

智能家居操作

智能家居操作专为与设备和特征,谷歌为其打造了对话体验.

智能家居操作有许多重要的区别:

  • 您无需确切了解用户可以说什么.这取决于您支持的设备和特征.Google 已经建立了词汇表,并向您发送了定义非常明确的命令,而不是广泛的对话.
  • 用户无需按名称专门调用您的产品.他们通过 Google Home 设置应用配置与您的产品的连接,然后可以更通用地寻址您的设备.

您的服务器可以用您希望的任何语言编写 - Google 将发送您注册的 HTTPS 端点 带有命令的 JSON,并希望您也使用 JSON 进行回复.没有针对此的特定 python 库 - 但大多数情况下不需要.最困难的部分是您需要支持用于帐户关联的OAuth,但这比您使用的语言和适用于整个平台的语言更重要.

Smart Home Actions 还可以支持 Local Home SDK,它允许命令可以直接在许多设备上执行,而无需到您的服务器进行处理.这必须用 TypeScript 或 JavaScript 编写,因此不支持 Python.

如果您要为智能家居设备进行构建,则应该使用智能家居操作而不是其他任何东西.您可能不想这样做的唯一原因是,如果您的设备类型与当前支持的设备有很大不同,您需要使用 Dialogflow 和/或 Action SDK 进行对话操作.>

对话流

Dialogflow 是 Google Cloud 的一款产品,为许多不同配置和集成.

使用它的一种方法(也是我在此讨论的唯一方法)是通过 Google 助理处理完成对话:

  • 用户通过智能助理调用你的操作,通常是说嘿谷歌,和莎士比亚侮辱对话"之类的话
  • 此调用以及此后对话中的每一步都由 Google 助理从语音转换为文本,然后发送到您在 对话流程<​​/a>
  • Dialogflow 确定哪个 Intent 与此用户输入匹配
  • 如果匹配的 Intent 配置为这样做,那么它将请求和其他信息转发到 您编写的履行网络钩子 正在您控制的某处服务器上运行
  • 此实现可以处理输入,确定回复,并将其发送回 Dialogflow,Dialogflow 将其发送回 Assistant,后者将其发送给用户

这个实现几乎可以用任何你想要的编程语言编写,包括 python.唯一的要求是

  1. 它可以在可公开访问的 HTTPS 服务器上运行
  2. 它可以在 Dialogflow 履行请求格式并在 Dialogflow+Action 执行响应格式.

谷歌没有支持这些 JSON 格式的特定库,但如果您想自己实现它们,它们是相当简单的.社区还开发了一些 Python 库,但我对它们的了解还不够多,无法建议哪些是目前最好的,或者哪些适用于当前协议.

动作 SDK

有时在文档中称为 Conversation API 或 SDK,尽管现在他们通常称其为 Action SDK.

这与 Dialogflow 的工作方式类似(实际上,Dialogflow 使用它),但不同的是没有 NLP 系统可以从用户的语音中确定用户的意图:

  • 用户仍然使用诸如Hey Google,与 Shakespearean Insult 交谈"之类的短语来调用操作
  • 此调用以及之后的每一步都由 Google 助理从语音转换为文本
  • 不同的是,此文本会直接发送到您的网络钩子,以及 对话请求格式 JSON
  • 您可以将其发送到 NLP/NLU 系统以了解用户的行为.
    • 您可能认为使用正则表达式可以做到这一点.你不能.但是还有许多其他优秀的 NLP/NLU 库可以与 Python 配合使用.
  • 您的网络钩子将使用 JSON 发送响应 助理将发送给用户.

同样,没有特定的 Google 支持的 Python 库来处理这个问题,但可能有社区开发的库可以做到这一点.

除非您有充分的理由使用更原始的 Action SDK(例如已经在使用现有 NLP/NLU 系统的现有组件),否则您应该使用 Dialogflow.

I developed a smart home device cloud service that's based on python, but while trying to integrate it with actions on google, their library for python is "Google Assistant Library for Python is deprecated as of June 28th, 2019, Use the Google Assistant Service instead."

i went to the google assistant service page and it says that python is "You can't launch commercial devices that integrate with the Google Assistant SDK. It's available for experimental and non-commercial uses only."

why is this the case? does it mean it is still in beta for them? should i not bother with python? i really would like to stick with python since I've spent a good amount of time developing on it.

解决方案

I think you're mixing up a few different, but related, things, some of which have similar or overlapping names. To try and clear things up:

Google Assistant SDK

The Google Assistant SDK and Google Assistant gRPC service enable you to build a device that works like a Google Home. So people would interact directly with your device and use it to control the Assistant.

  • There are python libraries for this because python is used by many hobbyists on their devices.
  • There used to be a more full-featured SDK (for python), but this appears to no longer be supported.
  • Even with the limited support, this is mostly for hobbyists. It sounds like most devices being made for consumers are using other platforms that require you to partner with Google directly.

Actions on Google

This is a broad term, describing ways that you can make something that people will use through the Google Assistant, via devices such as their Smart Speakers or phone.

It can very roughly be broken up into a couple of different approaches, some of which overlap:

Usually when people talk about Actions on Google, however, they're talking about one of the first two items, and often confusing the Action SDK and Dialogflow.

None of these specifically support, nor prohibit, python.

Smart Home Actions

Smart Home Actions are specifically built to work with the set of devices and traits that Google has built conversational experiences for.

There are a number of important distinctions about Smart Home Actions:

  • You don't need to figure exactly what the user can say. That is determined by the devices and traits you support. Google has built the vocabulary and sends you very discretely defined commands rather than broad conversations.
  • Users don't need to specifically invoke your product by name. They configure the connection to your product through the Google Home setup app and then can address your devices more generically.

Your server can be written in any language you wish - Google will send your registered HTTPS endpoint JSON with the commands, and expects you to reply with JSON as well. There is no specific python library for this - but mostly there doesn't need to be. The most difficult part is that you will need to support OAuth for account linking, but that is a bigger issue than what language you're using and goes to your entire platform.

Smart Home Actions can also support the Local Home SDK, which allows commands to be executed on many devices directly, without having to go to your server for processing. This must be written in either TypeScript or JavaScript, so does not support python.

If you are building for a Smart Home device, you should be using Smart Home Actions rather than anything else. The only reason you might not want to is if you have a device type that is so different from the currently supported devices, you need to make a conversational Action with Dialogflow and/or the Action SDK.

Dialogflow

Dialogflow is a product from Google Cloud that provides a Natural Language Processing system for a number of different configurations and integrations.

One way to use it (and the only one I discuss here) is to process and fulfill conversations through the Google Assistant:

  • Users invoke your Action through the Assistant, usually by saying something like "Hey Google, talk to Shakespearean Insult"
  • This invocation, and every step in the conversation afterwards, is converted from speech into text by the Assistant and then sent to your configuration in Dialogflow
  • Dialogflow determines which Intent matches this user input
  • If the matched Intent is configured to do so, it will then forward the request and additional information to a Fulfillment webhook that you have written that is running on a server you control somewhere
  • This fulfillment can then process the input, determine a reply, and send this back to Dialogflow, which will send it back to the Assistant, which will send it to the user

This fulfillment can be written in nearly any programming language you want, including python. The only requirements are that

  1. It can run on a publicly accessible HTTPS server
  2. It can accept JSON in the Dialogflow fulfillment request format and return JSON in the Dialogflow+Action fulfillment response format.

There is no specific library from Google that supports these JSON formats, but they are fairly straightforward if you want to implement it yourself. There have also been python libraries worked on by the community, but I don't know enough about them to advise which are the best ones right now or which ones work with the current protocol.

Action SDK

Sometimes this is called the Conversation API or SDK in the documentation, although usually they call it the Action SDK these days.

This is similar to how Dialogflow works (in fact, Dialogflow uses it), but differs that there is no NLP system that can determine the user's Intent from their speech:

  • Users still invoke the Action with a phrase such as "Hey Google, talk to Shakespearean Insult"
  • This invocation, and every step after, is converted from speech into text by the Assistant
  • The difference, however, is that this text is sent directly to your webhook, along with some other metadata in the conversation request format JSON
  • It is up to you to send it to an NLP/NLU system to get understanding from what the user has done.
    • You may think you can do this with regexps. You can't. But there are many other good NLP/NLU libraries out there that work with python.
  • Your webhook will send a response using JSON which the Assistant will send to the user.

Again, there is no specific Google supported python library to handle this, but there may be community developed libraries that can do so.

Unless you have a very good reason for using the more raw Action SDK (such as existing components that already are using an existing NLP/NLU system), you should probably use Dialogflow.

这篇关于对 google 的 python SDK 的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆