com.webos.service.ai.voice

API Summary

This service can be used to recognize voice input.

Overview of the API

(click to expand)

NA


Open All


start

Description

Starts the service based on the mode selected. It also checks if speech recognition is to be activated by a keyword (such as 'OK Google', 'Hi
LG') or a press-to-talk button.

Note: This method is only for allowed clients.

Parameters

Name

Required

Type

Description

modeRequiredString

Select the service mode. Possible values are: 

  • continuous - The service will restart automatically when a conversation ends.
  • single - The service will be stopped when a conversation ends.
keywordDetectRequiredBoolean

Indicates if a keyword is to be used for activating speech recognition. Possible values are:

  • true: Activated by a keyword. For example, "Hi LG" or "OK Google".
  • false: Activated by a button press.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber (int8_t)

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

luna-send -n 1 -f luna://com.webos.service.ai.voice/start '{"mode": "continuous", "keywordDetect": true}'

{

"returnValue": true

}

 

luna-send -n 1 -f luna://com.webos.service.ai.voice/start '{"mode": "single", "keywordDetect": false}'

{

"returnValue": true

}


getState

Description

Gets the current state of the service. It can have the following states:

  • idle: Before start.
  • waitActivation: Wait for keyword activation.
  • recording: Uploading audio to the server for speech recognition.
  • thinking: Waiting for results from server.
  • answering: Answering to the request through the speaker.

getState.png

Parameters

Name

Required

Type

Description

subscribe Optional Boolean

Subscribe for notifications. Possible values are:

  • true - Get notifications.
  • false - Notifications are not required.

Default value: false

Call Returns

Name

Required

Type

Description

returnValue Required String

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
subscribed Optional Boolean

Indicates if subscribed to get notified. Possible values are:

  • true - Get notifications
  • false - Notifications are not required
state Required String

Indicates the running state of the service. Possible values are:

  • idle
  • waitActivation
  • recording
  • thinking
  • answering
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

luna-send -n 1 -f luna://com.webos.service.ai.voice/getState '{}'

{

"returnValue": true

"state": idle

}

 

luna-send -i -f luna://com.webos.service.ai.voice/getState '{"subscribe": true}'

{

"returnValue": true

"state": "idle"

}

{

"state": "waitActivation"

}

{

"state": "recording"

}

...


getResponse

Description

Returns speech recognition results. This method is asynchronous.

Parameters

Name

Required

Type

Description

subscribeRequiredBoolean

Subscribe for notifications. Possible values are:

  • true - Get notifications.
  • false - Notifications are not required.

Default value: false

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
subscribedOptionalBoolean

Indicates if subscribed to get notified. Possible values are:

  • true - Get notifications.
  • false - Notifications are not required​.
providerOptionalString

Describes where the results of speech recognition are from.

It specifies the AI service provider, for example, googleassistant

responseOptionalString

This value consist of speech recognition results.

Results formats maybe different by provider.

Example

luna-send -i -f luna://com.webos.service.ai.voice/getResponse '{"subscribe": true}'

 

Returns:

{

"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 )"

    }

}


stop

Description

Stops the service. This method is only for allowed clients.

Parameters

None

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber (int8_t)

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

luna-send -n 1 -f luna://com.webos.service.ai.voice/stop '{}'

{

"returnValue": true

}


ERROR REFERENCES

Error Code

Error Text

Error Description

0Not error

Not error.

-1Unknown error

Unknown error.

-2Invalid parameters

This error occurs when api parameters are incorrectly.

-3Invalid configurations

This error occurs when system missed the environment files.

-5Network error has occurred

Network error has occurred.

-6Not supported

Not supported api.

-7Service had not started

Service had not started.

-8Service had already started

Service had already started.

-9Microphone error has occurred

Microphone error has occurred.

-10Audio error has occurred

Audio error has occurred.

-11Camera error has occurred

Camera error has occurred.


Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.