| class info |
| com.huawei.hms.mlsdk.asr.MLAsrListener |
| Receives data and event notifications from MLAsrRecognizer when an ASR event occurs. |
| Return type | Method name |
| void | onError(int error, String errorMessage) |
| void | onRecognizingResults(Bundle recognizingResults) |
| void | onResults(Bundle results) |
| void | onStartListening() |
| void | onStartingOfSpeech() |
| void | onState(int state, Bundle params) |
| void | onVoiceDataReceived(byte[] data,float energy, Bundle params) |
| Method |
| public void onError(int error, String errorMessage) |
| Called when a network error or recognition error occurs. |
Parameters
| Parameter name | Parameter desc |
| error | Result code. For details about the result codes, please refer to MLAsrConstants.ERR_NO_NETWORKERR_NO_UNDERSTANDERR_SERVICE_UNAVAILABLE |
| errorMessage | Error message. |
| Method |
| public void onRecognizingResults(Bundle recognizingResults) |
| When the speech recognition mode is set to MLAsrConstants.FEATURE_WORDFLUX, the speech recognizer continuously returns the speech recognition result through this API. |
Parameters
| Parameter name | Parameter desc |
| recognizingResults | Result returned during speech recognition.Currently, Bundle carries the recognized text information, which is stored in the value with MLAsrRecognizer.RESULTS_RECOGNIZING as the key in the string type. |
| Method |
| public void onResults(Bundle results) |
| Called when the speech recognition result is received from the speech recognizer. |
Parameters
| Parameter name | Parameter desc |
| results | Speech recognition result.Currently, Bundle carries the recognized text information, which is stored in the value with MLAsrRecognizer.RESULTS_RECOGNIZED as the key in the string type. |
| Method |
| public void onStartListening() |
| Called when the recorder starts to receive speech. |
| Method |
| public void onStartingOfSpeech() |
| Called when a user starts to speak, that is, the speech recognizer detects that the user starts to speak. |
| Method |
| public void onState(int state, Bundle params) |
| Notifies the app status change. |
Parameters
| Parameter name | Parameter desc |
| state | Status code. For details, please refer to MLAsrConstants. |
| params | Reserved fields. |
| Method |
| public void onVoiceDataReceived(byte[] data,float energy, Bundle params) |
| Returns the original PCM stream and audio power to the user. |
Parameters
| Parameter name | Parameter desc |
| data | PCM stream, with PCM mono, 16-bit depth, and 16 kHz audio sampling rate. |
| energy | Audio power. |
| params | Reserved fields. |