public interface RecognitionListener
| android.speech.RecognitionListener |
用于在识别相关事件发生时接收来自SpeechRecognizer的通知。 所有回调都在应用程序主线程上执行。
公共方法(Public methods) |
|
|---|---|
abstract void |
onBeginningOfSpeech() 用户已经开始说话。 |
abstract void |
onBufferReceived(byte[] buffer) 已收到更多声音。 |
abstract void |
onEndOfSpeech() 在用户停止说话之后调用。 |
abstract void |
onError(int error) 发生网络或识别错误。 |
abstract void |
onEvent(int eventType, Bundle params) 预留用于添加未来事件。 |
abstract void |
onPartialResults(Bundle partialResults) 部分识别结果可用时调用。 |
abstract void |
onReadyForSpeech(Bundle params) 当终端准备好让用户开始说话时调用。 |
abstract void |
onResults(Bundle results) 识别结果准备就绪时调用。 |
abstract void |
onRmsChanged(float rmsdB) 音频流中的声级已更改。 |
void onBufferReceived (byte[] buffer)
已收到更多声音。 此功能的目的是允许向用户提供有关捕获音频的反馈。 不能保证这个方法会被调用。
| 参数(Parameters) | |
|---|---|
buffer |
byte: a buffer containing a sequence of big-endian 16-bit integers representing a single channel audio stream. The sample rate is implementation dependent. |
void onError (int error)
发生网络或识别错误。
| 参数(Parameters) | |
|---|---|
error |
int: code is defined in SpeechRecognizer |
void onEvent (int eventType,
Bundle params)
预留用于添加未来事件。
| 参数(Parameters) | |
|---|---|
eventType |
int: the type of the occurred event |
params |
Bundle: a Bundle containing the passed parameters |
void onPartialResults (Bundle partialResults)
部分识别结果可用时调用。 当部分结果准备就绪时,可以在onBeginningOfSpeech()和onResults(Bundle)之间onBeginningOfSpeech()调用回调。 根据语音识别服务的实施情况,每次调用startListening(Intent) ,此方法可能被称为零,一次或多次。 要请求部分结果,请使用EXTRA_PARTIAL_RESULTS
| 参数(Parameters) | |
|---|---|
partialResults |
Bundle: the returned results. To retrieve the results in ArrayList<String> format use getStringArrayList(String) with RESULTS_RECOGNITION as a parameter |
void onReadyForSpeech (Bundle params)
当终端准备好让用户开始说话时调用。
| 参数(Parameters) | |
|---|---|
params |
Bundle: parameters set by the recognition service. Reserved for future use. |
void onResults (Bundle results)
识别结果准备就绪时调用。
| 参数(Parameters) | |
|---|---|
results |
Bundle: the recognition results. To retrieve the results in ArrayList<String> format use getStringArrayList(String) with RESULTS_RECOGNITION as a parameter. A float array of confidence values might also be given in CONFIDENCE_SCORES. |
void onRmsChanged (float rmsdB)
音频流中的声级已更改。 不能保证这个方法会被调用。
| 参数(Parameters) | |
|---|---|
rmsdB |
float: the new RMS dB value |