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.
- Kotlin
- Java
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.
}
})
import ai.pleos.playground.stt.constant.ErrorType;
import ai.pleos.playground.stt.listener.OnInitializeListener;
speechToText.initialize(new OnInitializeListener() {
@Override
public void onSuccess() {
// You can use the SpeechToText API.
}
@Override
public void 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().
- Kotlin
- Java
override fun onDestroy() {
speechToText.removeListener(resultListener)
speechToText.release()
super.onDestroy()
}
@Override
protected void 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.