Last week, I showed you how to force OK Google hotword detection to work on any device when its screen was off.
While it can certainly be useful in some cases, it requires users to have root access to enable and is also somewhat battery hungry because it prevents your device from entering a deep sleep state. Thus, it would be preferable if the device featured hardware support for offline hotword recognition.
When I first received the Huawei Mate 9, I was surprised to see that "OK Google" always on wasn't available. Given that the Mate 9 is a premium flagship device packed with a ton of sensors, it seemed odd that Huawei would not feature a dedicated co-processor to handle voice recognition. However, it appears that I was initially wrong. The Huawei Mate 9 (and later I learned that many flagship Huawei/Honor devices) does support offline hotword voice recognition – but only for its own proprietary voice service.
Tucked away in Settings –> Smart assistance –> Voice control is a menu for "Voice wakeup" which allows you to setup the a hotword to wake the device and launch some basic commands. You can ask the service, called "Emy", to find your phone or call a certain contact but other than that it's fairly disappointing when compared to Google's voice commands.
But the upside is that Huawei's voice assistant can be summoned even when the screen is off (and it even supports custom hotwords to boot), which is the functionality we were missing from the Google App on Huawei devices. Hence, I've come up with a way to take advantage of Huawei's "OK Emy" to instead launch Google's voice search so we can, in a roundabout way, achieve "OK Google" when the screen is off.
Say Goodbye to Emy and Hello to Google
As you can see in the video, I summon "OK Emy" which briefly flashes Huawei's proprietary voice interaction service before opening up Google's voice search. This works when the screen is off, too, though I can't show that using a screen recording.
In order to set this up, all you will need is the automation app Tasker. Install Tasker (or any other automation app of your choice, but this tutorial is built for Tasker as that is the only app I have experience with) and enable its Accessibility Service. Tasker needs an Accessibility Service so it can monitor changes in the window state, which is what we will use to detect when Emy has been activated.
If you have experience with Tasker, you can expand the below toggle to view the profile's description and quickly replicate this profile yourself. If you are unfamiliar with Tasker, continue reading for step-by-step instructions.
Profile Description
Profile: Mate 9 OK Google (182) Event: Variable Set [ Variable:%WIN Value:sound trigger User Variables Only:Off ] Enter: Anon (191) A1: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] A2: Launch App [ App:Google:Voice Search Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]
The first thing you will want to do is create a new profile in Tasker. In the main screen, press the + icon in the bottom right corner. Tap the Event context and choose Variables –> Variable Set. For the Variable, enter %WIN and for the Value enter "sound trigger" (without parenthesis). "Sound trigger" is the name of the window that pops up when Emy is activated, so this profile will be fired when the Window label (%WIN) is populated with that text.
Next, you will create the Task associated with this Profile. Tasker will ask you to create a new Task and to name it, but naming it is not important so just press the checkmark to enter the Task editing screen. At the bottom press + and go to Task –> Wait and set it to wait for 1 second. This is to prevent a bug from Google voice search where it times out if it is called immediately after Emy. Once you add that Action, press + again and this time go to App –> Launch App. Scroll down until you see the Google app. Long-press on 'Google' to bring up its list of available activities and scroll down to select VoiceSearchActivity.
That's it! Tasker should now start monitoring changes in the Window state and will activate this profile whenever the Window label matches "sound trigger" in which case it will wait 1 second before launching Google's voice search activity.
To make this feature seem even more seamless, you can change Emy's hotword to "OK Google" so it will be as if Huawei's Emy is totally uninvolved. We're just using it because it's the only service on Huawei devices that can wake the phone on hotword detection!
Download and Import Profile
As always, we're providing the script's XML file that you can download and import. Simply download the file from the link below and save it anywhere on your internal storage. Open up Tasker and disable Beginner Mode in Preferences. Then, go back to the main screen and long-press on the "Profile" tab up top. You should see a pop-up with one of the options being "Import." Tap on that and browse to where you saved the .prf.xml file and select that file to import. Be sure you remember to enable Tasker's Accessibility Service or this profile won't work!
Download the profile from AndroidFileHostWe hope you find this tip useful. Let us know in the comments below if this works for you!
from xda-developers http://ift.tt/2mfRbli
via IFTTT
No comments:
Post a Comment