Added in API level 34

ModelDownloadListener


interface ModelDownloadListener
android.speech.ModelDownloadListener

Listener for model download events. It makes RecognitionService let callers know about the progress of model download for a single recognition request.

Summary

Public methods
abstract Unit
onError(error: Int)

A network or scheduling error occurred.

abstract Unit
onProgress(completedPercent: Int)

Called by RecognitionService only if the download has started after the request.

abstract Unit

Called when RecognitionService scheduled the download, but won't satisfy it immediately.

abstract Unit

This method is called:

  • if the model is already available;
  • if the RecognitionService has started and completed the download.

    Once this method is called, the model can be safely used to satisfy recognition requests.

  • Public methods

    onProgress

    Added in API level 34
    abstract fun onProgress(completedPercent: Int): Unit

    Called by RecognitionService only if the download has started after the request.

    The number of calls to this method varies depending of the RecognitionService implementation. If the download finished quickly enough, onSuccess() may be called directly. In other cases, this method may be called any number of times during the download.

    Parameters
    completedPercent Int: the percentage of download that is completed

    onScheduled

    Added in API level 34
    abstract fun onScheduled(): Unit

    Called when RecognitionService scheduled the download, but won't satisfy it immediately. There will be no further updates on this listener.

    onSuccess

    Added in API level 34
    abstract fun onSuccess(): Unit

    This method is called:

  • if the model is already available;
  • if the RecognitionService has started and completed the download.

    Once this method is called, the model can be safely used to satisfy recognition requests.