With the Amazon Polly for WordPress Plugin

In this step-by-step tutorial you will use the Amazon Polly for WordPress plugin to add text-to-speech capability to a WordPress installation. Amazon Polly is a service that uses advanced deep learning technologies to synthesize speech that sounds like a human voice, enabling you to create applications that talk, and build entirely new categories of speech-enabled products.

The Amazon Polly for WordPress plugin example demostrates how content creators can easily add text-to-speech capabilities to any written content. With more and more search happening by voice, it’s essential to have more of your website’s content in audio formats. By adding voice capabilities, visitors to your websites can consume your content via new channels such as inline audio players and podcast applications.

You can add the Amazon Polly for WordPress plugin to a WordPress installation that is set up on an EC2 instance, LightSail or hosted elsewhere. There are numerous options to create a WordPress installation on AWS. If you need a WordPress site on AWS, you can create one easily using LightSail, on EC2 using the Launch a WordPress Website 10-minute tutorial, or with a more advanced tutorial at Build a Wordpress Website project.

This tutorial requires an AWS account

Create a Free Account

Open the AWS Management Console and you can keep this step-by-step guide open. When the screen loads, enter your user name and password to get started. Then type an IAM in the search box, and press Enter to open the dashboard.

If you are hosting your WordPress site on EC2, use the EC2 instructions below.

If you are hosting your WordPress site on LightSail or not on AWS, use the LightSail instructions below.

  • EC2

    In this step, you will create an IAM policy, which is a document that defines permissions. Once you attach the IAM policy to an IAM EC2 role, and can assign this role to your EC2 based WordPress server.

    a. Select Policies on the left-hand side and then Create Policy.

    tmt_tts-for-wordpress_1_EC2_a

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_a

    b. On the Create Policy page select JSON tab in the table. Paste below code into the editor, and then select the Review policy button.

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Permissions1",
                "Effect": "Allow",
                "Action": [
                    "polly:SynthesizeSpeech",
                    "s3:HeadBucket",
                    "polly:DescribeVoices"
                ],
                "Resource": "*"
            },
            {
                "Sid": "Permissions2",
                "Effect": "Allow",
                "Action": [
                    "s3:ListBucket",
                    "s3:GetBucketAcl",
                    "s3:GetBucketPolicy",
                    "s3:PutObject",
                    "s3:DeleteObject",
                    "s3:CreateBucket",
                    "s3:PutObjectAcl"
                ],
                "Resource": "arn:aws:s3:::audio_for_wordpress*"
            }
        ]
    }
    tmt_tts-for-wordpress_1_EC2_b

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_b

    c. On the Review policy page in Name field, type: PollyForWordPressPolicy and then select the Create policy button.

    tmt_tts-for-wordpress_1_EC2_c

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_c

    d. On the left-hand side of the screen, select Roles and then Create Role.

    tmt_tts-for-wordpress_1_EC2_d

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_d

    e. On the Create Role page, select AWS Service on the top. From the services list select EC2. From the Select your use case list, select EC2. Select Next: Permissions to continue to the next page.

    tmt_tts-for-wordpress_1_EC2_e

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_e

    f. On the Attach permissions policies page, in the search box type PollyForWordPressPolicy, Select the checkbox next to the policy from the list and then select Next Review.

    tmt_tts-for-wordpress_1_EC2_f

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_f

    g. On the Review page, in the Rule name field, write PollyForWordPressRole, and then select Create role to continue.

    tmt_tts-for-wordpress_1_EC2_g

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_g

    h. Now you will assign the PollyForWordPressRole role to your WordPress EC2 instance. Select Services tab on the top of the page and then EC2 service.

    tmt_tts-for-wordpress_1_EC2_h

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_h

    i. Select Instances on the left-hand side, and choose your EC2 WordPress instance. From the Actions menu choose Instance Settings > Attach/Replace IAM Role.

    tmt_tts-for-wordpress_1_EC2_i

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_i

    j. In the next window, under IAM role field select PollyForWordPressRole role, which you have created before. Then click Apply.

    tmt_tts-for-wordpress_1_EC2_j

    (click to zoom)

    tmt_tts-for-wordpress_1_EC2_j
  • LightSail/Non-AWS Hosting

    In this step you will create an IAM user with special permissions, which will provide access to AWS services required for the plugin to work. The IAM user you create will receive AWS credentials, which are known as AWS Access Key and AWS Secret Key. You will use these keys in the plugin configuration page.

    a. Select Policies on the left-hand side and then Create Policy.

    tmt_tts-for-wordpress_1_LS_a

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_a

    b. On the Create Policy page select JSON tab in the table. Paste below code into the editor, and then select the Review policy button.

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Permissions1",
                "Effect": "Allow",
                "Action": [
                    "polly:SynthesizeSpeech",
                    "s3:HeadBucket",
                    "polly:DescribeVoices"
                ],
                "Resource": "*"
            },
            {
                "Sid": "Permissions2",
                "Effect": "Allow",
                "Action": [
                    "s3:ListBucket",
                    "s3:GetBucketAcl",
                    "s3:GetBucketPolicy",
                    "s3:PutObject",
                    "s3:DeleteObject",
                    "s3:CreateBucket",
                    "s3:PutObjectAcl"
                ],
                "Resource": "arn:aws:s3:::audio_for_wordpress*"
            }
        ]
    }
    tmt_tts-for-wordpress_1_LS_b

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_b

    c. On the Review policy page in Name field, type: PollyForWordPressPolicy and Create policy.

    tmt_tts-for-wordpress_1_LS_c

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_c

    d. On the left-hand side of the screen, select Users, and Add User.

    tmt_tts-for-wordpress_1_LS_d

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_d

    e. On the first step of the wizard, provide the name of the new IAM User: AmazonPollyForWordPress, select Programmatic access and move to the next step of the wizard.

    tmt_tts-for-wordpress_1_LS_e

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_e

    f. On the next step of the wizard you will need to select the policy which you have created in ‘Step 1-c’. Select Attach existing policies directly tab and from the list of policies choose PollyForWordPressPolicy.

    tmt_tts-for-wordpress_1_LS_f

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_f

    g. On the third step of the wizard review the changes, select Create User and move to the final step.



    tmt_tts-for-wordpress_1_LS_g

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_g

    h. On the last step of the wizard you will need to note down the IAM credentials for the new user. You can choose to Download .csv, or copy the Access Key Id and Secret Access Key manually. The information is required to configure the Amazon Polly for Wordpress plugin later.

     

    tmt_tts-for-wordpress_1_LS_h

    (click to zoom)

    tmt_tts-for-wordpress_1_LS_h

In this step, you will download and install the Amazon Polly plugin for WordPress.


a. Download the Amazon Polly plugin for WordPress directly from GitHub. To install the plugin on your WordPress server, open your WordPress admin page and log in.

tmt_tts-for-wordpress_2a

(click to zoom)

tmt_tts-for-wordpress_2a

b. Select Plugins on the left-hand side, and Add New.

tmt_tts-for-wordpress_2b

(click to zoom)

tmt_tts-for-wordpress_2b

c. On Add Plugins Page, select Upload Plugin, and Choose File. Choose the Amazon Polly plugin zip file which you have downloaded and select Install Now.

tmt_tts-for-wordpress_2c

(click to zoom)

tmt_tts-for-wordpress_2c

d. Select Activate Plugin to activate the plugin.

tmt_tts-for-wordpress_2d

(click to zoom)

tmt_tts-for-wordpress_2d

If you are hosting your WordPress site on EC2, use the EC2 instructions below.

If you are hosting your WordPress site on LightSail (or elsewhere outside of AWS), choose the LightSail instructions below.

  • EC2

    Congratulations, the plugin is installed! The plugin will work without additional configuration, but there are many useful settings. For example, you can select different Amazon Polly voices for the audio output, or enable podcast capabilities through Amazon Pollycast feeds. Let's see how to get to the plugin configuration page.

    Select Settings on the left-hand side and then Amazon Polly. You can modify the plugin configuration in this step, for example you could change the voice (Voice Name) which is used to create audio file. Notice that you don’t need to provide IAM credentials – it’s because you have attached IAM role to EC2 instance on which WordPress is installed.

    tmt_tts-for-wordpress_3_EC2_a

    (click to zoom)

    tmt_tts-for-wordpress_3_EC2_a
  • LightSail/Non-AWS Hosting

    Congratulations, the plugin is installed! The plugin will work without additional configuration but there are many useful settings. For example, you can select different Amazon Polly voices for the audio output, or enable podcast capabilities through Amazon Pollycast feeds. Let's see how to get to the plugin configuration page!

    a. Select Settings on the left-hand side and choose Amazon Polly. You will need to provide your AWS credentials, so that the plugin would have access to AWS services which it uses. In AWS Access Key and AWS Secret Key fields, enter the credentials which you downloaded in the .csv  in Step 1-j of this tutorial. Click on Save to the save the changes.

    tmt_tts-for-wordpress_3_LS_a

    (click to zoom)

    tmt_tts-for-wordpress_3_LS_a

    b. Now you should see that other settings are available, and you can change them. For example, under Polly Voice Name, you can choose from a wide selection of voices to articulate the audio content.

    tmt_tts-for-wordpress_3_LS_b

    (click to zoom)

    tmt_tts-for-wordpress_3_LS_b

At this stage, everything is done and your new web content will be made available to your readers in audio format. Now you can create a new blog post and see if you are able to hear the audio content.


a. Select Posts on the left-hand side and then Add New to open wizard for creating new post. Write your own blog post with title and content. Still on this same screen, click on the Enable Amazon Polly checkbox. And then select Publish to save the new post.

tmt_tts-for-wordpress_4a

(click to zoom)

tmt_tts-for-wordpress_4a

b. Open your WordPress site. You should now see a new post with an embedded player. Click the Play button and listen to the voiced article.  

Note: In addition to the HTML embedded player available on WordPress site, you can also enable podcast capabilities via the Amazon Pollycast feeds. These feeds are RSS 2.0 compliant and provide necessary XML data for aggregation by popular Podcast mobile applications and podcast directories such as iTunes. Read the AWS AI Blog for more details!

tmt_tts-for-wordpress_4b

(click to zoom)

tmt_tts-for-wordpress_4b

You can now easily voice your WordPress content with the Amazon Polly plugin. To do something a bit more dynamic, use the Amazon Polly API to access the full set of features such as custom pronunciation, lip-syncing and text highlighting. With dozens of natural sounding voices across a variety of languages, you can select the ideal voice and build speech-enabled applications that work in many different countries.

Now that you have tried Amazon Polly, pick one of the following options to further expand your knowledge.

Webpage

Visit Amazon Polly to find out more about the text-to-speech service.

Documentation

Read the developer guide for detailed instructions on using the various Amazon Polly features. 

AI Blog

Get the latest updates and customer stories related to Amazon Polly

Yes
No