yashsingh1/xdaforums huggingface dataset:
[Tasker Tips & Tricks] Tajnymag:
[MENTION=3372705]Humpie[/MENTION]

With multiple hotwords controlling the same thing, it gets tedious in Tasker to manually set every profile up.

Let's say we have hotwords "lights on/lights off/lights red/lights green/lights blue". If I wanted to forward these commands to Home Assistant, I would have to create a profile and separate events for each hotword.

Could you please add an option in the plugin to respond to "any" hotword and then pass Tasker the name of the detected hotword?

Thank you for otherwise perfect app
[Tasker Tips & Tricks] Humpie:
Thanks for the idea! I can imagine this would be handy, especially if you are using JavaScript snippets in Tasker. Otherwise you still have to make a lot of if-statements. In the mean time it could also clean things up if you put all the profiles in their own project (in the bottom bar), that way they won't clutter the rest.

Anyways, I put it in my to-do list! However currently I'm very busy at University and with other projects so I'm not sure when I have time to add it. It doesn't seem like a lot of work though, so maybe I'll do it in between something else.
[Tasker Tips & Tricks] Tajnymag:
Thank you. I understand that.

Good luck :good:
[Tasker Tips & Tricks] Humpie:
Aah, you're forwarding them. That explains it. I'm also a fan of home assistant btw :).
[Tasker Tips & Tricks] Tajnymag:
Yup, that's exactly my desired setup. After the initial setup, Home Assistant is a wonderful piece of software.
[Tasker Tips & Tricks] Desmanto:
Was about to say the same thing for the multiple hotword. What I want is the ability to select multiple hotwords, not all of them. So if I have 20 hotwords, I can select maybe 5 for this flow. So only those 5 active when I enable the flow. Then in another flow I can select 10, and so on. This is for flow separation. I don't want every hotword active, which maybe too sensitive or mis-triggered easily.

After then, provide variable, example {hotword} to indicate which hotword got triggered. We can then branch the flow accordingly based on the hotword. For current method, I have to add multiple hotword triggers and use regex to parse the hotword. Or I need to add another Input Speech for another voice input, which we want to avoid for home automation (need to voice command twice for single operation).

This is the example of the flow in Automagic, if Hotword plugin now support multiple hotwords. As long as Hotword plugin provide the {hotword} variable, it is easy to split or parse it into separate branch of logic; either using multiple parallel expression or map. I take example words command from Tajnymag and apply it to my yeelight.

I use multiple parallel expression to split the hotword. For "lights on" and "lights off", the action are separated, so each branch accordingly. For light color, I create another database mapping to map each color to it hex code (converted to decimal). So I don't need to create 3 (or more) branches, only single branch but with variable.

colordb = newMapFromValues(
"lights red", 16711680,
"lights green", 65280,
"lights blue", 255);

colorcode = colordb[hotword];

After getting {colorcode}, I use it for the intent to send to Yeelight app.

putString("com.yeelight.tasker.extra.PARAM", colorcode);

As always, no need for hurry, just add it when you can. ;) Thanks in Advance.
[Tasker Tips & Tricks] Humpie:
I like the idea of being able to select multiple hotwords for a single event. That way you can also enable all hotwords if you like or specify a few.

I'm not sure if it's exactly what you mean, but how would you like to be able to activate or deactivate hotwords using an action? That way you can more easily enter a branch of hotwords and only listen for the words in that branch. Just another idea I had for those who want to use my plugin in a larger scale.

Let's first see if I can actually build it in the plugin with its current setup haha. Thanks for the suggestions anyways!
[Tasker Tips & Tricks] Humpie:
Alright, I found some spare hours to make this update. Thanks again for all your suggestions!

It should be up on XDA Labs and the Play Store in a couple of minutes. Let me know if you encounter any bugs!

2.1

- You can now select more hotwords for one event

- It's now possible to enable/disable hotwords as a Tasker action

- Added donation option
[Tasker Tips & Tricks] Humpie:
I'm happy you like it! I'm glad I found a Saturday off to make the update, as it does enhance the plugin.

Yeah, at first I didn't understand what you meant with flows and turning it off and on etc XD, but I'm glad turning off and on hotwords solved it.

Adding tags is a nice idea, however I'm not sure it's a necessity as you can already sort of do that using Tasker (and probably automagic, though I'm less familiar with that). You can just create a task Enable Generic Hotwords where you put in the action and execute that from other tasks, for example. That way you only have to set up a "group" once (or twice turn enable / disable it) and afterwards you can just execute that instead of having to select the hotwords you want to enable over and over again.

(unrelated question, but how's the performance with AutoMagic? I don't have a paid version of that app, just Tasker, so I cannot really test. Plus for Tasker I added a faster, service-based, integration that the Locale API doesn't support)
[Tasker Tips & Tricks] Desmanto:
Of course, the update really helps the overall usage for multiple hotwords. Without grouping, yeah, I can actually just set multiple actions corresponding to each enabling/disabling the flow. It is just additional enhancement to what is good already. Not so urgent anymore, since we can select multiple hotwords and disable/enable them already.

Off Topic

For Automagic perfomance, I can say they are on the same level. Although Automagic win in some part, Tasker sometimes has edge on the other. This is based on the result of last test I've done last year, probably around January 2018. I used tasker for 3 years, before switched to Automagic. After more than 1,5 years with Automagic, I really regret that I don't made the switch earlier. :)

The best feature I love the most is the flow chart style. As you can see from my screenshot, it is much easier to read the flow. I tried to translate the tasker project from the yeelight forum. It was so difficult to understand the project in tasker, too many if branches and parameter passing scattered in so many tasks; that I better recreate my own flow directly from the yeelight documentation. I have finished the main nested map/list just within 1-2 hours last night. The other nice part of Automagic is most of the time, built-in action is enough, no need for extra plugin. I uninstalled at least 4-5 plugins after the switch. Even if Automagic can't do it natively, and require plugin, it still compatible with most tasker's plugin. To be honest, I even ever requested the same built-in action as your Hotword Plugin to the dev. But after I posted it, just realized that your plugin is very unique. Why reinventing the wheel when you have made it already and even updated it to our request. :D (Thanks for keep updating this app). That's why I also encourage others who ask for the feature to just use your app instead.

Automagic evaluation version should be enough for some testing, need to delete existing flow, so we can test more. There is dev version which you can use fully but for beta testing only and has time limit too. I think it is expired already by now, since Martin is still busy with the Call/sms restriction from google (tasker already get exemption, but Automagic hasn't yet). You can visit the link at my signature for more thread and comparison, especially my long comparison thread.

3 years with tasker, I only create about 50+ tasks/profiles. 1,5 years with Automagic, I have 67 active flows from total 209 flows (about 1/4 are redundant), with 150+ active triggers. Total triggers close to 300, condition is 800 and action is 1500+. Can't imagine to go this far with tasker.
[Tasker Tips & Tricks] Tajnymag:
Thank you so much :victory:
[Tasker Tips & Tricks] trohn_javolta:
Hi, as I think you already had this thought I'm just gonna ask instead of trying it myself:

Why can't we take the phone out of the equasion?

I read that the Shield supports some Logitech webcams and also the ps3 eye camera (gonna pick one up today for 5 bucks). By support I mean the built in microphone works with google assistant.

Now my Shield is rooted and I run the Tasker app on it. Could your plugin also work on the Shield itself?

I guess you'd somehow have to grab voice input from the usb interface where the camera/mic is connected. As a task one wouldn't need the adb plugin, just the built in "execute shell command".

Now I'm no dev god, I cannot do this. I could just test it with the ps3 camera.

Plz don't see this as a request, I'm sure this would involve a lot of work.

It's just an idea of mine and it would be very cool :D
[Tasker Tips & Tricks] Humpie:
I'd suggest you try! You can just install hotwordplugin on the shield (maybe you have to sideload it if you cannot install it from the play store).

In the plugin I have an audio source setting. If Android is able to recognize the microphone of the camera, my plugin should be able to access it too with one of those options!

(For optimal recognition do make sure you also record your hotwords on the shield, with that camera if that's possible)

If you're rooted, that's ideal, then you can indeed just execute shell commands as root.

For the people without root on their shield, just enable adb over wifi, and with my adb shell plugin send commands to localhost.
[Tasker Tips & Tricks] trohn_javolta:
Nice, I'll try. I'm sure I can install your plugin app via yalp store. :good:

For the Hotword recording part, I'm not sure if I can record sth. with the camera on the Shield Tv, maybe there's a recording app that recognizes the cam and works...but I guess I could also hook the cam up to my pc (I saw there are win drivers for it) and record it also there.. if I understood the concept right.

I already know the hotword I'll use for google assistant, it's gonna be "Jarvis" :cool:

If this works this is gonna open up soo many possibilities. :)

For example, I have a harmony hub. Unfortunately, google assistant integration with the hub is not (yet?) supported in my country.

However there's a harmony plugin for Tasker :) And your Plugin allows more than one Hotword.

So I could say "Jarvis shutdown" and let tasker send the shutdown command to the hub through harmony tasker plugin :)

I'm curious to see if or how long your plugin will wait for the hotword activation. I mean if "Jarvis shutdown" would instantly fire up google assistant or if it will wait and send the desired shutdown command to harmony hub.
[Tasker Tips & Tricks] Humpie:
You shouldn't differentiate between "Jarvis" and "Jarvis shutdown" as the recognition is pretty instant, so "Jarvis shutdown" will never be reached.

I see you have three options.

You can add a wait after the "Jarvis" command in Tasker and when "Jarvis shutdown" has been activated before the wait is finished, cancel the Google assistant. This however comes with a cost, namely that you always have to wait for Google Assistant when shouting "Jarvis".

You can make "Jarvis" start Google assistant and create "shutdown" as a separate hotword to control your Harmony.

This is the neatest options. You can enable or disable (groups of) hotwords from Tasker. That way you can say "Jarvis" and in Tasker disable "Jarvis" and enable "Assistant" and "Shutdown" for instance. That way, when you say "Shutdown" or "Assistant", nothing will happen, however when you say "Jarvis shutdown", it would activate "Shutdown" and you can do your thing. Of course, afterwards you'll need to disable "Shutdown" and "Assistant" and enable "Jarvis" again.
[Tasker Tips & Tricks] trohn_javolta:
Well, good and bad news:

Hotword detection works on the shield via pseye cam mic!

But combined with the task to start google assistant, android tv completely crashes once i say the word.

I'm pretty sure I know why:

I think I have to enable "turn off service in apps that can use the mic".

But it prompts me that the app needs usage access for that and I should grant permission on next screen. However once I hit ok the app crashes. Had this with Tasker before, the app also couldn't optain permissions.

Permission handling is different on android tv. Or better said there's no routine to grant permissions like on smartphones.

However I learned how I can grant them in terminal.

I assume the needed permission is android.permission.PACKAGE_USAGE_STATS. Am I right?

I did grant the permission with: pm grant nl.jolanrensen.hotwordPluginFree android.permission.PACKAGE_USAGE_STATS.

I know this command works from tasker.

However I still can't tick the setting in your plugin app :( Still get the text, hit ok and it fast closes on me.

Any ideas how I could get it to work?
[Tasker Tips & Tricks] Humpie:
Yup android.permission.PACKAGE_USAGE_STATS must be enabled for that. The switch actually checks for that exact permission. It's a secure or "protected" permission however which basically means it's "special" or something. It's not a normal permission because you'd have to activate it in a different part of the settings which Android TV apparently lacks. Maybe they need a different command or something.

If usage stats doesn't work, you might have to stop hotwordplugin using the action in Tasker before launching Google Assistant and reactivate it after 10 or 20 seconds or so (The old fashioned way of the plugin).
[Tasker Tips & Tricks] Humpie:
Haha, unless you have the 2015 Shield like I do.

Right, that's because they try to access the mic while my plugin is blocking it :/.

What I think is that AndroidTV simply doesn't have UsageStatsManager, so the permission to use it would never be allowed (This is also what I find when Googling it). This is the same as AppWidgetManager which I looked into before, meaning that AndroidTV doesn't have the System Service to allow Launchers to communicate with widgets. It would make sense for Google to remove UsageStatsManager for AndroidTV as it doesn't add anything (in their eyes) useful to a TV.

This means my plugin can not scan which app is opened in the foreground and thus not check whether that app might use the microphone.

The only other way would be to use an accessibility service I believe, but those are very heavy and will probably slow down your system quickly. You can try this however! With Tasker in the monitor settings, you can decide whether to use Accessibility or App Usage Stats to check which app is in the foreground. You can then use the "App" state to define which app is in the foreground and based on that stop/start HotwordPlugin.

I think that in your case you can indeed simply plug in your camera in your pc and record your samples there as you're using the same microphone on the Shield. The hotword must be trained with the microphone you're gonna use, not the device per se.

This has a simple answer :P Install the Google Home app on your phone and make sure you use it with the same Google account as on your Shield.
[Tasker Tips & Tricks] trohn_javolta:
Hmm.. I wonder how Tasker knows which app is opened in the foreground... I don't remember which permission I gave it on the shield to make that work...and it works!

I have a task where I tell Tasker to switch the input method (with help of autotools plugin) if certain apps are opended.

I have a logitech keyboard with a touchpad connected so for most apps I don't want on screen keyboard to pop up, thus I use the "NullKeyboard" app and for some apps I have this leanback on screen keyboard pop up.

I didn't change any monitor settings in Tasker... maybe in Tasker Accessibility is selected by default..gotta check.

I'll also check what permissions I granted to Tasker.

One thing that'd be cool is if your plugin could hook into Tasker somehow to get the info which app is in foreground, but I guess this isn't possible.

Sry if I'm annoying about this, I could totally manage these small hickups with Tasker, like make a task: If playstore is opened, disable hotword plugin, wait a few secs and enable it again..

I just think it would be much better if your app could have a working way of getting which app is opened.

Thx for the google home app tip ;) It's a bit confusing for me to differentiate between google home and google assistant. Thought google home app is just to manage the google home hardware. :o

Btw: how do you multi quote like you did? I see the "multi quote" button under comments, I select it and it gets yellow but nothing more happens :laugh: I always wondered..
[Tasker Tips & Tricks] Humpie:
Great! Yeah it would be nice if my plugin could also detect if the app in the foreground can use the mic the accessibility way, but I'm not sure if that's possible. I'll check because I'm curious XD.

Edit: I read that Google is now very strict with accessibility service using apps on the Play Store. My plugin would probably removed if I added that, as I'm not a big enough developer to actually have them listen to me... So I'd rather not test my luck there haha. What I can do, it try to make my check work in Tasker, as all it seems to need is a package name of the app in the foreground.

Edit2: I tried creating a task. For now it just loops constantly, maybe it can be altered to only fire when the foreground activity changes, idk. You can find it here https://taskernet.com/shares/?user=...dUxIy&id=Task:HotwordPlugin+Disable+Listening

The Google Home app now is just a combination of all things smart home and Google Assistant or something. So Chromecasts, AndroidTvs etc are also part of it. Now that I think of it... The Google Home app is literally a rebrand of the Google (Chrome)Cast app.

Also I don't use multi quote ;), I literally type [*QUOTE] your text [/QUOTE] my text [*QUOTE] your text [/QUOTE]. (remove the ' * 's, otherwise they'd obviously convert to quotes).
[Tasker Tips & Tricks] trohn_javolta:
my text [*QUOTE] your text [/QUOTE]. (remove the ' * 's, otherwise they'd obviously convert to quotes).[/QUOTE]

Ok, so I entered dumpsys package nl.jolanrensen.hotwordPluginFree to see more info. It also gives a list of requested permissions and granted ones.

In granted permissions I see this line indicating I gave the permission:

android.permission.PACKAGE_USAGE_STATS: granted=true

Same in Tasker app. Monitoring is set to app usage stats and I'm pretty sure I gave the permission the same way and dumpsys for Tasker app also shows this line: android.permission.PACKAGE_USAGE_STATS: granted=true

Sth. seems to be off with the permission check in your app. Otherwise it would let me tick the setting. Any ideas?
[Tasker Tips & Tricks] Humpie:
I check whether I have the permission using AppOpsManager. So maybe AndroidTV also removed that service...

But using the task I sent you and in Tasker setting app monitoring to use Usage Stats, does the app detection work? And does hotword plugin get stopped and started correctly?
[Tasker Tips & Tricks] trohn_javolta:
Oh, I totally missed that. What's it supposes to do? I disabled my hotword, disabled toast messages in app and started it. It loops...

I left service active on the top right of the app and pressed a button to bring up assistant...this results in a crash.
[Tasker Tips & Tricks] Humpie:
The task should loop, scan which app is in the foreground based on a (root) shell command every 300ms and if the foreground app has microphone access, hotwordplugin gets the stop command, else it gets the start command.

That what it's supposed to do at least
[Tasker Tips & Tricks] trohn_javolta:
It works for other apps! So this means that your plugin was granted the permission?..or did it check the foreground app via tasker?

Unfortunately for google assistant this does not work :( Still a crash. Also this loop task seems to interfere with the "old fashioned way" (using stop and start plugin tasks). I tried with and without it.

Maybe google assistant isn't considered a foreground app when activating?
[Tasker Tips & Tricks] Humpie:
Nice! No, my plugin doesn't have the permission. I just recreated in Tasker what my plugin would do if it did have the permission. So yes, it will interfere with start/stopping the plugin yourself as the task now stops and starts hotwordplugin for you. You can fix this by maybe letting it start and stop using a variable in Tasker or something. If you take my task as a base and be creative I'm sure you can come up with something nice :p.

You might be right about Google Assistant. What you can do to check is to add a Flash action inside my task and flash %package to see if the Google package is detected correctly. Otherwise maybe search for another solution to detect which app is in the foreground using Tasker and get the package name of it.
[Tasker Tips & Tricks] trohn_javolta:
I fear I'm not that creative :D

Guess this stays more a proof of concept then.

One thing I'm gonna check is if I can somehow determine if google assistant is running via tasker event or state... didn't think of that before.

Still I don't understand why I could obtain the app usage stats permission in Tasker but not in your plugin.
[Tasker Tips & Tricks] trohn_javolta:
could grant permission :)

I set this aside for a bit and now looked into the permission problem again and was able to give you app the needed permission.

Like I wrote, initially I granted the PACKAGE_USAGE_STATS permission via pm grant....... command.

Appops command always failed with invalid string for the permission.

Now I learned that via AppOpsManager the equivalent (?) permission to PACKAGE_USAGE_STATS is GET_USAGE_STATS. :)

So it seems that your app expects to get the permission via AppOpsManger because after giving GET_USAGE_STATS permission, I can tick the option to deactivate plugin if an active app has mic access.

Now in apps with voice search like youtube or app store I can hit the mic button and it works without a crash..Great!

Now the bad news: Normal Google Assistant call still leads to a crash, which confirms the fear that google assistant isn't recognized as an active app by the plugin. :(

But I can always use the "old fashioned" way to disable or enable the plugin via tasker.

Ending this post on a positive note: Thanks to your plugin I dealt with the whole permission topic and I found a great app called App Opps Permission Manger which brings a user friendly way to enable permissions via appops. :)
[Tasker Tips & Tricks] Humpie:
That's great to hear! So Android TV does support usage stats after all.

Yeah, what I think is that Google Assistant on Android TV is part of the homescreen or the system UI or something. So when it appears, it's not the Google app that my plugin reads, it's the homescreen or something, which doesn't have microphone access.

Anyways, thanks for letting me know!
[Tasker Tips & Tricks] faranone:
halp

Hi,

I'm encountering a problem i tried to solve by myself but i can't find a working solution. I'm trying to invoke the google assistant by a personalized hotword with your plugin and Tasker, but when your plugin has microphone services activated the google assistant says "can't reach Google at the moment". Works fine if the plugin is not listening.

So i tried turning off and on the plugin while google assistant is on ( with Tasker ), but this method somehow works only the first time, then i have to manually reboot the plugin to let it function again.

Do you have any advice?

Thank you :)
[Tasker Tips & Tricks] Humpie:
This is exactly why I added the setting to disable hotword plugin listening in apps that require microphone access, like Google Assistant. If you enable that setting it should work fine.
[Tasker Tips & Tricks] faranone:
Thank you for your answer.

Well, the first time worked and i was "wow, it was that simple!!"..

Now it doesn't work anymore. And it takes like 30 seconds to 1 minute between each hotword recognition.. :c
[Tasker Tips & Tricks] Humpie:
That's weird. What happens when you have the ding enabled? Do you hear the ding when you say the hotword and then it takes a minute to get to Tasker?

In that case make sure to disable all battery saving functions for Tasker.