Error code
The SpeechToText SDK reports errors that occur during initialization, app registration, and speech recognition as ErrorType. Handle these errors in OnInitializeListener, OnServerConnectionListener, or ResultListener.
ErrorType
| ErrorType | Description | Recommended action |
|---|---|---|
AUDIO_ERROR | Processing the input audio data failed. | Check the input data and audio format, and then retry the request. |
INVALID_REQUEST_ERROR | A request value or the request state is invalid. | Check the call order, duplicate requests, and input values. |
MIC_ERROR | An error occurred while starting or processing microphone input. | Check the microphone and sensor privacy settings. |
NETWORK_ERROR | Network communication failed. | Check the network connection and retry the request. |
NOT_SUPPORTED_API | The API is not supported in the current mode or runtime environment. | Check the selected Mode and the platform's supported functionality. |
ON_DEVICE_ENGINE_ERROR | An error occurred in the On-device speech recognition engine. | Check the engine state or consider HYBRID or SERVER mode. |
PERMISSION_DENIED | The app does not have permission to access the SpeechToText service. | Check the STT_SERVICE permission in the manifest and the runtime permission state. |
SERVER_INTERNAL_ERROR | An internal Speech Service error occurred. | Retry later. If it persists, contact the service administrator. |
TIMEOUT | The request did not complete within the time limit. | Check the network and server state, and then retry. |
UNAUTHENTICATED | App authentication failed. | Check the My Project credentials or UA app information in Pleos Playground and the target environment. |
UNAVAILABLE_LANGUAGE | The requested language is unavailable. | Change to a supported Locale. |
UNKNOWN | An unclassified error occurred. | Collect the call timing and environment details, and contact the service administrator. |
Handle errors
Because new error types may be added to ErrorType, include a default branch in a when or switch statement.
override fun onError(errorType: ErrorType) {
when (errorType) {
ErrorType.PERMISSION_DENIED -> checkSttPermission()
ErrorType.UNAUTHENTICATED -> checkCredentials()
ErrorType.NETWORK_ERROR,
ErrorType.TIMEOUT -> retryWhenNetworkIsAvailable()
else -> logError(errorType.name)
}
}
For the exact declaration of each error type, see the SpeechToText API Reference.