Amazon Polly is a text-to-speech (TTS) service that turn text into lifelike speech. Polly’s Text-to-Speech (TTS) service uses advanced deep learning technologies to convert the text into human speech. Polly currently supports dozens of voices across a broad set of languages. Amazon Polly also offers Neural Text-to-Speech (NTTS) voices. Using it provide advanced improvements in speech quality through a new machine learning approach.
Polly’s NTTS technology also supports two speaking styles and those are Newscaster reading style and Conversational speaking style. Using Amazon Polly we can create applications that talk and speech-enabled products. We can use SSML (Speech Synthesis Markup Language) with Amazon Polly as additional customisation in Audio. For example, if our text contains words from more than one language, we can flag it to be pronounced as such using SSML.
Also in AWS Amazon Polly Console, we do have the option to test the working by simply give the text and listen by clicking play button.
- Provides a wide selection of natural-sounding male and female voices.
- Polly can generate high quality audio output up to 24000 Hz
- Using Amazon Polly’s API, we can stream audio directly to our application.
- Currently supported multiple audio formats and they are MP3, Speech Marks, PCM and OGG
- Unlimited replays of generated speech without any additional fees.
- Low cost due to Amazon Polly’s pay-as-you-go pricing structure.
- All text submissions are protected by SSL while in transit. Also has the option encrypt the audio files.
- Option to access Amazon Polly is via AWS Console, CLI, or SDKs.
AWS Polly Pricing Details
For Amazon Polly service, we only pay for what we use. Which means we charged based on the number of characters of text that we convert either to speech or to Speech Marks metadata. More details about pricing structure can be found from the amazon website.
Details of AWS Plugin for WordPress.
The AWS Plugin for WordPress is a free Plugin designed by Contributors like awslabs,wpengine etc. We can use this plugin on a WordPress websites hosted on AWS environment or on a remote hosts. This “AWS Plugin for WordPress” uses Amazon Polly to generate audio for our blog posts and pages. We can save the generated audio on our own server or to an Amazon s3 bucket.
Benefits and Features
- We can Integrate with Amazon Alexa to listen to our blog posts on Alexa-enabled devices.
- Use Amazon CloudFront and provide our audio stream over cloudfront servers. This will provide a faster, more reliable viewing experience for end users.
- Append ‘/amazon-pollycast/’ to our page URL for getting Amazon Pollycast RSS feed
- Options to support for things like whispering, speech marks, a timbre effect for generating audio files.
- We can use Audio Only and Word Only tags in to our content.
- RSS 2.0-compliant Pollycast feeds with thee XML data needed to aggregate podcasts.
- We will be able to toggle the text-to-speech functionality on or off on a per-post basis.
The plugin has the following filters
amazon_polly_post_types : Specifies which WordPress post types should be used by the plugin.
amazon_polly_content : Which Enables us to modify the content of the post before it is sent to the Amazon Polly service for text-to-speech conversion.
amazon_polly_s3_bucket_name : Enables us to define our own bucket name where audio files will be stored.
So lets discuss how we can implement Amazon Polly in our WordPress website. In this step-by-step tutorial we will use the “AWS Plugin for WordPress” to add text-to-speech capability to a WordPress. This will give voice capabilities and visitors to our websites can play with inline audio players and podcasts.
1. Create An IAM user and attach Policy.
AWS for WordPress plugin Need an IAM user attached with IAM policy that defines the permissions that apply to the user.
Sign in to the AWS Management Console and open the IAM console
In the navigation pane, choose Policies. Then choose Create policy.
Choose JSON tab,Delete everything in the policy text box, and then paste or enter the following JSON policy into the text box
Click Review policy button, On the Review policy page, give the name as “AWSForWordPressDeleteCert” and click Create policy.
Now in the IAM console, choose Users. Then choose Add user.
For User name, enter AWSForWordPressPlugin
For Access type, choose Programmatic access and click Next : Permissions button
On the Set permissions page, Choose Attach existing policies directly.
In the search box, enter WordPress, and then select the check boxes next to AWSForWordPressPluginPolicy and AWSForWordPressDeleteCert.
Click Next: Tags >> Choose Next: Review >> Choose Create user.
Choose Download .csv to save the user’s credentials (access key ID and secret access key) to our computer. We need them later to configure the AWS for WordPress plugin.
2. Installing and Configuring the Plugin
Log into WP Admin dashboard, Choose Plugins >> Add New
In the search box, enter AWS for WordPress.
Find the AWS for WordPress plugin. Choose Install Now and Activate the plugin.
From wp-admin left panel find out AWS icon >> Choose General
Give the AWS access key and AWS secret key of the IAM user we created through AWS console.
Choose the IAM user policy region, in our case its us-east-1 ( US East, N Virginia) and save settings.
Now choose “Text To Speech” option and enable “Enable text-to-speech support” and save settings.
Below are few important configurable options.
- Voice name : The Amazon Polly voice to use in the audio file. Choose as per our desire.
- Neural Text-To-Speech : Delivers significant improvements in speech quality.
- For Newscaster Style and Conversational Style, we need Neural Text-To-Speech enabled first.
- Sample rate : The sample rate for the audio files that will be generated, in Hz. Higher sampling rates produce higher-quality audio.
- Player position : before or After post
- New post default : Its how the amazon Polly enabled by default or not.
- Autoplay : Automatically play audio content when page loads
- Add post title to audio : If enabled, each audio file will start from the post’s title.
- Add post excerpt to audio : If enabled, each audio file will have an excerpt of the post at the beginning.
- Enable download audio : If enabled, viewers will see a download button next to the audio player.
- Store audio in Amazon S3 : Defines whether the audio file need to be stored in amazon s3 bucket. Its enabled by default.
- Amazon CloudFront (CDN) domain name : If you have a CloudFront distribution for your S3 bucket, enter the domain name
- Display “Powered by AWS” : Use this option to choose whether to display the Display by AWS logo on your website or add it to the content (like audio) that the plugin generates
- In Podcast : Amazon Pollycast section, if we enable it, we will have the option podcast our generated audio files.
- In Translate Configuration section : We will have the option to translate the audio files in to different supported languages
- Alexa Integration is available, if we need to enable it.
3. Enable Or Disable Amazon Polly for our Post.
In a create new post page, we will have the new Amazon Polly meta box that lets us to generate Audio files of our creating blog post.
And once we enable the text-to-speech functionality, our visitors will see the audio player on the front-end of site at the location that we specified
Customising can be done on Amazon Polly Audio
- Adjust the plugin settings like Voice name, Automated breaths, Audio speed and fine tune the audio files quality
- Use SSML in our blog post content and define how it will be spoken.
- Adding Translated Text to Your Post by making changes in plugin settings.
- Use Audio Only and Word Only tags in our content.
Which means sometimes we want to add something to our audio podcast but don’t want it to display it in the blog article. Or we want something to show in the article but don’t included it in the audio file. This can be done with the Audio Only and Word Only tags, which you place in the WordPress content to control which part of the text will be displayed or spoken.
To convert text to audio but not display it in the browser. Isolate the selected text on your WordPress page by placing an empty line above and below it. On the line above the selected text, insert the following tag.
You can use the same procedure to show text in the article without including it in the audio file by using following tags.
This concludes the Install and Configuration of Amazon Polly in a WordPress Website. Leave your thoughts at the comment box.