Error code
The SpeechToText SDK delivers errors that occur during initialization, app registration, and speech recognition as ErrorType. Errors can be handled in OnInitializeListener, OnServerConnectionListener, or ResultListener.
ErrorType
| ErrorType | Description | Recommended action |
|---|---|---|
AUDIO_ERROR | Failed to process input audio data. | Check the input data and audio format, then request again. |
INVALID_REQUEST_ERROR | The request value or request status is incorrect. | Verify the call sequence, duplicate requests, and input values. |
MIC_ERROR | An error occurred while starting or processing microphone input. | Check the microphone status and sensor privacy settings. |
NETWORK_ERROR | Failed to communicate over the network. | Check the network connection and request again. |
NOT_SUPPORTED_API | The API is not supported in the current mode or execution environment. | Verify the support range of the selected Mode and platform. |
ON_DEVICE_ENGINE_ERROR | An error occurred in the on-device speech recognition engine. | Check the engine status or review HYBRID or SERVER mode. |
PERMISSION_DENIED | No access permission to the SpeechToText service. | Check the STT_SERVICE permission in the manifest and the permission status of the execution environment. |
SERVER_INTERNAL_ERROR | An internal error occurred in the Speech Service. | Request again later, and if it repeats, contact the service administrator. |
TIMEOUT | The request was not completed within the time limit. | Check the network and server status, then request again. |
UNAUTHENTICATED | App authentication failed. | Verify the credentials of My Project in Pleos Playground or UA app information and access environment. |
UNAVAILABLE_LANGUAGE | The requested language is not available. | Change to a supported Locale. |
UNKNOWN | An unclassified error occurred. | Collect the call timing and environment information and contact the service administrator. |
UNCLASSIFIED(message) | An error not defined by the SDK, including the original message. | Record the message without sensitive information and identify the cause according to the message. |
Handle errors
Since new error types can 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 -> checkSttPermission()
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 SpeechToText API Reference.