Dictate iPhone to Mac

iphonetomac.png

As you may know if you’ve read through this blog, I use a Mac Mini as a part of my entertainment system.  I mostly control it using a Logitech MX Air mouse (think Wii remote for your mac).  Even though I have both a wired and wireless keyboard close by, most times, I’m content to just start up the virtual keyboard to enter short searches into Netflix or Amazon Prime.  Lazy?  Perhaps.  But they didn’t make couches for pro-active & efficient go-getters.

I’d seen those commercials for things like Apple TV and other such devices where you can just speak into your remote and ask to search for specific movies & TV shows.  I’ve also played around with dictation on my laptop, but to my dismay, I discovered that my Mac Mini doesn’t have a built-in microphone.  So I started looking online for either a wireless microphone or an app that would allow me to dictate through my iPhone.  I ended up discovering that wireless mics are bulky & expensive, and the one iPhone app that did what I wanted (Air Dictate) was no longer available on the App Store, so I set out to create a cheap hacky alternative.

I realized that I already had the tools at my disposal to make this happen, and it consists of these components:

  1. IFTTT‘s SMS & Dropbox channels
  2. A Dropbox folder
  3. An iPhone/iPad with Siri (or the Messages iPhone app)
  4. A Folder Action
  5. A Contact named something like “Mac Mini” with IFTTT’s SMS number

I will describe what I did here so you can do this too.  The end result will allow you to activate Siri on your phone and say something like:

Tell my Mac Mini Breaking Bad hashtag paste

and “Breaking Bad” will be pasted wherever the cursor currently is on your screen.

Assuming you have an IFTTT account and Dropbox installed on the computer in question, here’s what you need to do:

  1. Create a folder in your dropbox named something like “DictateToMacMini
  2. Create a recipe on IFTTT (or edit the one I published) which, when it receives an SMS containing ‘#paste‘, puts a file with the extension ‘.txt‘ into your dropbox folder containing the message contents (with the hashtag removed).  It will look something like this: dictatetomacmini.png
  3. Now, on your computer you want to dictate to (in this case “Mac Mini”), start up the AppleScript Editor, select “Folder Action”, and paste this script (below is an image – click it to be directed to a selectable pastebin copy of the script) and name it something like “paste_file_contents.scpt“: paste_file_contents.png
  4. Save or copy the script into one or both of the following locations on your computer: “~/Library/Scripts/Folder Action Scripts” or “/Library/Scripts/Folder Action Scripts
  5. Now right-click on your Dropbox “DictateToMacMini” folder in the finder and select Services->”Folder Actions Setup…
  6. Select your “paste_file_contents.scpt” script and make sure the “Enable Folder Actions” checkbox is checked: folderactionssetup.png
  7. Finally, Siri needs to know where to send your messages, so on the iDevice which you intend to dictate through, create a contact named “Mac Mini” and add your IFTTT’s SMS channel number to it as a mobile number (so Siri knows you can send text messages to it).
  8. As an optional step, you can add the “Mac Mini” contact to your contact card as a relationship with the custom label “Mac Mini”.  If you do this, you’ll be able to refer to your computer like “Tell my Mac Mini…” when speaking to Siri.  Otherwise, you’ll have to say “Tell Mac Mini…”.

And there you go.  It might take Siri a few tries at first to understand what you’re trying to do when you dictate your first message, but she catches on pretty quick.

A few notes…

  • Where you want to enter the text on your computer must “have focus”.  That means, you must click where you want the text to go before dictating to Siri.
  • It takes a couple seconds for the paste to happen (but it’s much faster and easier than using the virtual keyboard).
  • Currently, the AppleScript removes the “#paste” string from the dictated message even though that’s unnecessary given the “{{MessageNoHashtag}}” IFTTT variable.
  • The AppleScript currently replaces hard returns with spaces, as it is intended for typing text into a search field.
  • The AppleScript does not save what you entered on the clipboard.  It saves the current contents of the clipboard and then restores it after the paste.

You can test your AppleScript folder action by creating a text file and dropping it into the “PasteToMacMini” folder while an open text file has focus.

And this trick is not just for Siri.  You can actually use the Messages app on your phone to type out and send texts with “#paste” to your IFTTT Mac Mini contact and it will paste your message on the computer.

I might edit the applescript in the future to cut out “Search for ” at the beginning of the message so that you could say something that rolls off the tongue better, such as “Tell my Mac Mini to search for Breaking Bad hashtag paste” to Siri.  As for now, I’ll leave that as an exercise for the reader.

My wife claims that this new trick will give me a new reason to get mad at Siri – when she mis-hears what I’ve said, but I told her that this is just a toy I like playing with.  have fun, and let me know if you’ve tried this out.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s