PubNub Integration

Amazon Polly – Text-to-Speech

In-app chat

In-app chat

Bots & AI

Bots & AI

Chat & Social

Chat & Social

External APIs

External APIs

Last Updated:

2020/05/14

Author:

PubNub

APISign-upDocumentation

Turn text into lifelike speech using deep learning

Amazon Polly supports dozens of languages and a wide selection of natural-sounding male and female voices. When you send text to Amazon Polly's API, it returns the audio to your application as a stream so you can play the voices immediately. Amazon Polly also supports lexicons and SSML tags which enable you to control aspects of speech, such as pronunciation, volume, pitch, and speed rate,

Amazon Polly – Text-to-Speech

Walkthrough:

Begin by adding the AWS keys to the vault storage by using the MY SECRETS feature from within the blocks editor. The block will need the AWS_access_key and AWS_secret_key values.

This PubNub Functions listens for all chats and allows to get audio from text in private chats.

To trigger text-to-speech conversion, event payload should contain 'polly' field in it with following keys:

  • location - name of key in event payload, which contain data for polly

  • voice - identifier of voice which should be used to read text. By default set to: 'Joanna'

  • format - generated audio file format. By default set to: 'mp3'

Input:

{
    "data": {
        "text": "hello!",
        "polly": {
            "voice": "Joanna",
            "format": "mp3",
            "location": "text"
        }
    }
}

Output:

{
    "body": "{
        \"text\":\"hello!\",
        \"polly\":{
            \"voice\":\"Joanna\",
            \"format\":\"mp3\",
            \"location\":\"text\"
        },
        \"polly_sound\":\"base64encodedStringHere\"
    }",
    "status": 200,
    "headers": {
        "content-type": "application/json; charset=utf-8"
    }
}

Feedback & Support

Need help? Contact PubNub Support.

More integrations for you

Amazon Comprehend - Discover insights and relationships in text

    Amazon Comprehend - Discover insights and relationships in text

    Use natural language processing (NLP) to find insights and relationships in...

    Learn more
    Amazon Translate – Natural and fluent language translation

      Amazon Translate – Natural and fluent language translation

      Fast, high-quality, and affordable neural machine translation service

      Learn more

      Talk to an expert

      Contact Sales