public class AlwaysOnHotwordDetector
extends Object
java.lang.Object | |
↳ | android.service.voice.AlwaysOnHotwordDetector |
一个让VoiceInteractionService实现与永远在线的关键词检测API交互的类。
Nested classes |
|
---|---|
class |
AlwaysOnHotwordDetector.Callback 始终打开热门词检测的回调。 |
class |
AlwaysOnHotwordDetector.EventPayload |
Constants |
|
---|---|
int |
RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS
|
int |
RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO
|
int |
RECOGNITION_MODE_USER_IDENTIFICATION 使用关键词识别进行用户识别。 |
int |
RECOGNITION_MODE_VOICE_TRIGGER 对关键短语的简单识别。 |
int |
STATE_HARDWARE_UNAVAILABLE 由于硬件配置,表示对于给定的密钥短语的识别在系统上不可用。 |
int |
STATE_KEYPHRASE_ENROLLED 表示给定的关键词是当前注册的,并且可以开始识别它。 |
int |
STATE_KEYPHRASE_UNENROLLED 表示给定的关键短语未注册。 |
int |
STATE_KEYPHRASE_UNSUPPORTED 表示不支持给定关键词的识别。 |
Public methods |
|
---|---|
Intent |
createEnrollIntent() 创建一个意图开始注册关联的关键字。 |
Intent |
createReEnrollIntent() 创建一个意图开始重新注册关联的关键字。 |
Intent |
createUnEnrollIntent() 创建一个旨在开始关联关键短语的取消注册的意图。 |
int |
getSupportedRecognitionModes() 获取关联的关键字所支持的识别模式。 |
boolean |
startRecognition(int recognitionFlags) 开始识别关联的关键字。 |
boolean |
stopRecognition() 停止识别相关的关键字。 |
Inherited methods |
|
---|---|
From class java.lang.Object
|
int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS
startRecognition(int)
识别标志,指示即使在关键词语触发后,识别是否应继续进行。 如果指定了此标志,那么如果用户多次说出关键短语,可以在呼叫startRecognition(int)
后获得多个触发器。 如果没有指定,默认行为是一旦说出关键字就停止识别,直到主叫方再次开始识别。
常量值:2(0x00000002)
int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO
startRecognition(int)
识别标志,指示是否需要捕获热门词的触发音频。
常数值:1(0x00000001)
int RECOGNITION_MODE_USER_IDENTIFICATION
使用关键词识别进行用户识别。 由getSupportedRecognitionModes()
返回
常量值:2(0x00000002)
int RECOGNITION_MODE_VOICE_TRIGGER
对关键短语的简单识别。 由getSupportedRecognitionModes()
返回
常数值:1(0x00000001)
int STATE_HARDWARE_UNAVAILABLE
由于硬件配置,表示对于给定的密钥短语的识别在系统上不可用。 对于返回此可用性的检测器不应执行进一步的交互。
常量值:-2(0xfffffffe)
int STATE_KEYPHRASE_ENROLLED
表示给定的关键词是当前注册的,并且可以开始识别它。
常量值:2(0x00000002)
int STATE_KEYPHRASE_UNENROLLED
表示给定的关键短语未注册。 主叫方可以选择开始关键字的注册流程。
常数值:1(0x00000001)
int STATE_KEYPHRASE_UNSUPPORTED
表示不支持给定关键词的识别。 对于返回此可用性的检测器不应执行进一步的交互。
常量值:-1(0xffffffff)
Intent createEnrollIntent ()
创建一个意图开始注册关联的关键字。 这个意图必须使用startActivityForResult(Intent, int)
来调用。 开始重新注册仅在关键短语未注册时有效,即STATE_KEYPHRASE_UNENROLLED
,否则应优先使用createReEnrollIntent()
。
Returns | |
---|---|
Intent |
An Intent to start enrollment for the given keyphrase. |
Throws | |
---|---|
UnsupportedOperationException |
if managing they keyphrase isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |
Intent createReEnrollIntent ()
创建一个意图开始重新注册关联的关键字。 这个意图必须使用startActivityForResult(Intent, int)
来调用。 开始重新注册只有在关键字已被注册时才有效, STATE_KEYPHRASE_ENROLLED
,否则调用此操作可能会导致错误。
Returns | |
---|---|
Intent |
An Intent to start re-enrollment for the given keyphrase. |
Throws | |
---|---|
UnsupportedOperationException |
if managing they keyphrase isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |
Intent createUnEnrollIntent ()
创建一个旨在开始关联关键短语的取消注册的意图。 这个意图必须使用startActivityForResult(Intent, int)
来调用。 开始重新注册只有在关键字已被注册时才有效, STATE_KEYPHRASE_ENROLLED
,否则调用此操作可能会导致错误。
Returns | |
---|---|
Intent |
An Intent to start un-enrollment for the given keyphrase. |
Throws | |
---|---|
UnsupportedOperationException |
if managing they keyphrase isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |
int getSupportedRecognitionModes ()
获取关联的关键字所支持的识别模式。
Returns | |
---|---|
int |
Throws | |
---|---|
UnsupportedOperationException |
if the keyphrase itself isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |
boolean startRecognition (int recognitionFlags)
开始识别关联的关键字。
Parameters | |
---|---|
recognitionFlags |
int : The flags to control the recognition properties. |
Returns | |
---|---|
boolean |
Indicates whether the call succeeded or not. |
Throws | |
---|---|
UnsupportedOperationException |
if the recognition isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |
boolean stopRecognition ()
停止识别相关的关键字。
Returns | |
---|---|
boolean |
Indicates whether the call succeeded or not. |
Throws | |
---|---|
UnsupportedOperationException |
if the recognition isn't supported. Callers should only call this method after a supported state callback on onAvailabilityChanged(int) to avoid this exception. |
IllegalStateException |
if the detector is in an invalid state. This may happen if another detector has been instantiated or the VoiceInteractionService hosting this detector has been shut down. |