Thursday, February 4, 2016

Using voice to launch all the Tasks (Updated and Improved)

While the debate over more Profiles or more Tasks is better rages on (ok, well, not raging but it's been asked), I prefer to look at it this way.  Profiles I reserve for activities I want to launch a single way, such as Ryoen Deprouw's excellent tutorial on voice searching through your apps. Other profiles are your standard headset inserted and alarm clock ones that many others have documented.

Tasks I like to keep if I want to execute an activity in more than one way, or under different circumstances.  These are usually ad-hoc on demand requests I make, but might also be set as event based.

Sometimes I feel crazy on a Saturday night and want to change my wallpaper on an hourly basis so I set a profile to do that.  But suppose I don't like it, I can create a profile shortcut to change it again or if I'm feeling too lazy to push my screen I use a voice command to launch that task.

The problem is, by default Tasks are First Letter Upper Case, while Google accepts voice inputs as first letter lower case.  And since everything in the world is case sensitive, you need a script to convert the Google input into something Tasker can handle.

BTW I can't take full credit for this, it's from Tristan Pointer's post here: https://groups.google.com/forum/#!topic/tasker/rPO3BExrwcQ.  I changed it slightly to be more general so I could use it to launch a task from my autovoice profile.

As a simple example, here is a flash executed first through a shortcut widget, and then through a voice command.



Tasker Pro over at the G+ Tasker Plugin group made it easier for everyone;

"There's a better way to go about this. I hope you will seriously consider it and add it to your article. It basically works the problem 'backwards' but is indeed a better solution.

So - I've got Tasks with all kinds of upper/lower case mixed names, including Tasks with names like "SEARCH for newest reddit comments".

That wouldn't be able to be launched using the method you outline. What WOULD work however, in a larger variety of situations, is this:

A1. Variable Set: %voice_input To: %avcommnofilter
A2. Test Tasker > Tasks Store Result In: %all_tasks
A3. Variable Set: %index To: %all_tasks(#?%voice_input)
A4. Perform Task: %all_tasks(%index)

And there it is. Four Actions. If you say "launch task play beep sound" it will launch the Task even if it's name in Tasker is "PLay BEEP SoUnD".

It is also easy to add error handling if for example the Task doesn't exist. Right after A3 could just do a "Stop If %index=0" and add a Flash Action as well, or a Say Action to say "The Task you requested does not exist".
Enjoy, here is the download for the long version since I spent like hours figuring it out :)
Voice Search Tasks

Profile: Voice Launch Task (8)
State: AutoVoice Recognized [ Configuration:Event Behaviour: true
Command: "launch task  (regex)"
Last Cmd Id Regex: false
Last Cmd Id Invert: false
Not on Normal: false
Not on Continuous: false
Contains All: false
Use Regex Replacements: false
Do Google Now Search: false ]
Enter: Launch Task (44)
A1: Variable Set [ Name:%convertthis To:%avcommsnofilter() Do Maths:Off Append:Off ]
A2: Variable Split [ Name:%convertthis Splitter: Delete Base:Off ]
A3: For [ Variable:%item Items:%convertthis() ]
A4: Variable Convert [ Name:%item Function:To Upper Case First Store Result In: ]
A5: If [ %converted Set ]
A6: Variable Set [ Name:%converted To:%converted %item Do Maths:Off Append:Off ]
A7: End If
A8: If [ %converted !Set ]
A9: Variable Set [ Name:%converted To:%item Do Maths:Off Append:Off ]
A10: End If
A11: End For
A12: Variable Split [ Name:%converted Splitter: Delete Base:Off ]
A13: Perform Task [ Name:%converted Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]

Monday, January 25, 2016

Panorama-a-rama (show me the world)

Like most of us, many of my profiles only do casual things that I wish my phone did nativly.  Take viewing pictures.  Sure anyone can voice command "show me pictures of Golden Gate Bridge" but you can't say "show me panoramas of Golden Gate Bridge".

But using the Street View app, you can create a fun little trick to do just that.

Here is your end result.  You could just as easily open Street View and type in Golden Gate Bridge, but we're not in the business of that kind of effort :)



To get here you will need;
Tasker
AutoInput
AutoVoice
Street View

(The above looks better when you can tilt the phone to landscape, but that messes up the recording software)

What we're going to do, is grab the voice command "street view golden gate bridge", chop off everything after "street view" and show you pictures of it.  I don't say "show me panoramas" as a command because sometimes Google, or I suspect Moto Voice, will jump on the command and start showing panoramas in Google Search as normal before Tasker can get involved.

Fair warning, at least on my phone, this *usually* works.  I've tried launching Street View through Tasker and AutoLaunch but in both cases, Street View occasionally Force Closes on open.  I left it as just a generic "Launch App" because it's easier.

That also explains the long(!) four second wait time between the AutoVoice command and the Launch.  It makes it seem at least a little more stable.  Also, if you manually launch Street View before those total of eight seconds pass it'll still go and complete the task.

There are a couple other waits that you may or may not need.  Sometimes it just needs an extra second here or there to let things like the keyboard dropping back down before pasting to process.  Other than that, it's just some AutoInput clickity clicks to let you see all the places you wish you were right now.

The Profile;
Profile: Voice Street View (43)
State: AutoVoice Recognized [ Configuration:Event Behaviour: true
Command: "street view (regex)"
Last Cmd Id Regex: false
Last Cmd Id Invert: false
Not on Normal: false
Not on Continuous: false
Contains All: false
Use Regex Replacements: false
Do Google Now Search: false ]
Enter: Anon (49)
A1: Set Clipboard [ Text:%avcommnofilter Add:Off ] 
A2: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
A3: Launch App [ App:Street View Data: Exclude From Recent Apps:Off Always Start New Copy:Off ] 
A4: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
A5: AutoInput Action [ Configuration:Type: Id
Value: com.google.android.apps.dragonfly:id/map_action_search
Action : Click
Is Tasker Action: false
Check Screen State: false Package:com.joaomgcd.autoinput Name:AutoInput Action Timeout (Seconds):20 ] 
A6: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] 
A7: AutoInput Global Action [ Configuration:Action: Back Package:com.joaomgcd.autoinput Name:AutoInput Global Action Timeout (Seconds):20 ] 
A8: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] 
A9: AutoInput Action [ Configuration:Type: Id
Value: com.google.android.apps.dragonfly:id/search_text
Action : Click
Is Tasker Action: false
Check Screen State: false Package:com.joaomgcd.autoinput Name:AutoInput Action Timeout (Seconds):20 ] 
A10: AutoInput Action [ Configuration:Type: Id
Value: com.google.android.apps.dragonfly:id/search_text
Action : Paste
Is Tasker Action: false
Check Screen State: false Package:com.joaomgcd.autoinput Name:AutoInput Action Timeout (Seconds):20 ] 
A11: AutoInput Action [ Configuration:Type: List
Value: 1
Action : Click
Is Tasker Action: false
Check Screen State: false Package:com.joaomgcd.autoinput Name:AutoInput Action Timeout (Seconds):20 ]

tl;dr ... download here: Panorama a ramaama
Displaying Screenshot_2016-01-24-21-48-18.png
Displaying Screenshot_2016-01-24-21-48-18.png

Thursday, January 21, 2016

Spotify Wallpaper Changer

Like I said, I'm not a programmer.  A little background on that, I had one C++ class in college and I got a C-, ironically.  Pages of code to accomplish what others could perform in less than two dozen lines.  I'm not good at it.

Still I've managed to muddle my way through Tasker to create some profiles, this one being my favorite.  Some people want to change the world, I just want to change wallpapers to look cool.

I'll post the description, and what I *think* is going on, how to configure everything that you need to get there because I believe for the rest of you who are also not programmers can learn from them to build other profiles.

This basically will change your wallpaper to the album of your currently playing track in Spotify.  First, here is the end result we're going for (do not judge my taste of music :p );



















To get here, you need these apps;
Tasker
Spotify
Media Utilities (Beta)

First Media Utilities Setup;
Add "Spotify" to the available media apps it can use.  Then go into 'Settings' and uncheck everything except the boxes for "Attempt Direct Control" and "Make Album Art Available"

You will also need an Exit Task.  This will get you back to your default wallpaper when either a track is stopped or headphones unplugged.  I suspect this will also work if you don't include the Headset Plugged profile state.  I think I left that so it didn't launch every time something else called media, like an ad.

The exit task is it's own separate task, as opposed to an anon one in the profile because I use that for other wallpaper changing profiles.  That way i only have to change it in one place if I get tired of my default wallpaper.  Everyone should always have a default wallpaper task because you'll want it sooner or later.

What this does is, look for the headset plugged in, and the media state is playing.  Once that third condition is met (New Metadata), it copies the default Media Utility album art file (mu_coverart_current.jpg) to a new file.  It then sets that copied file as the wallpaper.  This will repeat every time the track changes.  When either music is paused, stopped, or the headphones are unplugged it will revert back to your default.

Sometimes when you pause, then skip to start the next track it slips.  I get around that by not pausing then skipping to the next track.

Anyway, here is your profile;

Profile: App Spotify Wallpaper (6)
State: Media Utilities State [ Configuration:New Metadata ]
State: Media Utilities State [ Configuration:Is Playing ]
State: Headset Plugged [ Type:Any ]
Enter: Anon (42)
A1: Copy File [ From:Pictures/mu_coverart/mu_coverart_current.jpg To:Pictures/coverart Use Root:Off ]
A2: Set Wallpaper [ Image:Pictures/coverart/mu_coverart_current.jpg Scale:Off Crop:Off ]

Exit: Wallpaper Reset (45)
A1: Set Wallpaper [ Image:zedge/wallpaper/Bamboo-wallpaper-8639973.jpg Scale:Off Crop:Off ] If [ %MTRACK !Set ]

These are changes from local files because I download my playlists.  If you are playing from the server you might have to add a Wait period of a second or two before the 'Set' command so it can get the album art.

You can download this profile here: Spotify Wallpaper Change

Enjoy!

Monday, January 18, 2016

Intro (fun with Tasker)

I'm not a programmer, obviously, since I'm using Blogger.  I am, however, a Tasker enthusiast with some time on my hands.  I'm sharing a bit about the Profiles / Tasks I have created, stolen and modified to share with everyone.  Stay tuned!