Skip to main content

Event listeners

Registering a ResultListener allows you to receive events for the preparation, start, intermediate and final results, voice segments, input size, and errors of speech recognition.

CallbackDescription
onReady()Called when the system is ready to process a speech recognition request.
onStartedRecognition()Called when speech recognition starts.
onUpdated(stt, completed)Called when the recognition text is updated. If completed is true, the recognition result is final.
onUpdatedEpdData(on, off)Called when the start (on) and end (off) positions detected by EPD (End Point Detection) are updated. The position values are byte offsets in the input audio buffer.
onUpdatedRms(rms)Called when the RMS (Root Mean Square) value of the input voice signal is updated. RMS represents the signal magnitude and is not a dB value.
onEndedRecognition()Called when speech recognition ends.
onError(errorType)Called when an error occurs during processing.
private val resultListener = object : ResultListener {
override fun onReady() = Unit
override fun onStartedRecognition() = Unit

override fun onUpdated(stt: String, completed: Boolean) {
// Handle intermediate or final recognition results.
}

override fun onUpdatedEpdData(on: Long, off: Long) = Unit
override fun onUpdatedRms(rms: Double) = Unit
override fun onEndedRecognition() = Unit

override fun onError(errorType: ErrorType) {
// Handle errors.
}
}

speechToText.addListener(resultListener)

To ensure you don't miss recognition events, register the listener before calling request() or sendAudio(). Remove the same instance used for registration when the listener is no longer needed or before releasing the SDK.

speechToText.removeListener(resultListener)

For handling errors, refer to Error code.