Skip to main content

Initialization

You must call initialize() after creating a SpeechToText object to use the API. When finished using the SDK, call release() to release connections and internal resources.

Initialize the SDK

If you need the initialization result, pass OnInitializeListener.

import ai.pleos.playground.stt.constant.ErrorType
import ai.pleos.playground.stt.listener.OnInitializeListener

speechToText.initialize(object : OnInitializeListener {
override fun onSuccess() {
// You can use the SpeechToText API.
}

override fun onFailure(errorType: ErrorType) {
// Handle initialization failures.
}
})

If a result callback is not needed, you can call it without arguments.

speechToText.initialize()

Release the SDK

Reuse the SpeechToText object according to the lifecycle of the component using it. When it is no longer needed or when the application is terminated, remove the registered result listener and call release().

override fun onDestroy() {
speechToText.removeListener(resultListener)
speechToText.release()
super.onDestroy()
}

To use the SDK again after release(), create a new object and perform the initialization procedure again.