| class info |
| com.huawei.hms.mlsdk.asr.MLAsrListener |
| 当识别发生后,使用该接口从MLAsrRecognizer接收数据和事件通知。 |
| 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) |
| 网络错误或者识别错误后会调用该接口。 |
Parameters
| Parameter name | Parameter desc |
| error | 错误码,见 MLAsrConstants中错误码。
|
| errorMessage | 错误消息。 |
| Method |
| public void onRecognizingResults(Bundle recognizingResults) |
| 当用户配置语音识别模式为MLAsrConstants.FEATURE_WORDFLUX时,语音识别器会通过该接口持续返回语音识别过程中的结果。 |
Parameters
| Parameter name | Parameter desc |
| recognizingResults | 语音识别过程中返回的结果。目前Bundle中携带了识别后的文本信息,文本信息以String类型保存在以MLAsrRecognizer.RESULTS_RECOGNIZING为key的value中。 |
| Method |
| public void onResults(Bundle results) |
| 从语音识别器接收到最终的语音识别结果。 |
Parameters
| Parameter name | Parameter desc |
| results | 语音识别返回的结果。目前Bundle中携带了识别后的文本信息,文本信息以String类型保存在以MLAsrRecognizer.RESULTS_RECOGNIZED为key的value中。 |
| Method |
| public void onStartListening() |
| 录音器开始接收声音。 |
| Method |
| public void onStartingOfSpeech() |
| 用户开始讲话,即语音识别器检测到用户开始讲话。 |
| Method |
| public void onState(int state, Bundle params) |
| 通知应用状态发生改变。 |
Parameters
| Parameter name | Parameter desc |
| state | 状态码见MLAsrConstants。 |
| params | 保留字段。 |
| Method |
| public void onVoiceDataReceived(byte[] data,float energy, Bundle params) |
| 返回给用户原始的PCM音频流和音频能量。 |
Parameters
| Parameter name | Parameter desc |
| data | pcm音频流,pcm音频采集格式为16000Hz采样率,16bit位深,单声道。 |
| energy | 音频流的能量值。 |
| params | 保留字段。 |