public class RecognitionService.Callback
extends Object
| java.lang.Object | |
| android.speech.RecognitionService.Callback | |
此课程接收来自语音识别服务的回传并将其转发给用户。 这个类的一个实例被传递给onStartListening(Intent, Callback)方法。 识别器可以在任何线程上调用这些方法。
公共方法(Public methods) |
|
|---|---|
void |
beginningOfSpeech() 当用户开始说话时,服务应该调用这个方法。 |
void |
bufferReceived(byte[] buffer) 收到声音时,服务应调用此方法。 |
void |
endOfSpeech() 用户停止说话后,该服务应该调用此方法。 |
void |
error(int error) 当发生网络或识别错误时,该服务应该调用此方法。 |
int |
getCallingUid() 返回分配给向您发送当前正在处理的事务的进程的Linux uid。 |
void |
partialResults(Bundle partialResults) 部分识别结果可用时,该服务应调用此方法。 |
void |
readyForSpeech(Bundle params) 当endpointer准备好让用户开始说话时,服务应该调用这个方法。 |
void |
results(Bundle results) 当识别结果准备就绪时,服务应调用此方法。 |
void |
rmsChanged(float rmsdB) 当音频流中的声音级别发生变化时,该服务应调用此方法。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
void beginningOfSpeech ()
当用户开始说话时,服务应该调用这个方法。
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void bufferReceived (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. |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void endOfSpeech ()
用户停止说话后,该服务应该调用此方法。
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void error (int error)
当发生网络或识别错误时,该服务应该调用此方法。
| 参数(Parameters) | |
|---|---|
error |
int: code is defined in SpeechRecognizer |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
int getCallingUid ()
返回分配给向您发送当前正在处理的事务的进程的Linux uid。 这是从getCallingUid()获得的。
| 返回(Returns) | |
|---|---|
int |
|
void partialResults (Bundle partialResults)
部分识别结果可用时,该服务应调用此方法。 当部分结果准备就绪时,可以在beginningOfSpeech()和results(Bundle)之间beginningOfSpeech()调用此方法。 根据语音识别服务的实现情况,每次调用startListening(Intent) ,此方法可能被称为零,一次或多次。
| 参数(Parameters) | |
|---|---|
partialResults |
Bundle: the returned results. To retrieve the results in ArrayList<String> format use getStringArrayList(String) with RESULTS_RECOGNITION as a parameter |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void readyForSpeech (Bundle params)
当endpointer准备好让用户开始说话时,服务应该调用这个方法。
| 参数(Parameters) | |
|---|---|
params |
Bundle: parameters set by the recognition service. Reserved for future use. |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void results (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 |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|
void rmsChanged (float rmsdB)
当音频流中的声音级别发生变化时,该服务应调用此方法。 不能保证这个方法会被调用。
| 参数(Parameters) | |
|---|---|
rmsdB |
float: the new RMS dB value |
| 抛出异常(Throws) | |
|---|---|
RemoteException |
|