How to use Amazon Polly and Turn Your Blog Posts into Speech Recordings
AWS and WPEngine recently launched a WordPress plugin designed to bring the power of Amazon Polly to WordPress — and it’s super cool.
So what exactly is Amazon Polly?
Amazon Polly is a text-to-speech service that uses deep learning technologies to synthesize text into human-like speech recordings.
The Amazon Polly for WordPress plugin makes adding accessible audio recordings of your posts super easy. I’m impressed, so much that I have already added the plugin to my blog, and updated my own WordPress theme, Tabor, to support the new plugin.
Check it out for yourself by listening to this article. 👍
Setting up the Amazon Polly for WordPress plugin
While you do need an AWS account, the Amazon Polly for WordPress plugin is super simple to use and not too difficult to get up and running. I’ve detailed a guide below to getting set up, although Amazon has a highly detailed step-by-step guide, if you’d like more information.
- Type “IAM” in the search field. Select it, and you will be redirected to the IAM (Identity and Access Management) service.
- Click on the “Policies” label within the left menu.
- Then click on the “Create Policy” button to create a new policy for your website.
- Select the “JSON” view and paste in this gist of code.
- On the next step of the wizard, add the policy name “PollyForWordPressPolicy,” and create it.
Next, you’ll want to create an IAM (Identity and Access Management) user. Follow these steps to do just that:
- Click on “Users” within the left menu, and then click the “Add User” button.
- Add a name for your user, such as “WordPress,” select the “Programmatic access” option, and proceed to the next step.
- From the “Permission” step, select “Attach existing policies directly,” and then provide the name of the policy created earlier, “PollyForWordPressPolicy.”
- From the “Review” step, click the “Create User” button.
- The user should have been created now. The “Access Key ID” and “Secret Access Key” are yours to add to the plugin’s configuration page on your WordPress dashboard.
Now that you have your access and secret keys, you may head to your WordPress Dashboard > Settings > Amazon Polly page and add the keys to their respective fields within the plugin’s settings.
You may also select the voice style, sample rate, player position (above the post, or below it), as well as a few other options.
Enabling Amazon Polly on your blog posts
Now that you’ve created an AWS account, set up your website’s policy, retrieved your access keys and added them to the plugin’s settings — you’re good to go. 😬
On each post’s edit view, you’ll now see a new “Enable Amazon Polly” metabox. This is where you may enable Amazon Polly and select a voice for the recording to use.
Once you’ve updated the post, the text is processed into a fine recording with your selected voice, and output to the frontend. Nice.
How much does Amazon Polly cost?
With Amazon Polly, you only pay for what you use. There is no setup cost and no minimum fee. You are charged based on the number of characters in your blog posts that are converted to speech.
There is a free tier to Amazon Polly, which includes up to 5 million characters per month for speech requests, for the first 12 months. Once you’re outside of the free tier, the pay-as-you-go model is only $4.00 USD per 1 million characters of speech requests. That’s pretty awesome.
Tabor + Amazon Polly for WordPress plugin
Out of the box, the Amazon Polly for WordPress plugin works quite well with my Tabor WordPress theme, as I suspected it would. I did, however, add a few finishing touches to the style and markup of the front-end output.
First, I added a filterable “Listen to this article” label. It’s quite important that readers know what they’ll be listening to, before they hit play. A rogue audio player doesn’t quite fill that need.
I also touched up the styling just a smidgen, to make sure the audio player felt native to the Tabor WordPress theme. I’ll likely add these same touch-ups to my other WordPress themes that cater to writers and publishers.
With the Amazon Polly for WordPress plugin, your visitors will be able to listen to your posts regardless of what they’re up to. It’s a really neat entrance into providing unique digital experiences for readers visiting your blog. I’m absolutely a fan.
Also, in the spirit of open source, the plugin’s source code is available on GitHub and collaboration is both welcomed and encouraged.