Tasker PAI series: Rudimentary AutoVoice music search feature
Disclaimer: The Tasker PAI series is a series of Tasker articles “Provided As Is“. They are marked as such because there’s an above average likelihood that something will break very badly when used by someone else, for whatever reason, and I don’t have the time to fix it for everyone that happens to. Read more here. Articles in this series are only published so that those who know what to do with it have the chance, but questions to these articles will be ignored.
Being able to search for music using voice control is one of my favorite features with Siri, but unfortunately it’s hard to replicate on Android. It’s probably possible to access the database of certain music apps and create some sort of intricate system to make it work, but honestly I’m not interested in spending that much time on this, so I instead came up with a very rudimentary system to get the basic functionality up and running. I’m posting this as a PAI article since it’s very rudimentary, lacks functionality, etc.
This method requires you to have all your music in a single folder. It also requires the files to have names that include whatever information you want to search for it using, as this won’t read metadata.
It essentially just uses Tasker’s List Files action to search for files, then opens the first file that matches. By creating an AutoVoice Recognized profile with “play” as the command filter, %avcommnofilter will contain whatever you say after “play”. Then, by using *%avcommnofilter* in the Match field of List Files, it will list any files that matches whatever you said after “play”. This can then be stored in a variable, like %songs.
To simply start playing the first song in that variable, using Open File with %songs1 in the File field. It will then open the file in whatever app is the system default for that type of music file, which is likely your preferred music player.
In my case, using PowerAmp, this works fine when the app isn’t already running. If it is running, it won’t work, which is why I use a Kill App action with root enabled followed by a half second Wait action before the Open File action. This means that when I ask for a new track, it will kill PowerAmp, then open the file.
Like I said, this isn’t the most sophisticated of creations, and there’s probably a better way out there. Since I just wanted the basic ability to start playing a specified track using AutoVoice, however, I can’t be bothered doing anything more with it.