Skip to main content

Event listeners

Register a ResultListener to receive readiness, start, interim and final results, speech segment, input level, and error events for speech recognition.

CallbackDescription
onReady()Called when the SDK is ready to process a speech recognition request.
onStartedRecognition()Called when speech recognition starts.
onUpdated(stt, completed)Called when the recognized text is updated. If completed is true, the recognition result is final.
onUpdatedEpdData(on, off)Called when EPD (End Point Detection) updates the speech start (on) and end (off) positions. The values are byte offsets in the input audio buffer.
onUpdatedRms(rms)Called when the RMS (Root Mean Square) value of the input speech signal is updated. RMS represents 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 an interim or final recognition result.
}

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

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

speechToText.addListener(resultListener)

Register the listener before calling request() or sendAudio() so that no recognition events are missed. When the listener is no longer needed or before releasing the SDK, remove the same instance that was registered.

speechToText.removeListener(resultListener)

For error handling guidance, see Error code.