Note
This API has been available since API level 11.
This API has been available since API level 11.
This service is used to recognize voice input.
It can use and customize the configurations defined by the configuration API (com.webos.service.config).
In webOS OSE, before using the ai.voice service, you need to set up Google Assistant on your device. The steps are detailed here:
Step A: Create credentials.json file.
Step B: Register the device ID.
Step C: Input the device model and device ID for AI service.
Step D: Reboot device or restart service daemon.
Step E: Launch the service using the start() method.
Note: Google assistant also supports custom device actions.
API level 11
Returns speech recognition results. This method is asynchronous.
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | Boolean | Subscribe for notifications. Possible values are:
Default value: false |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get notified. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
provider | Optional | String | Specifies the AI service provider that returns the results of speech recognition. In this case, it will always return "googleassistant". |
response | Optional | String | The results of speech recognition. Different providers will provide results in different format. |
Example scenario
Sample for webOS OSE users (when using googleassistant)
# luna-send -i -f luna://com.webos.service.ai.voice/getResponse '{"subscribe": true}'
Response:
{
"returnValue":true
}
Googleassistant for webOS OSE case:
Example subscribe for Trigger Word Detection:
{
"provider":"googleassistant",
"response":{
"keywordDetected":1
}
}
Example subscribe for Automatic Speech Recognition:
{
"provider":"googleassistant",
"response":{
"partial":"what"
}
}
{
"provider":"googleassistant",
"response":{
"partial":"what's"
}
}
{
"provider":"googleassistant",
"response":{
"partial":"what's the"
}
}
{
"provider":"googleassistant",
"response":{
"partial":"what's the weather"
}
}
{
"provider":"googleassistant",
"response":{
"displayText":"It looks pleasant outside Currently in Seoul it's 79 and partly cloudy. The forecast today is 78 and mostly cloudy. ( More on weather.com )"
}
}
API level 11
Gets the current state of the service. It can have the following states:
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Subscribe for notifications. Possible values are:
Default value: false |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | String | Indicates the status of operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get notified. Possible values are:
|
state | Required | String | Indicates the running state of the service. Possible values are:
|
errorCode | Optional | Number (int8_t) | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example scenario
# luna-send -n 1 -f luna://com.webos.service.ai.voice/getState '{}'
Response:
{
"returnValue":true,
"state":"idle"
}
# luna-send -i -f luna://com.webos.service.ai.voice/getState '{"subscribe": true}'
Response:
{
"returnValue":true,
"state":"idle"
}
{
"state":"waitActivation"
}
{
"state":"recording"
}
...
API level 11
Starts the service based on the mode selected.
Note: This method is only for allowed clients.
Name | Required | Type | Description |
---|---|---|---|
mode | Required | String | Select the service mode. Possible values are:
|
keywordDetect | Required | Boolean | Indicates if a keyword is to be used for activating speech recognition. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number (int8_t) | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example scenario
# luna-send -n 1 -f luna://com.webos.service.ai.voice/start '{"mode": "continuous", "keywordDetect": true}'
Response:
{
"returnValue":true
}
API level 11
Stops the service. Make sure to call this method before starting another engine.
Note: This method is only for allowed clients.
None
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number (int8_t) | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example scenario
# luna-send -n 1 -f luna://com.webos.service.ai.voice/stop '{}'
Response:
{
"returnValue":true
}
Error Code | Error Text | Error Description |
---|---|---|
-11 | Camera error has occurred | Camera error has occurred. |
-10 | Audio error has occurred | Audio error has occurred. |
-9 | Microphone error has occurred | Microphone error has occurred. |
-8 | Service had already started | Service had already started. |
-7 | Service had not started | Service had not started. |
-6 | Not supported | Not supported api. |
-5 | Network error has occurred | Network error has occurred. |
-3 | Invalid configurations | This error occurs when system missed the environment files. |
-2 | Invalid parameters | This error occurs when api parameters are incorrectly. |
-1 | Unknown error | Unknown error. |
0 | Not error | Not error. |
Contents