Search in sources :

Example 1 with ConfidenceLevel

use of android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) KeyphraseRecognitionEvent(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent) Parcel(android.os.Parcel) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 2 with ConfidenceLevel

use of android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel in project android_frameworks_base by DirtyUnicorns.

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;
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) RemoteException(android.os.RemoteException)

Example 3 with ConfidenceLevel

use of android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel in project android_frameworks_base by AOSPA.

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;
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) RemoteException(android.os.RemoteException)

Example 4 with ConfidenceLevel

use of android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel in project android_frameworks_base by ResurrectionRemix.

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;
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) RemoteException(android.os.RemoteException)

Example 5 with ConfidenceLevel

use of android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel in project android_frameworks_base by crdroidandroid.

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;
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) RemoteException(android.os.RemoteException)

Aggregations

ConfidenceLevel (android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel)9 KeyphraseRecognitionExtra (android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra)9 RecognitionConfig (android.hardware.soundtrigger.SoundTrigger.RecognitionConfig)5 RemoteException (android.os.RemoteException)5 KeyphraseRecognitionEvent (android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent)4 Parcel (android.os.Parcel)4 LargeTest (android.test.suitebuilder.annotation.LargeTest)4