Segment SDK
SpeechSynthesis
Constructor |
new |
SpeechSynthesis() |
SpeechSynthesis constructor.
This class is used to execute TTS engine to speak out texts.
It should be called after a segment is started, however the
speech is muted by the system when the segment is paused or in an onpaused state.
Summary
Properties |
boolean |
speaking |
Methods |
cancel
|
Terminates the playback of speech synthesis. |
getInstance
|
Returns the instance of SpeechSynthesis. |
speak
|
Executes TTS |
Type definitions |
onstart
|
The callback function called invoked when speech starts. |
onend
|
The callback function called when speech ends. |
onerror
|
The callback function called when an error occurs. |
Properties
Name | Type | Description |
speaking |
boolean |
indicates whether the TTS engine is speaking or not. |
Methods
cancel()
Terminates the playback of speech synthesis.
getInstance()
Returns the instance of SpeechSynthesis.
Returns
Type |
Description |
da.SpeechSynthesis |
|
speak(text, callbackObject)
Executes TTS.
If speak() method is called before the previous speech completes, the new speech will take over and the previous speech will be stopped.
Parameters
Name |
Type |
Description |
text |
string |
Text to be spoken out. max 10000 bytes, the part that exceeds the max size is ignored. |
callbackObject |
Object |
The callback object |
|
Properties
|
Type definitions
onstart()
The callback function called invoked when speech starts.
onend()
The callback function called when speech ends.
onerror(error)
The callback function called when an error occurs.
Parameters
Name |
Type |
Description |
error |
Object |
Error object |
|
Properties
Name |
Type |
Description |
code |
number |
Error code:
- 900: indicates that speech synthesis was interrupted
- 901: indicates that text size exceeded the limit
- 999: unidentified error
|
message |
string |
The error message |
|