Automated Podcasts With Automator & Overcast

I've mentioned before that I use Siri as an editing tool. I write a piece, lightly edit it, and then have Siri read it back to me. This helps me catch unintended grammatical errors and clumsy sentences. Building on that principle, and Hewell both ship with a feature that use iOS's AVSpeechSynthesizer API to read articles or location information aloud.

That said, I often find articles that I want to read, but after a long day staring at a computer screen, I don't want to actually read them. Lots of sites these days provide spoken audio for their articles—which is great—but the vast majority don't.

That's where Automator comes in.

Save Spoken Text to File

This Automator service simply runs a bash script that takes the contents of the selected text as input, feeds it to the built-in macOS say command, and outputs it to a file on the Desktop named using the contents in my clipboard.

Check out the full script
cd ~/Desktop;
# A hack to get stdin into say through Automator. For some
# reason simply saying -f didn't work for me.
while read line; do echo "$line" done < "${1:-/dev/stdin}" |
    say -o .spoken_text -f -

TITLE="$(pbpaste -Prefer txt)"
if [ -z "$TITLE" ]; then
    TITLE="Spoken Text"
# Sanitize the article title. Writers love colons which macOS hates
TITLE="$(echo "$TITLE" | sed -e 's/[^A-Za-z0-9._-]/_/g')"

# Conver the audio and be quiet about it
/usr/local/bin/ffmpeg -i .spoken_text.aiff -loglevel -8 -y "$TITLE.aac"
rm .spoken_text.aiff

The script also uses FFmpeg to convert the audio to an AAC file so that I can then upload it to Overcast, my preferred podcast player.

By default, macOS will include Automater services in the right-click menu, but I've also bound the script to Cmd+Ctl+Shift+S (which is similar to my existing Cmd+Ctl+S shortcut for reading the selected text aloud).

The macOS Services Menu

Now, I can discover new articles to read, perform a quick set of keystrokes, upload the audio to Overcast, and then go for a walk while I catch up on the day's interesting news!1

I've provided the Automator service as a zip archive below if anyone wants to play with it.

⬇️ Save Spoken Text to File.workflow

1. There are a few quirks to this workflow still. Websites are filled with non-article content, so to avoid selecting those, I typically following the following steps:

  1. Turn on reader mode (Cmd+Shift+R)
  2. Copy the title of the article to the clipboard (Cmd+C)
  3. Select the article text (Cmd+A)
  4. Run my Automator service (Cmd+Ctl+Shift+S)
  5. Upload the new AAC file to Overcast

I admit, it's a little cumbersome, but it does work really well.

Filed under: blogging, programming
Other Links: RSS Feed, JSON Feed, Status Page →