Most visited

Recently visited

Added in API level 21

AlwaysOnHotwordDetector

public class AlwaysOnHotwordDetector
extends Object

java.lang.Object
   ↳ android.service.voice.AlwaysOnHotwordDetector


一个让VoiceInteractionService实现与永远在线的关键词检测API交互的类。

Summary

Nested classes

class AlwaysOnHotwordDetector.Callback

始终打开热门词检测的回调。

class AlwaysOnHotwordDetector.EventPayload

额外的有效载荷为onDetected(AlwaysOnHotwordDetector.EventPayload)

Constants

int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS

startRecognition(int)识别标志,指示识别是否应该在关键词触发后继续进行。

int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO

startRecognition(int)识别标志,指示是否需要捕获热门词的触发音频。

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

Constants

RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS

Added in API level 21
int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS

startRecognition(int)识别标志,指示即使在关键词语触发后,识别是否应继续进行。 如果指定了此标志,那么如果用户多次说出关键短语,可以在呼叫startRecognition(int)后获得多个触发器。 如果没有指定,默认行为是一旦说出关键字就停止识别,直到主叫方再次开始识别。

常量值:2(0x00000002)

RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO

Added in API level 21
int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO

startRecognition(int)识别标志,指示是否需要捕获热门词的触发音频。

常数值:1(0x00000001)

RECOGNITION_MODE_USER_IDENTIFICATION

Added in API level 21
int RECOGNITION_MODE_USER_IDENTIFICATION

使用关键词识别进行用户识别。 getSupportedRecognitionModes()返回

常量值:2(0x00000002)

RECOGNITION_MODE_VOICE_TRIGGER

Added in API level 21
int RECOGNITION_MODE_VOICE_TRIGGER

对关键短语的简单识别。 getSupportedRecognitionModes()返回

常数值:1(0x00000001)

STATE_HARDWARE_UNAVAILABLE

Added in API level 21
int STATE_HARDWARE_UNAVAILABLE

由于硬件配置,表示对于给定的密钥短语的识别在系统上不可用。 对于返回此可用性的检测器不应执行进一步的交互。

常量值:-2(0xfffffffe)

STATE_KEYPHRASE_ENROLLED

Added in API level 21
int STATE_KEYPHRASE_ENROLLED

表示给定的关键词是当前注册的,并且可以开始识别它。

常量值:2(0x00000002)

STATE_KEYPHRASE_UNENROLLED

Added in API level 21
int STATE_KEYPHRASE_UNENROLLED

表示给定的关键短语未注册。 主叫方可以选择开始关键字的注册流程。

常数值:1(0x00000001)

STATE_KEYPHRASE_UNSUPPORTED

Added in API level 21
int STATE_KEYPHRASE_UNSUPPORTED

表示不支持给定关键词的识别。 对于返回此可用性的检测器不应执行进一步的交互。

常量值:-1(0xffffffff)

Public methods

createEnrollIntent

Added in API level 21
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.

createReEnrollIntent

Added in API level 21
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.

createUnEnrollIntent

Added in API level 21
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.

getSupportedRecognitionModes

Added in API level 21
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.

也可以看看:

startRecognition

Added in API level 21
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.

也可以看看:

stopRecognition

Added in API level 21
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.

Hooray!