public interface AsrListener
The caller determines how to implement this interface when using AsrClient#init(AsrIntent, AsrListener) to
initialize the ASR engine.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onAudioEnd() |
Called when the audio ends.
|
void |
onAudioStart() |
Called when the audio starts.
|
void |
onBeginningOfSpeech() |
Called when the ASR engine detects that a user starts to speak.
|
void |
onBufferReceived(byte[] buffer) |
Called when the ASR engine receives a new audio stream.
|
void |
onEnd() |
Called when the ASR ends.
|
void |
onEndOfSpeech() |
Called when the ASR engine detects that the user stops speaking.
|
void |
onError(int error) |
Called when an error occurs during ASR.
|
void |
onEvent(int eventType,
PacMap params) |
Called when the ASR engine detects certain events to report them to the caller.
|
void |
onInit(PacMap params) |
Called when the ASR engine is initialized.
|
void |
onIntermediateResults(PacMap intermediateResults) |
Called when the ASR engine delivers intermediate speech recognition results.
|
void |
onResults(PacMap results) |
Called when the ASR engine delivers the finally parsed speech recognition results.
|
void |
onRmsChanged(float rms) |
Called when the ASR engine detects any changes to the root mean square (RMS) energy of the input audio.
|
void onInit(PacMap params)
After the ASR engine is initialized by using AsrClient#init(AsrIntent, AsrListener), the ASR engine
server invokes this callback to process the initialization result data. The caller determines how to implement
this callback.
params - Indicates the initialization result data represented by a key-value pair. The key is the string
"error_code", and the value is a result code defined in AsrError.void onBeginningOfSpeech()
void onRmsChanged(float rms)
The ASR server invokes this callback to process the RMS energy.
rms - Indicates the RMS energy. The value is proportional to the RMS energy.void onBufferReceived(byte[] buffer)
This callback is invoked to process the received audio stream. Based on the callback result, the caller can observe whether the ASR server has received any audio input.
buffer - Indicates the audio stream received by the ASR server.void onEndOfSpeech()
void onError(int error)
error - Indicates the ASR error code.AsrErrorvoid onResults(PacMap results)
results - Indicates the ASR results represented by key-value pairs. For the possible keywords in the
results, see AsrResultKey.void onIntermediateResults(PacMap intermediateResults)
This callback may be invoked at any time between invocations of onBeginningOfSpeech() and
onResults(ohos.utils.PacMap).
intermediateResults - Indicates the intermediate ASR results represented by key-value pairs. For the
possible keywords in the results, see AsrResultKey.void onEnd()
If speech recognition is interrupted due to invocation of AsrClient#stopListening() or
AsrClient#cancel(), this callback will not be invoked.
void onEvent(int eventType,
PacMap params)
This callback is used for monitoring scenarios not specified by particular callbacks.
eventType - Indicates the event type, as defined in AsrEvent.params - Indicates event-specific results represented by key-value pairs, which vary according to event
types.void onAudioStart()
void onAudioEnd()