13

I have an Android app that is used to play audio via the phone's speaker continuously, including when other apps are in the foreground, or the screen is off.

There is however a problem with that app in that the audio it plays can trigger the "OK Google" hotword detection, which leads to a bit of an endless loop, since the app also rewinds a few seconds upon being paused.

Thus there is no choice for the user but to disable the hotword detection entirely and permanently. That is not optimal.

Is there an API call that the app can use to disable the hotword detection temporarily while it is playing audio?

Mithaldu
  • 2,393
  • 19
  • 39
  • 3
    Hmm ... Isn't that a problem all apps with audio playback should have? Have you tried other apps? I suggest an experiment: Record yourself saying 'ok google' a couple of times and play that recording back with common apps of your choice (in background). If the hotword is not triggered, there is a good chance that a solution to your problem exists. – forgemo Aug 05 '15 at 22:15

3 Answers3

8

Hotword detection disabled with accessibly service :

To prevent false positives, hotword detection is disabled when a spoken feedback service is enabled.

You have defined your service as providing all possible types of feedback, which includes spoken.

Community
  • 1
  • 1
Tharif
  • 13,794
  • 9
  • 55
  • 77
5

A dirty trick could be to keep the microphone busy while playing your audio stream.

You can lock the microphone using an AudioRecord (or a MediaRecorder) and then release it when you are done.

bonnyz
  • 13,458
  • 5
  • 46
  • 70
0

Please take a look at the android:accessibilityFeedbackType. http://developer.android.com/reference/android/accessibilityservice/AccessibilityServiceInfo.html#attr_android:accessibilityFeedbackType

I believe that by changing option of the feedbackSpoken will give you what you want. Haven't really used this feature, but its worth exploring.. You can try even android:accessibilityFeedbackType="feedbackAllMask" All the best and good luck

  • I don't understand how that is supposed to help disable hotword detection? This seems to be about setting how an accessibility service delivers feedback from the device to the user, not what the device does with spoken input from the user. – Mithaldu Jul 30 '15 at 15:21
  • 3
    @Mithaldu I think the answer might refer to this one: http://stackoverflow.com/a/23308303/1306419 . It mentions that `To prevent false positives, hotword detection is disabled when a spoken feedback service is enabled. ` – Shobhit Puri Aug 05 '15 at 22:11