目录

class info
com.huawei.hms.mlsdk.asr.MLAsrRecognizer
Speech recognizer. You need to set the MLAsrListener listener through setAsrListener and then call startRecognizing (Intent intent) to start recognition.

Constant Summary

TypeNameDesc
StringRESULTS_RECOGNIZEDKey value corresponding to text information in a speech recognition result.In onResults(), you can obtain the text recognized by the speech recognizer from Bundle based on the key value.
StringRESULTS_RECOGNIZINGKey value corresponding to text information during speech recognition.In onRecognizingResults(), you can obtain the text recognized by the speech recognizer from Bundle based on the key value.

Public Method Summary

Return typeMethod name
MLAsrRecognizercreateMLAsrRecognizer(Context context)
voiddestroy()
voidsetAsrListener(MLAsrListener listener)
voidstartRecognizing(Intent recognizerIntent)

Constants

Constant
public static final String RESULTS_RECOGNIZED
In onResults(), you can obtain the text recognized by the speech recognizer from Bundle based on the key value.
Constant value: results_recognized
Constant
public static final String RESULTS_RECOGNIZING
In onRecognizingResults(), you can obtain the text recognized by the speech recognizer from Bundle based on the key value.
Constant value: results_recognizing

Public Methods

Method
public static MLAsrRecognizer createAsrRecognizer(Context context)
Create an instance of MLAsrRecognizer.

Parameters

Parameter nameParameter desc
contextContext.


Return

Typedesc
MLAsrRecognizerAn instance of MLAsrRecognizer.
Method
public void destroy()
Destroys an instance of MLAsrRecognizer.
Method
public void setAsrListener(MLAsrListener listener)
Sets the listener callback function of the recognizer to receive the recognition result and result code.

Parameters

Parameter nameParameter desc
listenerListener used to receive results from the recognizer.
Method
public void startRecognizing(Intent recognizerIntent)
Starts recognition. The result can be received only after setAsrListener(MLAsrListener listener) is set.

Parameters

Parameter nameParameter desc
recognizerIntent

It includes parameters used for recognition.

Currently, the following parameters are carried:

Key=FEATURE: recognition mode. The input parameter is of the int type.

Key=LANGUAGE: language type. The input parameter is of the String type.