public
class
AlwaysOnHotwordDetector
extends Object
java.lang.Object | |
↳ | android.service.voice.AlwaysOnHotwordDetector |
A class that lets a VoiceInteractionService implementation interact with always-on keyphrase detection APIs.
Nested classes | |
---|---|
class |
AlwaysOnHotwordDetector.Callback
Callbacks for always-on hotword detection. |
class |
AlwaysOnHotwordDetector.EventPayload
Additional payload for |
Constants | |
---|---|
int |
RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS
Recognition flag for |
int |
RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO
Recognition flag for |
int |
RECOGNITION_MODE_USER_IDENTIFICATION
User identification performed with the keyphrase recognition. |
int |
RECOGNITION_MODE_VOICE_TRIGGER
Simple recognition of the key phrase. |
int |
STATE_HARDWARE_UNAVAILABLE
Indicates that recognition for the given keyphrase is not available on the system because of the hardware configuration. |
int |
STATE_KEYPHRASE_ENROLLED
Indicates that the given keyphrase is currently enrolled and it's possible to start recognition for it. |
int |
STATE_KEYPHRASE_UNENROLLED
Indicates that the given keyphrase is not enrolled. |
int |
STATE_KEYPHRASE_UNSUPPORTED
Indicates that recognition for the given keyphrase is not supported. |
Public methods | |
---|---|
Intent
|
createEnrollIntent()
Creates an intent to start the enrollment for the associated keyphrase. |
Intent
|
createReEnrollIntent()
Creates an intent to start the re-enrollment for the associated keyphrase. |
Intent
|
createUnEnrollIntent()
Creates an intent to start the un-enrollment for the associated keyphrase. |
int
|
getSupportedRecognitionModes()
Gets the recognition modes supported by the associated keyphrase. |
boolean
|
startRecognition(int recognitionFlags)
Starts recognition for the associated keyphrase. |
boolean
|
stopRecognition()
Stops recognition for the associated keyphrase. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS
Recognition flag for startRecognition(int)
that indicates
whether the recognition should keep going on even after the keyphrase triggers.
If this flag is specified, it's possible to get multiple triggers after a
call to startRecognition(int)
if the user speaks the keyphrase multiple times.
When this isn't specified, the default behavior is to stop recognition once the
keyphrase is spoken, till the caller starts recognition again.
Constant Value: 2 (0x00000002)
int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO
Recognition flag for startRecognition(int)
that indicates
whether the trigger audio for hotword needs to be captured.
Constant Value: 1 (0x00000001)
int RECOGNITION_MODE_USER_IDENTIFICATION
User identification performed with the keyphrase recognition.
Returned by getSupportedRecognitionModes()
Constant Value: 2 (0x00000002)
int RECOGNITION_MODE_VOICE_TRIGGER
Simple recognition of the key phrase.
Returned by getSupportedRecognitionModes()
Constant Value: 1 (0x00000001)
int STATE_HARDWARE_UNAVAILABLE
Indicates that recognition for the given keyphrase is not available on the system because of the hardware configuration. No further interaction should be performed with the detector that returns this availability.
Constant Value: -2 (0xfffffffe)
int STATE_KEYPHRASE_ENROLLED
Indicates that the given keyphrase is currently enrolled and it's possible to start recognition for it.
Constant Value: 2 (0x00000002)
int STATE_KEYPHRASE_UNENROLLED
Indicates that the given keyphrase is not enrolled. The caller may choose to begin an enrollment flow for the keyphrase.
Constant Value: 1 (0x00000001)
int STATE_KEYPHRASE_UNSUPPORTED
Indicates that recognition for the given keyphrase is not supported. No further interaction should be performed with the detector that returns this availability.
Constant Value: -1 (0xffffffff)
Intent createEnrollIntent ()
Creates an intent to start the enrollment for the associated keyphrase.
This intent must be invoked using startActivityForResult(Intent, int)
.
Starting re-enrollment is only valid if the keyphrase is un-enrolled,
i.e. STATE_KEYPHRASE_UNENROLLED
,
otherwise createReEnrollIntent()
should be preferred.
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 ()
Creates an intent to start the re-enrollment for the associated keyphrase.
This intent must be invoked using startActivityForResult(Intent, int)
.
Starting re-enrollment is only valid if the keyphrase is already enrolled,
i.e. STATE_KEYPHRASE_ENROLLED
, otherwise invoking this may result in an error.
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 ()
Creates an intent to start the un-enrollment for the associated keyphrase.
This intent must be invoked using startActivityForResult(Intent, int)
.
Starting re-enrollment is only valid if the keyphrase is already enrolled,
i.e. STATE_KEYPHRASE_ENROLLED
, otherwise invoking this may result in an error.
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 ()
Gets the recognition modes supported by the associated keyphrase.
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)
Starts recognition for the associated keyphrase.
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 ()
Stops recognition for the associated keyphrase.
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.
|