A org.rdk.TextToSpeech plugin for Thunder framework.
The TextToSpeech plugin provides TTS functionality (Voice Guidance & Speech Synthesis) for the client application.
The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].
The table below lists configuration options of the plugin.
| Name | Type | Description |
|---|---|---|
| callsign | string | Plugin instance name (default: org.rdk.TextToSpeech) |
| classname | string | Class name: org.rdk.TextToSpeech |
| locator | string | Library name: libWPEFrameworkTextToSpeech.so |
| autostart | boolean | Determines if the plugin shall be started automatically along with the framework |
The following methods are provided by the org.rdk.TextToSpeech plugin:
TextToSpeech interface methods:
| Method | Description |
|---|---|
| cancel | Cancels the speech |
| enabletts | (For Resident App) Enables or disables the TTS conversion processing |
| getapiversion | Gets the API Version |
| getspeechstate | Returns the current state of the speech request |
| getttsconfiguration | Gets the current TTS configuration |
| isspeaking | Checks if speech is in progress |
| isttsenabled | Returns whether the TTS engine is enabled or disabled |
| listvoices | Lists the available voices for the specified language |
| pause | Pauses the speech |
| resume | Resumes the speech |
| setttsconfiguration | Sets the TTS configuration |
| speak | Converts the input text to speech when TTS is enabled |
| setACL | Configures app to speak |
Cancels the speech. Triggers the onspeechinterrupted
| Event | Description |
|---|---|
| onspeechinterrupted | Triggered when ongoing speech is cancelled. Event is not triggered: if TTS is not enabled; if ongoing Speech is completed |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.cancel",
"params": {
"speechid": 1
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"TTS_Status": 0,
"success": true
}
}(For Resident App) Enables or disables the TTS conversion processing. Triggered onttsstatechanged event when state changes and onspeechinterrupted event when disabling TTS while speech is in-progress.
| Event | Description |
|---|---|
| onttsstatechanged | state : true Triggered when TTS is enabled; state : false Triggered when TTS is disabled; otherwise No event When TTS enable or disable is in-progress |
| onspeechinterrupted | Triggered when disabling TTS while speech is in-progress. |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.enabletts | boolean | Enable or Disable TTS |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.enabletts",
"params": {
"enabletts": true
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"TTS_Status": 0,
"success": true
}
}Gets the API Version.
No Events
This method takes no parameters.
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.version | number | Indicates the API Version |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.getapiversion"
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"version": 1,
"success": true
}
}Returns the current state of the speech request.
No Events
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.speechstate | string | The speech state (must be one of the following: SPEECH_PENDING(0), SPEECH_IN_PROGRESS(1), SPEECH_PAUSED(2), SPEECH_NOT_FOUND(3)) |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.getspeechstate",
"params": {
"speechid": 1
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"speechstate": "SPEECH_IN_PROGRESS",
"TTS_Status": 0,
"success": true
}
}Gets the current TTS configuration.
No Events
This method takes no parameters.
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.ttsendpoint | string | The TTS engine URL |
| result.ttsendpointsecured | string | The TTS engine secured URL |
| result.language | string | The TTS language |
| result.voice | string | The TTS Voice |
| result.volume | string | The TTS Volume |
| result.rate | number | The TTS Rate |
| result?.speechrate | string | (optional) TTS Rate for TTS2 endpoint |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.getttsconfiguration"
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"ttsendpoint": "http://url_for_the_text_to_speech_processing_unit",
"ttsendpointsecured": "https://url_for_the_text_to_speech_processing_unit",
"language": "en-US",
"voice": "carol",
"volume": "100.000000",
"rate": 50,
"speechrate": "medium",
"TTS_Status": 0,
"success": true
}
}Checks if speech is in progress.
No Events
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.speaking | boolean | true if the passed speech is in progress (that is, audio was playing), false if speech is completed or speech ID not found |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.isspeaking",
"params": {
"speechid": 1
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"speaking": true,
"TTS_Status": 0,
"success": true
}
}Returns whether the TTS engine is enabled or disabled. By default the TTS engine is disabled.
No Events
This method takes no parameters.
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.isenabled | boolean | true if the TTS engine is enabled, otherwise false |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.isttsenabled"
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"isenabled": true,
"TTS_Status": 0,
"success": true
}
}Lists the available voices for the specified language. For every language there is a set of pre-defined voices.
No Events
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.language | string | The TTS language |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.voices | string | Array of available voice |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.listvoices",
"params": {
"language": "en-US"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"voices": "carol",
"TTS_Status": 0,
"success": true
}
}Pauses the speech. Triggers the onspeechpause
| Event | Description |
|---|---|
| onspeechpause | Triggered when ongoing speech is paused. Event not triggered on following conditions: TTS is not enabled; Speech is already in pause; or Speech is completed |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.pause",
"params": {
"speechid": 1
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"TTS_Status": 0,
"success": true
}
}Resumes the speech. Triggers the onspeechresume
| Event | Description |
|---|---|
| onspeechresume | Triggered when speech is resumed and speech output is available. Event not triggered under following conditions: TTS is not enabled; Speech is resumed already; or Speech is completed |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.resume",
"params": {
"speechid": 1
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"TTS_Status": 0,
"success": true
}
}Sets the TTS configuration. Triggers the onvoicechanged
| Event | Description |
|---|---|
| onvoicechanged | Triggered only when the voice configuration is changed |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params?.ttsendpoint | string | (optional) The TTS engine URL |
| params?.ttsendpointsecured | string | (optional) The TTS engine secured URL |
| params?.language | string | (optional) The TTS language |
| params?.voice | string | (optional) The TTS Voice |
| params?.volume | string | (optional) The TTS Volume |
| params?.primvolduckpercent | number | (optional) The TTS Primary Volumeduckpercentage |
| params?.rate | number | (optional) The TTS Rate |
| params?.speechrate | string | (optional) TTS Rate for TTS2 endpoint |
| params?.fallbacktext | object | (optional) |
| params?.fallbacktext?.scenario | string | (optional) Describes the scenario where fallback text is to be used . At present, only offline is supported |
| params?.fallbacktext?.value | string | (optional) The Text which is to be spoken when the scenario is met |
| params?.authinfo | object | (optional) |
| params?.authinfo?.type | string | (optional) The type of authentication. At present, only apikey is supported |
| params?.authinfo?.value | string | (optional) x api key(secret key) required for GCD Endpoints |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.setttsconfiguration",
"params": {
"ttsendpoint": "http://url_for_the_text_to_speech_processing_unit",
"ttsendpointsecured": "https://url_for_the_text_to_speech_processing_unit",
"language": "en-US",
"voice": "carol",
"volume": "100.000000",
"primvolduckpercent": 25,
"rate": 50,
"speechrate": "medium",
"fallbacktext": {
"scenario": "offline",
"value": "No Internet connection"
},
"authinfo": {
"type": "apikey",
"value": "XXXXXXXXXXXX"
}
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"TTS_Status": 0,
"success": true
}
}Converts the input text to speech when TTS is enabled. Any ongoing speech is interrupted and the newly requested speech is processed. The clients of the previous speech is sent an onspeechinterrupted Upon success, this API returns an ID, which is used as input to other API methods for controlling the speech (for example, pause, resume, and cancel).
| Event | Description |
|---|---|
| onwillspeak | Triggered when speech conversion is about to start |
| onspeechstart | Triggered when conversion of text to speech is started |
| onspeechinterrupted | Current speech is interrupted either by a next speech request; by calling the cancel method; or by disabling TTS, when speech is in-progress |
| onspeechcomplete | Triggered when conversion from text to speech is completed |
| onnetworkerror | Triggered when failed to fetch audio from the endpoint |
| onplaybackerror | Triggered when an error occurs during playback including pipeline failures; Triggered when speak is called during TTS disabled |
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.text | string | The text input |
| params?.callsign | string | (optional) Callsign of the application. This is mandatory when setACL is called prior to speak |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.speechid | number | The speech ID |
| result.TTS_Status | number | (must be one of the following: TTS_OK(0), TTS_FAIL(1), TTS_NOT_ENABLED(2), TTS_INVALID_CONFIGURATION(3)) |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.speak",
"params": {
"text": "speech_1",
"callsign": "WebApp"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"speechid": 1,
"TTS_Status": 0,
"success": true
}
}Configures app to speak. Allows the ResidentAPP to configure the particular app and provides access to speak If not configured any then gives access to all apps to speak. Configuration does not retained after reboot.
No Events
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.accesslist | array | |
| params.accesslist[#] | object | |
| params.accesslist[#].method | string | Method of TTS function to be performed |
| params.accesslist[#].apps | array | List of client application |
| params.accesslist[#].apps[#] | string |
| Name | Type | Description |
|---|---|---|
| result | object | |
| result.success | boolean | Whether the request succeeded |
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.TextToSpeech.setACL",
"params": {
"accesslist": [
{
"method": "speak",
"apps": [
"App1"
]
}
]
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": {
"success": true
}
}Notifications are autonomous events, triggered by the internals of the implementation, and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.
The following events are provided by the org.rdk.TextToSpeech plugin:
TextToSpeech interface events:
| Event | Description |
|---|---|
| onnetworkerror | Triggered when a network error occurs while fetching the audio from the endpoint |
| onplaybackerror | Triggered when an error occurs during playback including pipeline failures |
| onspeechcomplete | Triggered when the speech completes |
| onspeechinterrupted | Triggered when the current speech is interrupted either by a next speech request, by calling cancel or by disabling TTS, when speech is in progress |
| onspeechpause | Triggered when the ongoing speech pauses |
| onspeechresume | Triggered when any paused speech resumes |
| onspeechstart | Triggered when the speech start |
| onttsstatechanged | Triggered when TTS is enabled or disabled |
| onvoicechanged | Triggered when the configured voice changes |
| onwillspeak | Triggered when the text to speech conversion is about to start |
Triggered when a network error occurs while fetching the audio from the endpoint.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onnetworkerror",
"params": {
"speechid": 1
}
}Triggered when an error occurs during playback including pipeline failures.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onplaybackerror",
"params": {
"speechid": 1
}
}Triggered when the speech completes.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onspeechcomplete",
"params": {
"speechid": 1
}
}Triggered when the current speech is interrupted either by a next speech request, by calling cancel or by disabling TTS, when speech is in progress.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onspeechinterrupted",
"params": {
"speechid": 1
}
}Triggered when the ongoing speech pauses.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onspeechpause",
"params": {
"speechid": 1
}
}Triggered when any paused speech resumes.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onspeechresume",
"params": {
"speechid": 1
}
}Triggered when the speech start.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onspeechstart",
"params": {
"speechid": 1
}
}Triggered when TTS is enabled or disabled.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.state | boolean | True if TTS is enabled, otherwise False |
{
"jsonrpc": "2.0",
"method": "client.events.onttsstatechanged",
"params": {
"state": true
}
}Triggered when the configured voice changes.
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.voice | string | The TTS Voice |
{
"jsonrpc": "2.0",
"method": "client.events.onvoicechanged",
"params": {
"voice": "carol"
}
}Triggered when the text to speech conversion is about to start. It provides the speech ID, generated for the text input given in the speak
| Name | Type | Description |
|---|---|---|
| params | object | |
| params.speechid | number | The speech ID |
{
"jsonrpc": "2.0",
"method": "client.events.onwillspeak",
"params": {
"speechid": 1
}
}