如何更改 Google 助手 SDK 中的 language/locale?
How do I change the language/locale in the Google Assistant SDK?
从 Google Assistant SDK 0.4.1 开始,使用它的开发人员可以使用 Google 助手库和 Google 助手服务来更改 language/locale。
此 post 将解释开发人员如何利用此功能。
Google 助理服务
使用 gRPC API,开发人员可以轻松地以编程方式更改每个 API 调用中的语言环境。他们还可以将语言环境更改为 pushtotalk.py
示例的参数。
我们可以看一下 the Embedded Assistant protobuf,它显示了 API。
嵌入式助手 Protobuf
rpc Assist(stream AssistRequest) returns (stream AssistResponse);
API 调用需要一个 AssistantRequest
和 returns 一个 AssistResponse
一个AssistantRequest
can be an AssistConfig
. An AssistConfig
may contain several properties including a DialogStateIn
. A DialogStateIn
may contain several properties including a language_code
.
string language_code = 2;
来自关于此 属性 的文档:
// *Required* Language of the request in
// [IETF BCP 47 syntax](https://tools.ietf.org/html/bcp47). For example:
// "en-US". If you have selected a language for this `device_id` using the
// [Settings](https://developers.google.com/assistant/sdk/guides/assistant-settings)
// menu in your phone's Google Assistant app, that selection will override
// this value.
使用 en-US、fr-FR 等字符串或 Google 助理支持的任何其他语言环境。
pushtotalk.py
开发人员 运行 示例可以通过在 运行 脚本中包含 --lang
参数后跟区域设置代码来更改区域设置。
Google 助理设置
在您 register your device 之后,它将出现在 Google 助理设置的设备列表中。
Google 助手 > 探索 > 设置 > 设备
从这里,您可以进入每个设备的设置。这将允许您使用友好的选择器更改设备的语言。请注意,一旦您这样做,这将覆盖以编程方式设置的值。
Google 助理图书馆
如果您正在使用 Google 助手库或 hotword.py
示例,您只能在 phone 上的 Google 助手设置中更改语言。
从 Google Assistant SDK 0.4.1 开始,使用它的开发人员可以使用 Google 助手库和 Google 助手服务来更改 language/locale。
此 post 将解释开发人员如何利用此功能。
Google 助理服务
使用 gRPC API,开发人员可以轻松地以编程方式更改每个 API 调用中的语言环境。他们还可以将语言环境更改为 pushtotalk.py
示例的参数。
我们可以看一下 the Embedded Assistant protobuf,它显示了 API。
嵌入式助手 Protobuf
rpc Assist(stream AssistRequest) returns (stream AssistResponse);
API 调用需要一个 AssistantRequest
和 returns 一个 AssistResponse
一个AssistantRequest
can be an AssistConfig
. An AssistConfig
may contain several properties including a DialogStateIn
. A DialogStateIn
may contain several properties including a language_code
.
string language_code = 2;
来自关于此 属性 的文档:
// *Required* Language of the request in
// [IETF BCP 47 syntax](https://tools.ietf.org/html/bcp47). For example:
// "en-US". If you have selected a language for this `device_id` using the
// [Settings](https://developers.google.com/assistant/sdk/guides/assistant-settings)
// menu in your phone's Google Assistant app, that selection will override
// this value.
使用 en-US、fr-FR 等字符串或 Google 助理支持的任何其他语言环境。
pushtotalk.py
开发人员 运行 示例可以通过在 运行 脚本中包含 --lang
参数后跟区域设置代码来更改区域设置。
Google 助理设置
在您 register your device 之后,它将出现在 Google 助理设置的设备列表中。
Google 助手 > 探索 > 设置 > 设备
从这里,您可以进入每个设备的设置。这将允许您使用友好的选择器更改设备的语言。请注意,一旦您这样做,这将覆盖以编程方式设置的值。
Google 助理图书馆
如果您正在使用 Google 助手库或 hotword.py
示例,您只能在 phone 上的 Google 助手设置中更改语言。