Error code
The TextToSpeech SDK communicates errors that occur during initialization, app registration, and speech synthesis as ErrorType. Errors can be handled in OnInitializeListener, OnServerConnectionListener, or EventListener.
ErrorType
| ErrorType | Description | Recommended action |
|---|---|---|
AUDIO_ERROR | Failed to process audio output or playback. | Check audio settings and output device status, then try again. |
INVALID_REQUEST_ERROR | The request value or request status is incorrect. | Verify request conditions such as text and call order. |
MIC_ERROR | An error occurred while processing the audio input device. | Check the status of the audio device in the execution environment. |
NETWORK_ERROR | Failed to communicate over the network. | Check the network connection and try again. |
NOT_SUPPORTED_API | The API is not supported in the current mode or execution environment. | Verify the selected Mode and platform support range. |
ON_DEVICE_ENGINE_ERROR | An error occurred in the on-device speech synthesis engine. | Check the engine status or consider HYBRID or SERVER mode. |
PERMISSION_DENIED | Access to the TextToSpeech service is denied. | Check the TTS_SERVICE permission in the manifest and the permission status in the execution environment. |
SERVER_INTERNAL_ERROR | An internal error occurred in the Speech Service. | Try again later, and if it persists, contact the service administrator. |
TIMEOUT | The request could not be completed within the time limit. | Check the network and server status, then try again. |
UNAUTHENTICATED | App authentication failed. | Verify credentials in Pleos Playground's My Project or UA app information and connection environment. |
UNAVAILABLE_LANGUAGE | The requested language is not available. | Change to a supported Locale. |
UNKNOWN | An unclassified error occurred. | Collect information about the call timing and environment, then contact the service administrator. |
UNCLASSIFIED(message) | An error not defined by the SDK, including the original message. | Record the message and determine the cause based on it. |
Handle errors
Since new error types may be added to ErrorType, it is recommended to include a default branch in when or switch statements.
override fun onError(errorType: ErrorType) {
when (errorType) {
ErrorType.PERMISSION_DENIED -> checkTtsPermission()
ErrorType.UNAUTHENTICATED -> checkCredentials()
ErrorType.NETWORK_ERROR,
ErrorType.TIMEOUT -> retryWhenNetworkIsAvailable()
is ErrorType.UNCLASSIFIED -> logError(errorType.message)
else -> logError(errorType.name)
}
}
The exact declaration of each error type can be found in the TextToSpeech API Reference.