You may have noticed that I am turning my blog posts into lifelike speech audio versions. To do this I am using Amazon Polly and here I am going to show you how you can use it and customize it.
Tired of reading? Then listen to this article: |
Amazon Polly is a cloud service that enables you to turn text into speech using over 40 unique and lifelike voices. WP Engine and Amazon have created a free plugin to help WordPress users integrate it into their WordPress sites.
The Amazon AI Plugin for WordPress works on both sites powered with Amazon Web Services (AWS) and those running on other web hosts. Either way, you can use Amazon Polly to generate audio for your blog posts and pages. Plus, it lets you store the audio versions on your own server or using Amazon S3 at a minimal cost.
Here I am not going to show you how to install, set up and configure the plugin. This information is already laid out perfectly on the plugin’s homepage.
But I will show you how to customize Amazon AI Plugin for WordPress, how you can show the player on the homepage and how to move the player position to anywhere you want on a page.
Because out of the box the Amazon AI Plugin for WordPress won’t show the player on the homepage and it only lets you show the player before the post or after the post.
But with a bit of customization you can display the player anywhere on the page, and on the homepage (like I have on my homepage).
How to move the Amazon Polly / AI WordPress plugin player position and how to show it on the homepage?
It’s really straightforward.
First add the below code into your functions.php file (important: backup your functions.php file before making any changes):
// Move Amazon AI Polly Player Position function amazon_polly_player_shortcode($atts, $content = NULL) { global $post; $tagged_content = ''; if(intval(get_post_meta($post->ID, 'amazon_polly_enable', TRUE))===1) { $player_source = get_post_meta($post->ID, 'amazon_polly_audio_link_location', TRUE); $tagged_content = PHP_EOL.''.PHP_EOL.' <table id="amazon-polly-audio-table"><tbody><tr><td id="amazon-polly-audio-tab"> <div id="amazon-ai-player-label">Tired of reading? Then listen to this article:</div> <div id="amazon-ai-player-container"> <audio class="amazon-ai-player" id="amazon-ai-player" preload="none" controls="" controlslist="nodownload"> <source type="audio/mpeg" src="'.$player_source.'"> </audio> </div> <div id="amazon-polly-subscribe-tab"></div> <div id="amazon-polly-by-tab"></div> </td></tr></tbody></table>'.PHP_EOL.''.PHP_EOL; } else { $tagged_content = PHP_EOL.'<!-- Amazon Polly not enabled on this post -->'.PHP_EOL; } return $tagged_content; } add_shortcode('polly_player', 'amazon_polly_player_shortcode');
On line 9 you can customize the player description text Tired of reading? Then listen to this article: to whatever you like.
Then add in the below shortcode into your post or page where you want the player to appear:
[polly_player]
Finally go in to the player position setting in WordPress and select do not show:
That’s it! The Amazon Polly Plugin for WordPress player position should now show up where you have added in the shortcode.
Hi Mathias,
I have a confusion.
Will Amazon Polly regenerate the audio file every time I update the content if it enabled?
If yes, Please guide how we can avoid that?
Thanks!
Hey, I’m trying to use this to place the audio in the same position across all posts of the same type. I have a plugin that uses a post type “at_biz_dir”.
The amazon plugin allows me to add in that post type and have the transcription features for that post type, too. Which is great. Unfortunately it’s showing at the top of the page (for that post type, but I’d prefer to have it appear below the post title (my name) or at the bottom of the bio. See here: https://montessoricommons.cc/directory/fearghal-hendron/
For normal posts, the positioning that amazon provide is fine.
I must admit I’m self taught at “chopping together other peoples code” (read: no training or experience), any pointers you could share would be amazing.
Great intro info, thanks!
I have to wonder if the plugin has allowance to hide content. For instance, in this post, the reader was reading out your polly position shortcode text. While a bit humours to hear the first time around, I can imagine this being tedious. It would be good if the plugin can insert tags such as “to learn more about the code behind this shortcode, visit my webpage for more info,” and then remove the code from the recording.
Anyway, thanks for the heads up. 🙂
This plugin is free or paid? if it’s paid how much for a lifetime?
It’s a free plugin
Great post! I saw this audio player on another website and didn’t know what it was. I came across your website and got the information I was looking for. I am going to get it installed on my website soon. Thanks a lot!
Thanks it worked however I have a problem.
Right before and after the post there is a string of text saying:
-AMAZONPOLLY-ONLYWORDS-START-
-AMAZONPOLLY-ONLYWORDS-END-
Any idea how to fix this?