| 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. |
| Type | Name | Desc |
| String | RESULTS_RECOGNIZED | Key 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. |
| String | RESULTS_RECOGNIZING | Key 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. |
| Return type | Method name |
| MLAsrRecognizer | createMLAsrRecognizer(Context context) |
| void | destroy() |
| void | setAsrListener(MLAsrListener listener) |
| void | startRecognizing(Intent recognizerIntent) |
| 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 |
| Method |
| public static MLAsrRecognizer createAsrRecognizer(Context context) |
| Create an instance of MLAsrRecognizer. |
Parameters
| Parameter name | Parameter desc |
| context | Context. |
Return
| Type | desc |
| MLAsrRecognizer | An 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 name | Parameter desc |
| listener | Listener 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 name | Parameter 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. |