Tag: Amazon Polly

Yesterday at Amazon re:Invent 2016 event a new machine learning service has been presented and made globally available: Polly.Amazon Polly is a service that turns text into lifelike speech. Polly lets you create applications that talk, enabling you to build entirely new categories of speech-enabled products. Polly is an Amazon AI service that uses advanced deep learning technologies to synthesize speech that sounds like a human voice. Right now Polly supports 24 languages across 47 different lifelike voices.

The service allows you to create new content for the users and enables new Internet of Things (IoT) use cases by making it easy and inexpensive to add speech to IoT devices.
You can find a set of use cases here: Amazon Polly

You can interact with Polly using the official Boto 3 Python SDK. In case you have an older version of the SDK, you should update it using pip3 –upgrade.

1

pip3 install boto3--upgrade

First, create a new Polly client service instance:

1

2

3

4

5

6

7

8

import boto3

polly_service=boto3.client(

'polly',

aws_access_key_id='YOUR_AWS_ACCESS_KEY',

aws_secret_access_key='YOUR_AWS_SECRET_ACCESS_KEY',

region_name='eu-west-1'

)

To get the list of the available voices, you can use the describe_voices method. You have to specify the language code (e.g.: en-GB, en-US, it-IT) to get the voices Ids and descriptions.

1

2

3

4

5

6

r_voices=polly_service.describe_voices(

LanguageCode='en-GB'

)

forvoice inr_voices['Voices']:

print(voice)

print(voice['Id'])

To synthesize a new text, use the method synthesize_speech. You need to specify the text, the output format and the Voice you want to use (by specifying the Id).

1

2

3

4

5

6

7

my_text='Hello, this is a demo'

polly_response=polly_service.synthesize_speech(

OutputFormat='mp3',

Text=my_text,

TextType='text',

VoiceId='Emma'# English - British female voice

)

Once we have the synthesized text, we can store the stream to a mp3 file.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. If you want to know more or withdraw your consent to all or some of the cookies, please refer to the coockie policy. Got it!Reject.