Error code
The TextToSpeech SDK reports errors that occur during initialization, app registration, and speech synthesis as ErrorType. Handle these errors through OnInitializeListener, OnServerConnectionListener, or EventListener.
ErrorType
| ErrorType | Description | Recommended action |
|---|---|---|
AUDIO_ERROR | Audio output or playback processing failed. | Check the audio configuration and output device, and then try again. |
INVALID_REQUEST_ERROR | The request value or request state is invalid. | Check request conditions such as the text and API call order. |
MIC_ERROR | An error occurred while processing the audio input device. | Check the audio device state in the runtime environment. |
NETWORK_ERROR | Network communication failed. | Check the network connection and try again. |
NOT_SUPPORTED_API | The API is not supported in the current mode or runtime environment. | Check the selected Mode and platform support. |
ON_DEVICE_ENGINE_ERROR | An error occurred in the on-device speech synthesis engine. | Check the engine state or consider using HYBRID or SERVER mode. |
PERMISSION_DENIED | The app does not have permission to access the TextToSpeech service. | Check the TTS_SERVICE permission in the manifest and the permission state in the runtime environment. |
SERVER_INTERNAL_ERROR | An internal Speech Service error occurred. | Try again later. If the problem continues, contact the service administrator. |
TIMEOUT | The request did not complete within the time limit. | Check the network and server status, and then try again. |
UNAUTHENTICATED | App authentication failed. | Check the My Project credentials from Pleos Playground or the UA app credentials and target environment. |
UNAVAILABLE_LANGUAGE | The requested language is unavailable. | Select a supported Locale. |
UNKNOWN | An unclassified error occurred. | Collect the call timing and environment information and contact the service administrator. |
Handle errors
Because new error types can be added to ErrorType, we recommend including 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()
else -> logError(errorType.name)
}
}
For the exact declaration of each error type, see the TextToSpeech API Reference.