SDK for PHP 3.x

Client: Aws\Polly\PollyClient
Service ID: polly
Version: 2016-06-10

This page describes the parameters and results for the operations of the Amazon Polly (2016-06-10), and shows how to use the Aws\Polly\PollyClient object to call the described operations. This documentation is specific to the 2016-06-10 API version of the service.

Operation Summary

Each of the following operations can be created from a client using $client->getCommand('CommandName'), where "CommandName" is the name of one of the following operations. Note: a command is a value that encapsulates an operation and the parameters used to create an HTTP request.

You can also create and send a command immediately using the magic methods available on a client object: $client->commandName(/* parameters */). You can send the command asynchronously (returning a promise) by appending the word "Async" to the operation name: $client->commandNameAsync(/* parameters */).

DeleteLexicon ( array $params = [] )
Deletes the specified pronunciation lexicon stored in an Amazon Web Services Region.
DescribeVoices ( array $params = [] )
Returns the list of voices that are available for use when requesting speech synthesis.
GetLexicon ( array $params = [] )
Returns the content of the specified pronunciation lexicon stored in an Amazon Web Services Region.
GetSpeechSynthesisTask ( array $params = [] )
Retrieves a specific SpeechSynthesisTask object based on its TaskID.
ListLexicons ( array $params = [] )
Returns a list of pronunciation lexicons stored in an Amazon Web Services Region.
ListSpeechSynthesisTasks ( array $params = [] )
Returns a list of SpeechSynthesisTask objects ordered by their creation date.
PutLexicon ( array $params = [] )
Stores a pronunciation lexicon in an Amazon Web Services Region.
StartSpeechSynthesisTask ( array $params = [] )
Allows the creation of an asynchronous synthesis task, by starting a new SpeechSynthesisTask.
SynthesizeSpeech ( array $params = [] )
Synthesizes UTF-8 input, plain text or SSML, to a stream of bytes.

Paginators

Paginators handle automatically iterating over paginated API results. Paginators are associated with specific API operations, and they accept the parameters that the corresponding API operation accepts. You can get a paginator from a client class using getPaginator($paginatorName, $operationParameters). This client supports the following paginators:

ListSpeechSynthesisTasks

Operations

DeleteLexicon

$result = $client->deleteLexicon([/* ... */]);
$promise = $client->deleteLexiconAsync([/* ... */]);

Deletes the specified pronunciation lexicon stored in an Amazon Web Services Region. A lexicon which has been deleted is not available for speech synthesis, nor is it possible to retrieve it using either the GetLexicon or ListLexicon APIs.

For more information, see Managing Lexicons.

Parameter Syntax

$result = $client->deleteLexicon([
    'Name' => '<string>', // REQUIRED
]);

Parameter Details

Members
Name
Required: Yes
Type: string

The name of the lexicon to delete. Must be an existing lexicon in the region.

Result Syntax

[]

Result Details

The results for this operation are always empty.

Errors

LexiconNotFoundException:

Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.

Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

Examples

Example 1: To delete a lexicon

Deletes a specified pronunciation lexicon stored in an AWS Region.

$result = $client->deleteLexicon([
    'Name' => 'example',
]);

Result syntax:

[
]

DescribeVoices

$result = $client->describeVoices([/* ... */]);
$promise = $client->describeVoicesAsync([/* ... */]);

Returns the list of voices that are available for use when requesting speech synthesis. Each voice speaks a specified language, is either male or female, and is identified by an ID, which is the ASCII version of the voice name.

When synthesizing speech ( SynthesizeSpeech ), you provide the voice ID for the voice you want from the list of voices returned by DescribeVoices.

For example, you want your news reader application to read news in a specific language, but giving a user the option to choose the voice. Using the DescribeVoices operation you can provide the user with a list of available voices to select from.

You can optionally specify a language code to filter the available voices. For example, if you specify en-US, the operation returns a list of all available US English voices.

This operation requires permissions to perform the polly:DescribeVoices action.

Parameter Syntax

$result = $client->describeVoices([
    'Engine' => 'standard|neural|long-form|generative',
    'IncludeAdditionalLanguageCodes' => true || false,
    'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
    'NextToken' => '<string>',
]);

Parameter Details

Members
Engine
Type: string

Specifies the engine (standard, neural, long-form or generative) used by Amazon Polly when processing input text for speech synthesis.

IncludeAdditionalLanguageCodes
Type: boolean

Boolean value indicating whether to return any bilingual voices that use the specified language as an additional language. For instance, if you request all languages that use US English (es-US), and there is an Italian voice that speaks both Italian (it-IT) and US English, that voice will be included if you specify yes but not if you specify no.

LanguageCode
Type: string

The language identification tag (ISO 639 code for the language name-ISO 3166 country code) for filtering the list of voices returned. If you don't specify this optional parameter, all available voices are returned.

NextToken
Type: string

An opaque pagination token returned from the previous DescribeVoices operation. If present, this indicates where to continue the listing.

Result Syntax

[
    'NextToken' => '<string>',
    'Voices' => [
        [
            'AdditionalLanguageCodes' => ['<string>', ...],
            'Gender' => 'Female|Male',
            'Id' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu',
            'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
            'LanguageName' => '<string>',
            'Name' => '<string>',
            'SupportedEngines' => ['<string>', ...],
        ],
        // ...
    ],
]

Result Details

Members
NextToken
Type: string

The pagination token to use in the next request to continue the listing of voices. NextToken is returned only if the response is truncated.

Voices
Type: Array of Voice structures

A list of voices with their properties.

Errors

InvalidNextTokenException:

The NextToken is invalid. Verify that it's spelled correctly, and then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

Examples

Example 1: To describe available voices

Returns the list of voices that are available for use when requesting speech synthesis. Displayed languages are those within the specified language code. If no language code is specified, voices for all available languages are displayed.

$result = $client->describeVoices([
    'LanguageCode' => 'en-GB',
]);

Result syntax:

[
    'Voices' => [
        [
            'Gender' => 'Female',
            'Id' => 'Emma',
            'LanguageCode' => 'en-GB',
            'LanguageName' => 'British English',
            'Name' => 'Emma',
        ],
        [
            'Gender' => 'Male',
            'Id' => 'Brian',
            'LanguageCode' => 'en-GB',
            'LanguageName' => 'British English',
            'Name' => 'Brian',
        ],
        [
            'Gender' => 'Female',
            'Id' => 'Amy',
            'LanguageCode' => 'en-GB',
            'LanguageName' => 'British English',
            'Name' => 'Amy',
        ],
    ],
]

GetLexicon

$result = $client->getLexicon([/* ... */]);
$promise = $client->getLexiconAsync([/* ... */]);

Returns the content of the specified pronunciation lexicon stored in an Amazon Web Services Region. For more information, see Managing Lexicons.

Parameter Syntax

$result = $client->getLexicon([
    'Name' => '<string>', // REQUIRED
]);

Parameter Details

Members
Name
Required: Yes
Type: string

Name of the lexicon.

Result Syntax

[
    'Lexicon' => [
        'Content' => '<string>',
        'Name' => '<string>',
    ],
    'LexiconAttributes' => [
        'Alphabet' => '<string>',
        'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
        'LastModified' => <DateTime>,
        'LexemesCount' => <integer>,
        'LexiconArn' => '<string>',
        'Size' => <integer>,
    ],
]

Result Details

Members
Lexicon
Type: Lexicon structure

Lexicon object that provides name and the string content of the lexicon.

LexiconAttributes
Type: LexiconAttributes structure

Metadata of the lexicon, including phonetic alphabetic used, language code, lexicon ARN, number of lexemes defined in the lexicon, and size of lexicon in bytes.

Errors

LexiconNotFoundException:

Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.

Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

Examples

Example 1: To retrieve a lexicon

Returns the content of the specified pronunciation lexicon stored in an AWS Region.

$result = $client->getLexicon([
    'Name' => '',
]);

Result syntax:

[
    'Lexicon' => [
        'Content' => '  W3C World Wide Web Consortium ',
        'Name' => 'example',
    ],
    'LexiconAttributes' => [
        'Alphabet' => 'ipa',
        'LanguageCode' => 'en-US',
        'LastModified' => ,
        'LexemesCount' => 1,
        'LexiconArn' => 'arn:aws:polly:us-east-1:123456789012:lexicon/example',
        'Size' => 503,
    ],
]

GetSpeechSynthesisTask

$result = $client->getSpeechSynthesisTask([/* ... */]);
$promise = $client->getSpeechSynthesisTaskAsync([/* ... */]);

Retrieves a specific SpeechSynthesisTask object based on its TaskID. This object contains information about the given speech synthesis task, including the status of the task, and a link to the S3 bucket containing the output of the task.

Parameter Syntax

$result = $client->getSpeechSynthesisTask([
    'TaskId' => '<string>', // REQUIRED
]);

Parameter Details

Members
TaskId
Required: Yes
Type: string

The Amazon Polly generated identifier for a speech synthesis task.

Result Syntax

[
    'SynthesisTask' => [
        'CreationTime' => <DateTime>,
        'Engine' => 'standard|neural|long-form|generative',
        'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
        'LexiconNames' => ['<string>', ...],
        'OutputFormat' => 'json|mp3|ogg_vorbis|pcm',
        'OutputUri' => '<string>',
        'RequestCharacters' => <integer>,
        'SampleRate' => '<string>',
        'SnsTopicArn' => '<string>',
        'SpeechMarkTypes' => ['<string>', ...],
        'TaskId' => '<string>',
        'TaskStatus' => 'scheduled|inProgress|completed|failed',
        'TaskStatusReason' => '<string>',
        'TextType' => 'ssml|text',
        'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu',
    ],
]

Result Details

Members
SynthesisTask
Type: SynthesisTask structure

SynthesisTask object that provides information from the requested task, including output format, creation time, task status, and so on.

Errors

InvalidTaskIdException:

The provided Task ID is not valid. Please provide a valid Task ID and try again.

ServiceFailureException:

An unknown condition has caused a service failure.

SynthesisTaskNotFoundException:

The Speech Synthesis task with requested Task ID cannot be found.

ListLexicons

$result = $client->listLexicons([/* ... */]);
$promise = $client->listLexiconsAsync([/* ... */]);

Returns a list of pronunciation lexicons stored in an Amazon Web Services Region. For more information, see Managing Lexicons.

Parameter Syntax

$result = $client->listLexicons([
    'NextToken' => '<string>',
]);

Parameter Details

Members
NextToken
Type: string

An opaque pagination token returned from previous ListLexicons operation. If present, indicates where to continue the list of lexicons.

Result Syntax

[
    'Lexicons' => [
        [
            'Attributes' => [
                'Alphabet' => '<string>',
                'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
                'LastModified' => <DateTime>,
                'LexemesCount' => <integer>,
                'LexiconArn' => '<string>',
                'Size' => <integer>,
            ],
            'Name' => '<string>',
        ],
        // ...
    ],
    'NextToken' => '<string>',
]

Result Details

Members
Lexicons
Type: Array of LexiconDescription structures

A list of lexicon names and attributes.

NextToken
Type: string

The pagination token to use in the next request to continue the listing of lexicons. NextToken is returned only if the response is truncated.

Errors

InvalidNextTokenException:

The NextToken is invalid. Verify that it's spelled correctly, and then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

Examples

Example 1: To list all lexicons in a region

Returns a list of pronunciation lexicons stored in an AWS Region.

$result = $client->listLexicons([
]);

Result syntax:

[
    'Lexicons' => [
        [
            'Attributes' => [
                'Alphabet' => 'ipa',
                'LanguageCode' => 'en-US',
                'LastModified' => ,
                'LexemesCount' => 1,
                'LexiconArn' => 'arn:aws:polly:us-east-1:123456789012:lexicon/example',
                'Size' => 503,
            ],
            'Name' => 'example',
        ],
    ],
]

ListSpeechSynthesisTasks

$result = $client->listSpeechSynthesisTasks([/* ... */]);
$promise = $client->listSpeechSynthesisTasksAsync([/* ... */]);

Returns a list of SpeechSynthesisTask objects ordered by their creation date. This operation can filter the tasks by their status, for example, allowing users to list only tasks that are completed.

Parameter Syntax

$result = $client->listSpeechSynthesisTasks([
    'MaxResults' => <integer>,
    'NextToken' => '<string>',
    'Status' => 'scheduled|inProgress|completed|failed',
]);

Parameter Details

Members
MaxResults
Type: int

Maximum number of speech synthesis tasks returned in a List operation.

NextToken
Type: string

The pagination token to use in the next request to continue the listing of speech synthesis tasks.

Status
Type: string

Status of the speech synthesis tasks returned in a List operation

Result Syntax

[
    'NextToken' => '<string>',
    'SynthesisTasks' => [
        [
            'CreationTime' => <DateTime>,
            'Engine' => 'standard|neural|long-form|generative',
            'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
            'LexiconNames' => ['<string>', ...],
            'OutputFormat' => 'json|mp3|ogg_vorbis|pcm',
            'OutputUri' => '<string>',
            'RequestCharacters' => <integer>,
            'SampleRate' => '<string>',
            'SnsTopicArn' => '<string>',
            'SpeechMarkTypes' => ['<string>', ...],
            'TaskId' => '<string>',
            'TaskStatus' => 'scheduled|inProgress|completed|failed',
            'TaskStatusReason' => '<string>',
            'TextType' => 'ssml|text',
            'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu',
        ],
        // ...
    ],
]

Result Details

Members
NextToken
Type: string

An opaque pagination token returned from the previous List operation in this request. If present, this indicates where to continue the listing.

SynthesisTasks
Type: Array of SynthesisTask structures

List of SynthesisTask objects that provides information from the specified task in the list request, including output format, creation time, task status, and so on.

Errors

InvalidNextTokenException:

The NextToken is invalid. Verify that it's spelled correctly, and then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

PutLexicon

$result = $client->putLexicon([/* ... */]);
$promise = $client->putLexiconAsync([/* ... */]);

Stores a pronunciation lexicon in an Amazon Web Services Region. If a lexicon with the same name already exists in the region, it is overwritten by the new lexicon. Lexicon operations have eventual consistency, therefore, it might take some time before the lexicon is available to the SynthesizeSpeech operation.

For more information, see Managing Lexicons.

Parameter Syntax

$result = $client->putLexicon([
    'Content' => '<string>', // REQUIRED
    'Name' => '<string>', // REQUIRED
]);

Parameter Details

Members
Content
Required: Yes
Type: string

Content of the PLS lexicon as string data.

Name
Required: Yes
Type: string

Name of the lexicon. The name must follow the regular express format [0-9A-Za-z]{1,20}. That is, the name is a case-sensitive alphanumeric string up to 20 characters long.

Result Syntax

[]

Result Details

The results for this operation are always empty.

Errors

InvalidLexiconException:

Amazon Polly can't find the specified lexicon. Verify that the lexicon's name is spelled correctly, and then try again.

UnsupportedPlsAlphabetException:

The alphabet specified by the lexicon is not a supported alphabet. Valid values are x-sampa and ipa.

UnsupportedPlsLanguageException:

The language specified in the lexicon is unsupported. For a list of supported languages, see Lexicon Attributes.

LexiconSizeExceededException:

The maximum size of the specified lexicon would be exceeded by this operation.

MaxLexemeLengthExceededException:

The maximum size of the lexeme would be exceeded by this operation.

MaxLexiconsNumberExceededException:

The maximum number of lexicons would be exceeded by this operation.

ServiceFailureException:

An unknown condition has caused a service failure.

Examples

Example 1: To save a lexicon

Stores a pronunciation lexicon in an AWS Region.

$result = $client->putLexicon([
    'Content' => 'file://example.pls',
    'Name' => 'W3C',
]);

Result syntax:

[
]

StartSpeechSynthesisTask

$result = $client->startSpeechSynthesisTask([/* ... */]);
$promise = $client->startSpeechSynthesisTaskAsync([/* ... */]);

Allows the creation of an asynchronous synthesis task, by starting a new SpeechSynthesisTask. This operation requires all the standard information needed for speech synthesis, plus the name of an Amazon S3 bucket for the service to store the output of the synthesis task and two optional parameters (OutputS3KeyPrefix and SnsTopicArn). Once the synthesis task is created, this operation will return a SpeechSynthesisTask object, which will include an identifier of this task as well as the current status. The SpeechSynthesisTask object is available for 72 hours after starting the asynchronous synthesis task.

Parameter Syntax

$result = $client->startSpeechSynthesisTask([
    'Engine' => 'standard|neural|long-form|generative',
    'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
    'LexiconNames' => ['<string>', ...],
    'OutputFormat' => 'json|mp3|ogg_vorbis|pcm', // REQUIRED
    'OutputS3BucketName' => '<string>', // REQUIRED
    'OutputS3KeyPrefix' => '<string>',
    'SampleRate' => '<string>',
    'SnsTopicArn' => '<string>',
    'SpeechMarkTypes' => ['<string>', ...],
    'Text' => '<string>', // REQUIRED
    'TextType' => 'ssml|text',
    'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu', // REQUIRED
]);

Parameter Details

Members
Engine
Type: string

Specifies the engine (standard, neural, long-form or generative) for Amazon Polly to use when processing input text for speech synthesis. Using a voice that is not supported for the engine selected will result in an error.

LanguageCode
Type: string

Optional language code for the Speech Synthesis request. This is only necessary if using a bilingual voice, such as Aditi, which can be used for either Indian English (en-IN) or Hindi (hi-IN).

If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice. The default language for any voice is the one returned by the DescribeVoices operation for the LanguageCode parameter. For example, if no language code is specified, Aditi will use Indian English rather than Hindi.

LexiconNames
Type: Array of strings

List of one or more pronunciation lexicon names you want the service to apply during synthesis. Lexicons are applied only if the language of the lexicon is the same as the language of the voice.

OutputFormat
Required: Yes
Type: string

The format in which the returned output will be encoded. For audio stream, this will be mp3, ogg_vorbis, or pcm. For speech marks, this will be json.

OutputS3BucketName
Required: Yes
Type: string

Amazon S3 bucket name to which the output file will be saved.

OutputS3KeyPrefix
Type: string

The Amazon S3 key prefix for the output speech file.

SampleRate
Type: string

The audio frequency specified in Hz.

The valid values for mp3 and ogg_vorbis are "8000", "16000", "22050", and "24000". The default value for standard voices is "22050". The default value for neural voices is "24000". The default value for long-form voices is "24000". The default value for generative voices is "24000".

Valid values for pcm are "8000" and "16000" The default value is "16000".

SnsTopicArn
Type: string

ARN for the SNS topic optionally used for providing status notification for a speech synthesis task.

SpeechMarkTypes
Type: Array of strings

The type of speech marks returned for the input text.

Text
Required: Yes
Type: string

The input text to synthesize. If you specify ssml as the TextType, follow the SSML format for the input text.

TextType
Type: string

Specifies whether the input text is plain text or SSML. The default value is plain text.

VoiceId
Required: Yes
Type: string

Voice ID to use for the synthesis.

Result Syntax

[
    'SynthesisTask' => [
        'CreationTime' => <DateTime>,
        'Engine' => 'standard|neural|long-form|generative',
        'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
        'LexiconNames' => ['<string>', ...],
        'OutputFormat' => 'json|mp3|ogg_vorbis|pcm',
        'OutputUri' => '<string>',
        'RequestCharacters' => <integer>,
        'SampleRate' => '<string>',
        'SnsTopicArn' => '<string>',
        'SpeechMarkTypes' => ['<string>', ...],
        'TaskId' => '<string>',
        'TaskStatus' => 'scheduled|inProgress|completed|failed',
        'TaskStatusReason' => '<string>',
        'TextType' => 'ssml|text',
        'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu',
    ],
]

Result Details

Members
SynthesisTask
Type: SynthesisTask structure

SynthesisTask object that provides information and attributes about a newly submitted speech synthesis task.

Errors

TextLengthExceededException:

The value of the "Text" parameter is longer than the accepted limits. For the SynthesizeSpeech API, the limit for input text is a maximum of 6000 characters total, of which no more than 3000 can be billed characters. For the StartSpeechSynthesisTask API, the maximum is 200,000 characters, of which no more than 100,000 can be billed characters. SSML tags are not counted as billed characters.

InvalidS3BucketException:

The provided Amazon S3 bucket name is invalid. Please check your input with S3 bucket naming requirements and try again.

InvalidS3KeyException:

The provided Amazon S3 key prefix is invalid. Please provide a valid S3 object key name.

InvalidSampleRateException:

The specified sample rate is not valid.

InvalidSnsTopicArnException:

The provided SNS topic ARN is invalid. Please provide a valid SNS topic ARN and try again.

InvalidSsmlException:

The SSML you provided is invalid. Verify the SSML syntax, spelling of tags and values, and then try again.

EngineNotSupportedException:

This engine is not compatible with the voice that you have designated. Choose a new voice that is compatible with the engine or change the engine and restart the operation.

LexiconNotFoundException:

Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.

Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

MarksNotSupportedForFormatException:

Speech marks are not supported for the OutputFormat selected. Speech marks are only available for content in json format.

SsmlMarksNotSupportedForTextTypeException:

SSML speech marks are not supported for plain text-type input.

LanguageNotSupportedException:

The language specified is not currently supported by Amazon Polly in this capacity.

SynthesizeSpeech

$result = $client->synthesizeSpeech([/* ... */]);
$promise = $client->synthesizeSpeechAsync([/* ... */]);

Synthesizes UTF-8 input, plain text or SSML, to a stream of bytes. SSML input must be valid, well-formed SSML. Some alphabets might not be available with all the voices (for example, Cyrillic might not be read at all by English voices) unless phoneme mapping is used. For more information, see How it Works.

Parameter Syntax

$result = $client->synthesizeSpeech([
    'Engine' => 'standard|neural|long-form|generative',
    'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR|en-NZ|en-ZA|ca-ES|de-AT|yue-CN|ar-AE|fi-FI|en-IE|nl-BE|fr-BE',
    'LexiconNames' => ['<string>', ...],
    'OutputFormat' => 'json|mp3|ogg_vorbis|pcm', // REQUIRED
    'SampleRate' => '<string>',
    'SpeechMarkTypes' => ['<string>', ...],
    'Text' => '<string>', // REQUIRED
    'TextType' => 'ssml|text',
    'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Camila|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Gabrielle|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kevin|Kimberly|Lea|Liv|Lotte|Lucia|Lupe|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Olivia|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu|Aria|Ayanda|Arlet|Hannah|Arthur|Daniel|Liam|Pedro|Kajal|Hiujin|Laura|Elin|Ida|Suvi|Ola|Hala|Andres|Sergio|Remi|Adriano|Thiago|Ruth|Stephen|Kazuha|Tomoko|Niamh|Sofie|Lisa|Isabelle|Zayd|Danielle|Gregory|Burcu', // REQUIRED
]);

Parameter Details

Members
Engine
Type: string

Specifies the engine (standard, neural, long-form, or generative) for Amazon Polly to use when processing input text for speech synthesis. Provide an engine that is supported by the voice you select. If you don't provide an engine, the standard engine is selected by default. If a chosen voice isn't supported by the standard engine, this will result in an error. For information on Amazon Polly voices and which voices are available for each engine, see Available Voices.

Type: String

Valid Values: standard | neural | long-form | generative

Required: Yes

LanguageCode
Type: string

Optional language code for the Synthesize Speech request. This is only necessary if using a bilingual voice, such as Aditi, which can be used for either Indian English (en-IN) or Hindi (hi-IN).

If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice. The default language for any voice is the one returned by the DescribeVoices operation for the LanguageCode parameter. For example, if no language code is specified, Aditi will use Indian English rather than Hindi.

LexiconNames
Type: Array of strings

List of one or more pronunciation lexicon names you want the service to apply during synthesis. Lexicons are applied only if the language of the lexicon is the same as the language of the voice. For information about storing lexicons, see PutLexicon.

OutputFormat
Required: Yes
Type: string

The format in which the returned output will be encoded. For audio stream, this will be mp3, ogg_vorbis, or pcm. For speech marks, this will be json.

When pcm is used, the content returned is audio/pcm in a signed 16-bit, 1 channel (mono), little-endian format.

SampleRate
Type: string

The audio frequency specified in Hz.

The valid values for mp3 and ogg_vorbis are "8000", "16000", "22050", and "24000". The default value for standard voices is "22050". The default value for neural voices is "24000". The default value for long-form voices is "24000". The default value for generative voices is "24000".

Valid values for pcm are "8000" and "16000" The default value is "16000".

SpeechMarkTypes
Type: Array of strings

The type of speech marks returned for the input text.

Text
Required: Yes
Type: string

Input text to synthesize. If you specify ssml as the TextType, follow the SSML format for the input text.

TextType
Type: string

Specifies whether the input text is plain text or SSML. The default value is plain text. For more information, see Using SSML.

VoiceId
Required: Yes
Type: string

Voice ID to use for the synthesis. You can get a list of available voice IDs by calling the DescribeVoices operation.

Result Syntax

[
    'AudioStream' => <string || resource || Psr\Http\Message\StreamInterface>,
    'ContentType' => '<string>',
    'RequestCharacters' => <integer>,
]

Result Details

Members
AudioStream
Type: blob (string|resource|Psr\Http\Message\StreamInterface)

Stream containing the synthesized speech.

ContentType
Type: string

Specifies the type audio stream. This should reflect the OutputFormat parameter in your request.

  • If you request mp3 as the OutputFormat, the ContentType returned is audio/mpeg.

  • If you request ogg_vorbis as the OutputFormat, the ContentType returned is audio/ogg.

  • If you request pcm as the OutputFormat, the ContentType returned is audio/pcm in a signed 16-bit, 1 channel (mono), little-endian format.

  • If you request json as the OutputFormat, the ContentType returned is application/x-json-stream.

RequestCharacters
Type: int

Number of characters synthesized.

Errors

TextLengthExceededException:

The value of the "Text" parameter is longer than the accepted limits. For the SynthesizeSpeech API, the limit for input text is a maximum of 6000 characters total, of which no more than 3000 can be billed characters. For the StartSpeechSynthesisTask API, the maximum is 200,000 characters, of which no more than 100,000 can be billed characters. SSML tags are not counted as billed characters.

InvalidSampleRateException:

The specified sample rate is not valid.

InvalidSsmlException:

The SSML you provided is invalid. Verify the SSML syntax, spelling of tags and values, and then try again.

LexiconNotFoundException:

Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.

Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.

ServiceFailureException:

An unknown condition has caused a service failure.

MarksNotSupportedForFormatException:

Speech marks are not supported for the OutputFormat selected. Speech marks are only available for content in json format.

SsmlMarksNotSupportedForTextTypeException:

SSML speech marks are not supported for plain text-type input.

LanguageNotSupportedException:

The language specified is not currently supported by Amazon Polly in this capacity.

EngineNotSupportedException:

This engine is not compatible with the voice that you have designated. Choose a new voice that is compatible with the engine or change the engine and restart the operation.

Examples

Example 1: To synthesize speech

Synthesizes plain text or SSML into a file of human-like speech.

$result = $client->synthesizeSpeech([
    'LexiconNames' => [
        'example',
    ],
    'OutputFormat' => 'mp3',
    'SampleRate' => '8000',
    'Text' => 'All Gaul is divided into three parts',
    'TextType' => 'text',
    'VoiceId' => 'Joanna',
]);

Result syntax:

[
    'AudioStream' => <BLOB>,
    'ContentType' => 'audio/mpeg',
    'RequestCharacters' => 37,
]

Shapes

EngineNotSupportedException

Description

This engine is not compatible with the voice that you have designated. Choose a new voice that is compatible with the engine or change the engine and restart the operation.

Members
message
Type: string

InvalidLexiconException

Description

Amazon Polly can't find the specified lexicon. Verify that the lexicon's name is spelled correctly, and then try again.

Members
message
Type: string

InvalidNextTokenException

Description

The NextToken is invalid. Verify that it's spelled correctly, and then try again.

Members
message
Type: string

InvalidS3BucketException

Description

The provided Amazon S3 bucket name is invalid. Please check your input with S3 bucket naming requirements and try again.

Members
message
Type: string

InvalidS3KeyException

Description

The provided Amazon S3 key prefix is invalid. Please provide a valid S3 object key name.

Members
message
Type: string

InvalidSampleRateException

Description

The specified sample rate is not valid.

Members
message
Type: string

InvalidSnsTopicArnException

Description

The provided SNS topic ARN is invalid. Please provide a valid SNS topic ARN and try again.

Members
message
Type: string

InvalidSsmlException

Description

The SSML you provided is invalid. Verify the SSML syntax, spelling of tags and values, and then try again.

Members
message
Type: string

InvalidTaskIdException

Description

The provided Task ID is not valid. Please provide a valid Task ID and try again.

Members
message
Type: string

LanguageNotSupportedException

Description

The language specified is not currently supported by Amazon Polly in this capacity.

Members
message
Type: string

Lexicon

Description

Provides lexicon name and lexicon content in string format. For more information, see Pronunciation Lexicon Specification (PLS) Version 1.0.

Members
Content
Type: string

Lexicon content in string format. The content of a lexicon must be in PLS format.

Name
Type: string

Name of the lexicon.

LexiconAttributes

Description

Contains metadata describing the lexicon such as the number of lexemes, language code, and so on. For more information, see Managing Lexicons.

Members
Alphabet
Type: string

Phonetic alphabet used in the lexicon. Valid values are ipa and x-sampa.

LanguageCode
Type: string

Language code that the lexicon applies to. A lexicon with a language code such as "en" would be applied to all English languages (en-GB, en-US, en-AUS, en-WLS, and so on.

LastModified
Type: timestamp (string|DateTime or anything parsable by strtotime)

Date lexicon was last modified (a timestamp value).

LexemesCount
Type: int

Number of lexemes in the lexicon.

LexiconArn
Type: string

Amazon Resource Name (ARN) of the lexicon.

Size
Type: int

Total size of the lexicon, in characters.

LexiconDescription

Description

Describes the content of the lexicon.

Members
Attributes
Type: LexiconAttributes structure

Provides lexicon metadata.

Name
Type: string

Name of the lexicon.

LexiconNotFoundException

Description

Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.

Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.

Members
message
Type: string

LexiconSizeExceededException

Description

The maximum size of the specified lexicon would be exceeded by this operation.

Members
message
Type: string

MarksNotSupportedForFormatException

Description

Speech marks are not supported for the OutputFormat selected. Speech marks are only available for content in json format.

Members
message
Type: string

MaxLexemeLengthExceededException

Description

The maximum size of the lexeme would be exceeded by this operation.

Members
message
Type: string

MaxLexiconsNumberExceededException

Description

The maximum number of lexicons would be exceeded by this operation.

Members
message
Type: string

ServiceFailureException

Description

An unknown condition has caused a service failure.

Members
message
Type: string

SsmlMarksNotSupportedForTextTypeException

Description

SSML speech marks are not supported for plain text-type input.

Members
message
Type: string

SynthesisTask

Description

SynthesisTask object that provides information about a speech synthesis task.

Members
CreationTime
Type: timestamp (string|DateTime or anything parsable by strtotime)

Timestamp for the time the synthesis task was started.

Engine
Type: string

Specifies the engine (standard, neural, long-form or generative) for Amazon Polly to use when processing input text for speech synthesis. Using a voice that is not supported for the engine selected will result in an error.

LanguageCode
Type: string

Optional language code for a synthesis task. This is only necessary if using a bilingual voice, such as Aditi, which can be used for either Indian English (en-IN) or Hindi (hi-IN).

If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice. The default language for any voice is the one returned by the DescribeVoices operation for the LanguageCode parameter. For example, if no language code is specified, Aditi will use Indian English rather than Hindi.

LexiconNames
Type: Array of strings

List of one or more pronunciation lexicon names you want the service to apply during synthesis. Lexicons are applied only if the language of the lexicon is the same as the language of the voice.

OutputFormat
Type: string

The format in which the returned output will be encoded. For audio stream, this will be mp3, ogg_vorbis, or pcm. For speech marks, this will be json.

OutputUri
Type: string

Pathway for the output speech file.

RequestCharacters
Type: int

Number of billable characters synthesized.

SampleRate
Type: string

The audio frequency specified in Hz.

The valid values for mp3 and ogg_vorbis are "8000", "16000", "22050", and "24000". The default value for standard voices is "22050". The default value for neural voices is "24000". The default value for long-form voices is "24000". The default value for generative voices is "24000".

Valid values for pcm are "8000" and "16000" The default value is "16000".

SnsTopicArn
Type: string

ARN for the SNS topic optionally used for providing status notification for a speech synthesis task.

SpeechMarkTypes
Type: Array of strings

The type of speech marks returned for the input text.

TaskId
Type: string

The Amazon Polly generated identifier for a speech synthesis task.

TaskStatus
Type: string

Current status of the individual speech synthesis task.

TaskStatusReason
Type: string

Reason for the current status of a specific speech synthesis task, including errors if the task has failed.

TextType
Type: string

Specifies whether the input text is plain text or SSML. The default value is plain text.

VoiceId
Type: string

Voice ID to use for the synthesis.

SynthesisTaskNotFoundException

Description

The Speech Synthesis task with requested Task ID cannot be found.

Members
message
Type: string

TextLengthExceededException

Description

The value of the "Text" parameter is longer than the accepted limits. For the SynthesizeSpeech API, the limit for input text is a maximum of 6000 characters total, of which no more than 3000 can be billed characters. For the StartSpeechSynthesisTask API, the maximum is 200,000 characters, of which no more than 100,000 can be billed characters. SSML tags are not counted as billed characters.

Members
message
Type: string

UnsupportedPlsAlphabetException

Description

The alphabet specified by the lexicon is not a supported alphabet. Valid values are x-sampa and ipa.

Members
message
Type: string

UnsupportedPlsLanguageException

Description

The language specified in the lexicon is unsupported. For a list of supported languages, see Lexicon Attributes.

Members
message
Type: string

Voice

Description

Description of the voice.

Members
AdditionalLanguageCodes
Type: Array of strings

Additional codes for languages available for the specified voice in addition to its default language.

For example, the default language for Aditi is Indian English (en-IN) because it was first used for that language. Since Aditi is bilingual and fluent in both Indian English and Hindi, this parameter would show the code hi-IN.

Gender
Type: string

Gender of the voice.

Id
Type: string

Amazon Polly assigned voice ID. This is the ID that you specify when calling the SynthesizeSpeech operation.

LanguageCode
Type: string

Language code of the voice.

LanguageName
Type: string

Human readable name of the language in English.

Name
Type: string

Name of the voice (for example, Salli, Kendra, etc.). This provides a human readable voice name that you might display in your application.

SupportedEngines
Type: Array of strings

Specifies which engines (standard, neural, long-form or generative) are supported by a given voice.