use of android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra in project platform_frameworks_base by android.
the class AlwaysOnHotwordDetector method startRecognitionLocked.
private int startRecognitionLocked(int recognitionFlags) {
KeyphraseRecognitionExtra[] recognitionExtra = new KeyphraseRecognitionExtra[1];
// TODO: Do we need to do something about the confidence level here?
recognitionExtra[0] = new KeyphraseRecognitionExtra(mKeyphraseMetadata.id, mKeyphraseMetadata.recognitionModeFlags, 0, new ConfidenceLevel[0]);
boolean captureTriggerAudio = (recognitionFlags & RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO) != 0;
boolean allowMultipleTriggers = (recognitionFlags & RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS) != 0;
int code = STATUS_ERROR;
try {
code = mModelManagementService.startRecognition(mVoiceInteractionService, mKeyphraseMetadata.id, mLocale.toLanguageTag(), mInternalCallback, new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, recognitionExtra, null));
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException in startRecognition!", e);
}
if (code != STATUS_OK) {
Slog.w(TAG, "startRecognition() failed with error code " + code);
}
return code;
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra in project android_frameworks_base by ResurrectionRemix.
the class SoundTriggerTest method testKeyphraseRecognitionEventParcelUnparcel_largeData.
@LargeTest
public void testKeyphraseRecognitionEventParcelUnparcel_largeData() throws Exception {
byte[] data = new byte[200 * 1024];
mRandom.nextBytes(data);
KeyphraseRecognitionExtra[] kpExtra = new KeyphraseRecognitionExtra[4];
ConfidenceLevel cl1 = new ConfidenceLevel(1, 90);
ConfidenceLevel cl2 = new ConfidenceLevel(2, 30);
kpExtra[0] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_USER_IDENTIFICATION, 0, new ConfidenceLevel[] { cl1, cl2 });
kpExtra[1] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[] { cl2 });
kpExtra[2] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, null);
kpExtra[3] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[0]);
KeyphraseRecognitionEvent re = new KeyphraseRecognitionEvent(SoundTrigger.RECOGNITION_STATUS_FAILURE, 1, true, 2, 3, 4, false, null, data, kpExtra);
// Write to a parcel
Parcel parcel = Parcel.obtain();
re.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseRecognitionEvent unparceled = KeyphraseRecognitionEvent.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(re, unparceled);
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra in project android_frameworks_base by crdroidandroid.
the class SoundTriggerTest method testKeyphraseRecognitionEventParcelUnparcel_largeData.
@LargeTest
public void testKeyphraseRecognitionEventParcelUnparcel_largeData() throws Exception {
byte[] data = new byte[200 * 1024];
mRandom.nextBytes(data);
KeyphraseRecognitionExtra[] kpExtra = new KeyphraseRecognitionExtra[4];
ConfidenceLevel cl1 = new ConfidenceLevel(1, 90);
ConfidenceLevel cl2 = new ConfidenceLevel(2, 30);
kpExtra[0] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_USER_IDENTIFICATION, 0, new ConfidenceLevel[] { cl1, cl2 });
kpExtra[1] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[] { cl2 });
kpExtra[2] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, null);
kpExtra[3] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[0]);
KeyphraseRecognitionEvent re = new KeyphraseRecognitionEvent(SoundTrigger.RECOGNITION_STATUS_FAILURE, 1, true, 2, 3, 4, false, null, data, kpExtra);
// Write to a parcel
Parcel parcel = Parcel.obtain();
re.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseRecognitionEvent unparceled = KeyphraseRecognitionEvent.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(re, unparceled);
}
Aggregations