As of the Google Assistant SDK 0.4.1, developers using it can change the language/locale using both the Google Assistant Library and the Google Assistant Service.
This post will explain how developers can take advantage of this feature.
As of the Google Assistant SDK 0.4.1, developers using it can change the language/locale using both the Google Assistant Library and the Google Assistant Service.
This post will explain how developers can take advantage of this feature.
Using the gRPC API, developers can easily and programmatically change the locale in each API call. They can also change the locale as an argument to the pushtotalk.py
sample.
We can take a look at the Embedded Assistant protobuf which shows the API.
rpc Assist(stream AssistRequest) returns (stream AssistResponse);
The API call requires an AssistantRequest
and returns an AssistResponse
An 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;
From the documentation about this property:
// *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.
Using strings such as en-US, fr-FR or any other locale that the Assistant supports.
pushtotalk.py
Developers running the sample can change locales by including the --lang
argument followed by the locale code when running the script.
After you register your device it will appear in the list of devices in the Google Assistant settings.
Google Assistant > Explore > Settings > Devices
From here, you can go into settings for each device. This will allow you to change the language of the device using a friendly picker. Note that once you do, this will override the value set programmatically.
If you are using the Google Assistant Library or the hotword.py
sample, you can only change the language in the Google Assistant settings on your phone.