AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

Polly

import "github.com/aws/aws-sdk-go/service/polly"

type Polly struct { *client.Client }

Polly provides the API operation methods for making requests to Amazon Polly. See this package's package overview docs for details on the service.

Polly methods are safe to use concurrently. It is not safe to modify mutate any of the struct's properties though.

Client

Type: *client.Client

Method

DeleteLexicon

func (c *Polly) DeleteLexicon(input *DeleteLexiconInput) (*DeleteLexiconOutput, error)

DeleteLexicon API operation for Amazon Polly.

Deletes the specified pronunciation lexicon stored in an AWS 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 (https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation DeleteLexicon for usage and error information.

Returned Error Codes:

  • ErrCodeLexiconNotFoundException "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.
  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/DeleteLexicon

Example

Polly DeleteLexicon shared00

To delete a lexicon

Deletes a specified pronunciation lexicon stored in an AWS Region.

{ svc := polly.New(session.New()) input := &polly.DeleteLexiconInput{ Name: aws.String("example"), } result, err := svc.DeleteLexicon(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeLexiconNotFoundException: fmt.Println(polly.ErrCodeLexiconNotFoundException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DeleteLexiconRequest

func (c *Polly) DeleteLexiconRequest(input *DeleteLexiconInput) (req *request.Request, output *DeleteLexiconOutput)

DeleteLexiconRequest generates a "aws/request.Request" representing the client's request for the DeleteLexicon operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeleteLexicon for more information on using the DeleteLexicon API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeleteLexiconRequest method. req, resp := client.DeleteLexiconRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/DeleteLexicon

DeleteLexiconWithContext

func (c *Polly) DeleteLexiconWithContext(ctx aws.Context, input *DeleteLexiconInput, opts ...request.Option) (*DeleteLexiconOutput, error)

DeleteLexiconWithContext is the same as DeleteLexicon with the addition of the ability to pass a context and additional request options.

See DeleteLexicon for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeVoices

func (c *Polly) DescribeVoices(input *DescribeVoicesInput) (*DescribeVoicesOutput, error)

DescribeVoices API operation for Amazon Polly.

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.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation DescribeVoices for usage and error information.

Returned Error Codes:

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

  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/DescribeVoices

Example

Polly DescribeVoices shared00

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.

{ svc := polly.New(session.New()) input := &polly.DescribeVoicesInput{ LanguageCode: aws.String("en-GB"), } result, err := svc.DescribeVoices(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeInvalidNextTokenException: fmt.Println(polly.ErrCodeInvalidNextTokenException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeVoicesRequest

func (c *Polly) DescribeVoicesRequest(input *DescribeVoicesInput) (req *request.Request, output *DescribeVoicesOutput)

DescribeVoicesRequest generates a "aws/request.Request" representing the client's request for the DescribeVoices operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeVoices for more information on using the DescribeVoices API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeVoicesRequest method. req, resp := client.DescribeVoicesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/DescribeVoices

DescribeVoicesWithContext

func (c *Polly) DescribeVoicesWithContext(ctx aws.Context, input *DescribeVoicesInput, opts ...request.Option) (*DescribeVoicesOutput, error)

DescribeVoicesWithContext is the same as DescribeVoices with the addition of the ability to pass a context and additional request options.

See DescribeVoices for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

GetLexicon

func (c *Polly) GetLexicon(input *GetLexiconInput) (*GetLexiconOutput, error)

GetLexicon API operation for Amazon Polly.

Returns the content of the specified pronunciation lexicon stored in an AWS Region. For more information, see Managing Lexicons (https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation GetLexicon for usage and error information.

Returned Error Codes:

  • ErrCodeLexiconNotFoundException "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.
  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/GetLexicon

Example

Polly GetLexicon shared00

To retrieve a lexicon

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

{ svc := polly.New(session.New()) input := &polly.GetLexiconInput{ Name: aws.String(""), } result, err := svc.GetLexicon(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeLexiconNotFoundException: fmt.Println(polly.ErrCodeLexiconNotFoundException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

GetLexiconRequest

func (c *Polly) GetLexiconRequest(input *GetLexiconInput) (req *request.Request, output *GetLexiconOutput)

GetLexiconRequest generates a "aws/request.Request" representing the client's request for the GetLexicon operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See GetLexicon for more information on using the GetLexicon API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the GetLexiconRequest method. req, resp := client.GetLexiconRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/GetLexicon

GetLexiconWithContext

func (c *Polly) GetLexiconWithContext(ctx aws.Context, input *GetLexiconInput, opts ...request.Option) (*GetLexiconOutput, error)

GetLexiconWithContext is the same as GetLexicon with the addition of the ability to pass a context and additional request options.

See GetLexicon for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

GetSpeechSynthesisTask

func (c *Polly) GetSpeechSynthesisTask(input *GetSpeechSynthesisTaskInput) (*GetSpeechSynthesisTaskOutput, error)

GetSpeechSynthesisTask API operation for Amazon Polly.

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.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation GetSpeechSynthesisTask for usage and error information.

Returned Error Codes:

  • ErrCodeInvalidTaskIdException "InvalidTaskIdException" The provided Task ID is not valid. Please provide a valid Task ID and try again.

  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

  • ErrCodeSynthesisTaskNotFoundException "SynthesisTaskNotFoundException" The Speech Synthesis task with requested Task ID cannot be found.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/GetSpeechSynthesisTask

GetSpeechSynthesisTaskRequest

func (c *Polly) GetSpeechSynthesisTaskRequest(input *GetSpeechSynthesisTaskInput) (req *request.Request, output *GetSpeechSynthesisTaskOutput)

GetSpeechSynthesisTaskRequest generates a "aws/request.Request" representing the client's request for the GetSpeechSynthesisTask operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See GetSpeechSynthesisTask for more information on using the GetSpeechSynthesisTask API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the GetSpeechSynthesisTaskRequest method. req, resp := client.GetSpeechSynthesisTaskRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/GetSpeechSynthesisTask

GetSpeechSynthesisTaskWithContext

func (c *Polly) GetSpeechSynthesisTaskWithContext(ctx aws.Context, input *GetSpeechSynthesisTaskInput, opts ...request.Option) (*GetSpeechSynthesisTaskOutput, error)

GetSpeechSynthesisTaskWithContext is the same as GetSpeechSynthesisTask with the addition of the ability to pass a context and additional request options.

See GetSpeechSynthesisTask for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListLexicons

func (c *Polly) ListLexicons(input *ListLexiconsInput) (*ListLexiconsOutput, error)

ListLexicons API operation for Amazon Polly.

Returns a list of pronunciation lexicons stored in an AWS Region. For more information, see Managing Lexicons (https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation ListLexicons for usage and error information.

Returned Error Codes:

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

  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons

Example

Polly ListLexicons shared00

To list all lexicons in a region

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

{ svc := polly.New(session.New()) input := &polly.ListLexiconsInput{} result, err := svc.ListLexicons(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeInvalidNextTokenException: fmt.Println(polly.ErrCodeInvalidNextTokenException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListLexiconsRequest

func (c *Polly) ListLexiconsRequest(input *ListLexiconsInput) (req *request.Request, output *ListLexiconsOutput)

ListLexiconsRequest generates a "aws/request.Request" representing the client's request for the ListLexicons operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListLexicons for more information on using the ListLexicons API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListLexiconsRequest method. req, resp := client.ListLexiconsRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons

ListLexiconsWithContext

func (c *Polly) ListLexiconsWithContext(ctx aws.Context, input *ListLexiconsInput, opts ...request.Option) (*ListLexiconsOutput, error)

ListLexiconsWithContext is the same as ListLexicons with the addition of the ability to pass a context and additional request options.

See ListLexicons for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListSpeechSynthesisTasks

func (c *Polly) ListSpeechSynthesisTasks(input *ListSpeechSynthesisTasksInput) (*ListSpeechSynthesisTasksOutput, error)

ListSpeechSynthesisTasks API operation for Amazon Polly.

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.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation ListSpeechSynthesisTasks for usage and error information.

Returned Error Codes:

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

  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListSpeechSynthesisTasks

ListSpeechSynthesisTasksPages

func (c *Polly) ListSpeechSynthesisTasksPages(input *ListSpeechSynthesisTasksInput, fn func(*ListSpeechSynthesisTasksOutput, bool) bool) error

ListSpeechSynthesisTasksPages iterates over the pages of a ListSpeechSynthesisTasks operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListSpeechSynthesisTasks method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListSpeechSynthesisTasks operation. pageNum := 0 err := client.ListSpeechSynthesisTasksPages(params, func(page *ListSpeechSynthesisTasksOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListSpeechSynthesisTasksPagesWithContext

func (c *Polly) ListSpeechSynthesisTasksPagesWithContext(ctx aws.Context, input *ListSpeechSynthesisTasksInput, fn func(*ListSpeechSynthesisTasksOutput, bool) bool, opts ...request.Option) error

ListSpeechSynthesisTasksPagesWithContext same as ListSpeechSynthesisTasksPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListSpeechSynthesisTasksRequest

func (c *Polly) ListSpeechSynthesisTasksRequest(input *ListSpeechSynthesisTasksInput) (req *request.Request, output *ListSpeechSynthesisTasksOutput)

ListSpeechSynthesisTasksRequest generates a "aws/request.Request" representing the client's request for the ListSpeechSynthesisTasks operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListSpeechSynthesisTasks for more information on using the ListSpeechSynthesisTasks API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListSpeechSynthesisTasksRequest method. req, resp := client.ListSpeechSynthesisTasksRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListSpeechSynthesisTasks

ListSpeechSynthesisTasksWithContext

func (c *Polly) ListSpeechSynthesisTasksWithContext(ctx aws.Context, input *ListSpeechSynthesisTasksInput, opts ...request.Option) (*ListSpeechSynthesisTasksOutput, error)

ListSpeechSynthesisTasksWithContext is the same as ListSpeechSynthesisTasks with the addition of the ability to pass a context and additional request options.

See ListSpeechSynthesisTasks for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

PutLexicon

func (c *Polly) PutLexicon(input *PutLexiconInput) (*PutLexiconOutput, error)

PutLexicon API operation for Amazon Polly.

Stores a pronunciation lexicon in an AWS 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 (https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation PutLexicon for usage and error information.

Returned Error Codes:

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

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

  • ErrCodeLexiconSizeExceededException "LexiconSizeExceededException" The maximum size of the specified lexicon would be exceeded by this operation.

  • ErrCodeMaxLexemeLengthExceededException "MaxLexemeLengthExceededException" The maximum size of the lexeme would be exceeded by this operation.

  • ErrCodeMaxLexiconsNumberExceededException "MaxLexiconsNumberExceededException" The maximum number of lexicons would be exceeded by this operation.

  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/PutLexicon

Example

Polly PutLexicon shared00

To save a lexicon

Stores a pronunciation lexicon in an AWS Region.

{ svc := polly.New(session.New()) input := &polly.PutLexiconInput{ Content: aws.String("file://example.pls"), Name: aws.String("W3C"), } result, err := svc.PutLexicon(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeInvalidLexiconException: fmt.Println(polly.ErrCodeInvalidLexiconException, aerr.Error()) case polly.ErrCodeUnsupportedPlsAlphabetException: fmt.Println(polly.ErrCodeUnsupportedPlsAlphabetException, aerr.Error()) case polly.ErrCodeUnsupportedPlsLanguageException: fmt.Println(polly.ErrCodeUnsupportedPlsLanguageException, aerr.Error()) case polly.ErrCodeLexiconSizeExceededException: fmt.Println(polly.ErrCodeLexiconSizeExceededException, aerr.Error()) case polly.ErrCodeMaxLexemeLengthExceededException: fmt.Println(polly.ErrCodeMaxLexemeLengthExceededException, aerr.Error()) case polly.ErrCodeMaxLexiconsNumberExceededException: fmt.Println(polly.ErrCodeMaxLexiconsNumberExceededException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

PutLexiconRequest

func (c *Polly) PutLexiconRequest(input *PutLexiconInput) (req *request.Request, output *PutLexiconOutput)

PutLexiconRequest generates a "aws/request.Request" representing the client's request for the PutLexicon operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PutLexicon for more information on using the PutLexicon API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PutLexiconRequest method. req, resp := client.PutLexiconRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/PutLexicon

PutLexiconWithContext

func (c *Polly) PutLexiconWithContext(ctx aws.Context, input *PutLexiconInput, opts ...request.Option) (*PutLexiconOutput, error)

PutLexiconWithContext is the same as PutLexicon with the addition of the ability to pass a context and additional request options.

See PutLexicon for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

StartSpeechSynthesisTask

func (c *Polly) StartSpeechSynthesisTask(input *StartSpeechSynthesisTaskInput) (*StartSpeechSynthesisTaskOutput, error)

StartSpeechSynthesisTask API operation for Amazon Polly.

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.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation StartSpeechSynthesisTask for usage and error information.

Returned Error Codes:

  • ErrCodeTextLengthExceededException "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.

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

  • ErrCodeInvalidS3KeyException "InvalidS3KeyException" The provided Amazon S3 key prefix is invalid. Please provide a valid S3 object key name.

  • ErrCodeInvalidSampleRateException "InvalidSampleRateException" The specified sample rate is not valid.

  • ErrCodeInvalidSnsTopicArnException "InvalidSnsTopicArnException" The provided SNS topic ARN is invalid. Please provide a valid SNS topic ARN and try again.

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

  • ErrCodeLexiconNotFoundException "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.
  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

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

  • ErrCodeSsmlMarksNotSupportedForTextTypeException "SsmlMarksNotSupportedForTextTypeException" SSML speech marks are not supported for plain text-type input.

  • ErrCodeLanguageNotSupportedException "LanguageNotSupportedException" The language specified is not currently supported by Amazon Polly in this capacity.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/StartSpeechSynthesisTask

StartSpeechSynthesisTaskRequest

func (c *Polly) StartSpeechSynthesisTaskRequest(input *StartSpeechSynthesisTaskInput) (req *request.Request, output *StartSpeechSynthesisTaskOutput)

StartSpeechSynthesisTaskRequest generates a "aws/request.Request" representing the client's request for the StartSpeechSynthesisTask operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See StartSpeechSynthesisTask for more information on using the StartSpeechSynthesisTask API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the StartSpeechSynthesisTaskRequest method. req, resp := client.StartSpeechSynthesisTaskRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/StartSpeechSynthesisTask

StartSpeechSynthesisTaskWithContext

func (c *Polly) StartSpeechSynthesisTaskWithContext(ctx aws.Context, input *StartSpeechSynthesisTaskInput, opts ...request.Option) (*StartSpeechSynthesisTaskOutput, error)

StartSpeechSynthesisTaskWithContext is the same as StartSpeechSynthesisTask with the addition of the ability to pass a context and additional request options.

See StartSpeechSynthesisTask for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

SynthesizeSpeech

func (c *Polly) SynthesizeSpeech(input *SynthesizeSpeechInput) (*SynthesizeSpeechOutput, error)

SynthesizeSpeech API operation for Amazon Polly.

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 (https://docs.aws.amazon.com/polly/latest/dg/how-text-to-speech-works.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Polly's API operation SynthesizeSpeech for usage and error information.

Returned Error Codes:

  • ErrCodeTextLengthExceededException "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.

  • ErrCodeInvalidSampleRateException "InvalidSampleRateException" The specified sample rate is not valid.

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

  • ErrCodeLexiconNotFoundException "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.
  • ErrCodeServiceFailureException "ServiceFailureException" An unknown condition has caused a service failure.

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

  • ErrCodeSsmlMarksNotSupportedForTextTypeException "SsmlMarksNotSupportedForTextTypeException" SSML speech marks are not supported for plain text-type input.

  • ErrCodeLanguageNotSupportedException "LanguageNotSupportedException" The language specified is not currently supported by Amazon Polly in this capacity.

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/SynthesizeSpeech

Example

Polly SynthesizeSpeech shared00

To synthesize speech

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

{ svc := polly.New(session.New()) input := &polly.SynthesizeSpeechInput{ LexiconNames: []*string{ aws.String("example"), }, OutputFormat: aws.String("mp3"), SampleRate: aws.String("8000"), Text: aws.String("All Gaul is divided into three parts"), TextType: aws.String("text"), VoiceId: aws.String("Joanna"), } result, err := svc.SynthesizeSpeech(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case polly.ErrCodeTextLengthExceededException: fmt.Println(polly.ErrCodeTextLengthExceededException, aerr.Error()) case polly.ErrCodeInvalidSampleRateException: fmt.Println(polly.ErrCodeInvalidSampleRateException, aerr.Error()) case polly.ErrCodeInvalidSsmlException: fmt.Println(polly.ErrCodeInvalidSsmlException, aerr.Error()) case polly.ErrCodeLexiconNotFoundException: fmt.Println(polly.ErrCodeLexiconNotFoundException, aerr.Error()) case polly.ErrCodeServiceFailureException: fmt.Println(polly.ErrCodeServiceFailureException, aerr.Error()) case polly.ErrCodeMarksNotSupportedForFormatException: fmt.Println(polly.ErrCodeMarksNotSupportedForFormatException, aerr.Error()) case polly.ErrCodeSsmlMarksNotSupportedForTextTypeException: fmt.Println(polly.ErrCodeSsmlMarksNotSupportedForTextTypeException, aerr.Error()) case polly.ErrCodeLanguageNotSupportedException: fmt.Println(polly.ErrCodeLanguageNotSupportedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

SynthesizeSpeechRequest

func (c *Polly) SynthesizeSpeechRequest(input *SynthesizeSpeechInput) (req *request.Request, output *SynthesizeSpeechOutput)

SynthesizeSpeechRequest generates a "aws/request.Request" representing the client's request for the SynthesizeSpeech operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See SynthesizeSpeech for more information on using the SynthesizeSpeech API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the SynthesizeSpeechRequest method. req, resp := client.SynthesizeSpeechRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/SynthesizeSpeech

SynthesizeSpeechWithContext

func (c *Polly) SynthesizeSpeechWithContext(ctx aws.Context, input *SynthesizeSpeechInput, opts ...request.Option) (*SynthesizeSpeechOutput, error)

SynthesizeSpeechWithContext is the same as SynthesizeSpeech with the addition of the ability to pass a context and additional request options.

See SynthesizeSpeech for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

On this page: