Class: AWS.Polly

Inherits:
AWS.Service show all
Identifier:
polly
API Version:
2016-06-10
Defined in:
(unknown)

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Sending a Request Using Polly

var polly = new AWS.Polly();
polly.deleteLexicon(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Locking the API Version

In order to ensure that the Polly object uses this specific API, you can construct the object by passing the apiVersion option to the constructor:

var polly = new AWS.Polly({apiVersion: '2016-06-10'});

You can also set the API version globally in AWS.config.apiVersions using the polly service identifier:

AWS.config.apiVersions = {
  polly: '2016-06-10',
  // other service API versions
};

var polly = new AWS.Polly();

Version:

  • 2016-06-10

Defined Under Namespace

Classes: Presigner

Constructor Summary collapse

Property Summary collapse

Properties inherited from AWS.Service

apiVersions

Method Summary collapse

Methods inherited from AWS.Service

makeRequest, makeUnauthenticatedRequest, waitFor, setupRequestListeners, defineService

Constructor Details

new AWS.Polly(options = {}) ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a Polly object

var polly = new AWS.Polly({apiVersion: '2016-06-10'});

Options Hash (options):

  • params (map)

    An optional map of parameters to bind to every request sent by this service object. For more information on bound parameters, see "Working with Services" in the Getting Started Guide.

  • endpoint (String)

    The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like 'https://{service}.{region}.amazonaws.com'.

  • accessKeyId (String)

    your AWS access key ID.

  • secretAccessKey (String)

    your AWS secret access key.

  • sessionToken (AWS.Credentials)

    the optional AWS session token to sign requests with.

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. You can either specify this object, or specify the accessKeyId and secretAccessKey options directly.

  • credentialProvider (AWS.CredentialProviderChain)

    the provider chain used to resolve credentials if no static credentials property is set.

  • region (String)

    the region to send service requests to. See AWS.Polly.region for more information.

  • maxRetries (Integer)

    the maximum amount of retries to attempt with a request. See AWS.Polly.maxRetries for more information.

  • maxRedirects (Integer)

    the maximum amount of redirects to follow with a request. See AWS.Polly.maxRedirects for more information.

  • sslEnabled (Boolean)

    whether to enable SSL for requests.

  • paramValidation (Boolean|map)

    whether input parameters should be validated against the operation description before sending the request. Defaults to true. Pass a map to enable any of the following specific validation features:

    • min [Boolean] — Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to true.
    • max [Boolean] — Validates that a value meets the max constraint.
    • pattern [Boolean] — Validates that a string value matches a regular expression.
    • enum [Boolean] — Validates that a string value matches one of the allowable enum values.
  • computeChecksums (Boolean)

    whether to compute checksums for payload bodies when the service accepts it (currently supported in S3 only)

  • convertResponseTypes (Boolean)

    whether types are converted when parsing response data. Currently only supported for JSON based services. Turning this off may improve performance on large response payloads. Defaults to true.

  • correctClockSkew (Boolean)

    whether to apply a clock skew correction and retry requests that fail because of an skewed client clock. Defaults to false.

  • s3ForcePathStyle (Boolean)

    whether to force path style URLs for S3 objects.

  • s3BucketEndpoint (Boolean)

    whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint). Note that setting this configuration option requires an endpoint to be provided explicitly to the service constructor.

  • s3DisableBodySigning (Boolean)

    whether S3 body signing should be disabled when using signature version v4. Body signing can only be disabled when using https. Defaults to true.

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. Currently supported options are:

    • base [Integer] — The base number of milliseconds to use in the exponential backoff for operation retries. Defaults to 100 ms for all services except DynamoDB, where it defaults to 50ms.
    • customBackoff [function] — A custom function that accepts a retry count and returns the amount of time to delay in milliseconds. The base option will be ignored if this option is supplied.
  • httpOptions (map)

    A set of options to pass to the low-level HTTP request. Currently supported options are:

    • proxy [String] — the URL to proxy requests through
    • agent [http.Agent, https.Agent] — the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (http.globalAgent) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment.
    • connectTimeout [Integer] — Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds. This timeout has no effect once a socket connection has been established.
    • timeout [Integer] — Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
    • xhrAsync [Boolean] — Whether the SDK will send asynchronous HTTP requests. Used in the browser environment only. Set to false to send requests synchronously. Defaults to true (async on).
    • xhrWithCredentials [Boolean] — Sets the "withCredentials" property of an XMLHttpRequest object. Used in the browser environment only. Defaults to false.
  • apiVersion (String, Date)

    a String in YYYY-MM-DD format (or a date) that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify 'latest' to use the latest possible version.

  • apiVersions (map<String, String|Date>)

    a map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.

  • logger (#write, #log)

    an object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests

  • systemClockOffset (Number)

    an offset value in milliseconds to apply to all signing times. Use this to compensate for clock skew when your system may be out of sync with the service time. Note that this configuration option can only be applied to the global AWS.config object and cannot be overridden in service-specific configuration. Defaults to 0 milliseconds.

  • signatureVersion (String)

    the signature version to sign requests with (overriding the API configuration). Possible values are: 'v2', 'v3', 'v4'.

  • signatureCache (Boolean)

    whether the signature to sign requests with (overriding the API configuration) is cached. Only applies to the signature version 'v4'. Defaults to true.

  • dynamoDbCrc32 (Boolean)

    whether to validate the CRC32 checksum of HTTP response bodies returned by DynamoDB. Default: true.

Property Details

endpointAWS.Endpoint (readwrite)

Returns an Endpoint object representing the endpoint URL for service requests.

Returns:

  • (AWS.Endpoint)

    an Endpoint object representing the endpoint URL for service requests.

Method Details

deleteLexicon(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

To delete a lexicon


/* Deletes a specified pronunciation lexicon stored in an AWS Region. */

 var params = {
  Name: "example"
 };
 polly.deleteLexicon(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the deleteLexicon operation

var params = {
  Name: 'STRING_VALUE' /* required */
};
polly.deleteLexicon(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Name — (String)

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

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

describeVoices(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

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. */

 var params = {
  LanguageCode: "en-GB"
 };
 polly.describeVoices(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    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"
     }
    ]
   }
   */
 });

Calling the describeVoices operation

var params = {
  LanguageCode: cy-GB | da-DK | de-DE | en-AU | en-GB | en-GB-WLS | en-IN | en-US | es-ES | es-US | fr-CA | fr-FR | is-IS | it-IT | ko-KR | ja-JP | nb-NO | nl-NL | pl-PL | pt-BR | pt-PT | ro-RO | ru-RU | sv-SE | tr-TR,
  NextToken: 'STRING_VALUE'
};
polly.describeVoices(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • LanguageCode — (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.

      Possible values include:
      • "cy-GB"
      • "da-DK"
      • "de-DE"
      • "en-AU"
      • "en-GB"
      • "en-GB-WLS"
      • "en-IN"
      • "en-US"
      • "es-ES"
      • "es-US"
      • "fr-CA"
      • "fr-FR"
      • "is-IS"
      • "it-IT"
      • "ko-KR"
      • "ja-JP"
      • "nb-NO"
      • "nl-NL"
      • "pl-PL"
      • "pt-BR"
      • "pt-PT"
      • "ro-RO"
      • "ru-RU"
      • "sv-SE"
      • "tr-TR"
    • NextToken — (String)

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

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • Voices — (Array<map>)

        A list of voices with their properties.

        • Gender — (String)

          Gender of the voice.

          Possible values include:
          • "Female"
          • "Male"
        • Id — (String)

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

          Possible values include:
          • "Geraint"
          • "Gwyneth"
          • "Mads"
          • "Naja"
          • "Hans"
          • "Marlene"
          • "Nicole"
          • "Russell"
          • "Amy"
          • "Brian"
          • "Emma"
          • "Raveena"
          • "Ivy"
          • "Joanna"
          • "Joey"
          • "Justin"
          • "Kendra"
          • "Kimberly"
          • "Matthew"
          • "Salli"
          • "Conchita"
          • "Enrique"
          • "Miguel"
          • "Penelope"
          • "Chantal"
          • "Celine"
          • "Mathieu"
          • "Dora"
          • "Karl"
          • "Carla"
          • "Giorgio"
          • "Mizuki"
          • "Liv"
          • "Lotte"
          • "Ruben"
          • "Ewa"
          • "Jacek"
          • "Jan"
          • "Maja"
          • "Ricardo"
          • "Vitoria"
          • "Cristiano"
          • "Ines"
          • "Carmen"
          • "Maxim"
          • "Tatyana"
          • "Astrid"
          • "Filiz"
          • "Vicki"
          • "Takumi"
          • "Seoyeon"
          • "Aditi"
        • LanguageCode — (String)

          Language code of the voice.

          Possible values include:
          • "cy-GB"
          • "da-DK"
          • "de-DE"
          • "en-AU"
          • "en-GB"
          • "en-GB-WLS"
          • "en-IN"
          • "en-US"
          • "es-ES"
          • "es-US"
          • "fr-CA"
          • "fr-FR"
          • "is-IS"
          • "it-IT"
          • "ko-KR"
          • "ja-JP"
          • "nb-NO"
          • "nl-NL"
          • "pl-PL"
          • "pt-BR"
          • "pt-PT"
          • "ro-RO"
          • "ru-RU"
          • "sv-SE"
          • "tr-TR"
        • LanguageName — (String)

          Human readable name of the language in English.

        • Name — (String)

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

      • NextToken — (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.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getLexicon(params = {}, callback) ⇒ AWS.Request

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

Service Reference:

Examples:

To retrieve a lexicon


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

 var params = {
  Name: ""
 };
 polly.getLexicon(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    Lexicon: {
     Content: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<lexicon version=\"1.0\" \r\n      xmlns=\"http://www.w3.org/2005/01/pronunciation-lexicon\"\r\n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \r\n      xsi:schemaLocation=\"http://www.w3.org/2005/01/pronunciation-lexicon \r\n        http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd\"\r\n      alphabet=\"ipa\" \r\n      xml:lang=\"en-US\">\r\n  <lexeme>\r\n    <grapheme>W3C</grapheme>\r\n    <alias>World Wide Web Consortium</alias>\r\n  </lexeme>\r\n</lexicon>", 
     Name: "example"
    }, 
    LexiconAttributes: {
     Alphabet: "ipa", 
     LanguageCode: "en-US", 
     LastModified: <Date Representation>, 
     LexemesCount: 1, 
     LexiconArn: "arn:aws:polly:us-east-1:123456789012:lexicon/example", 
     Size: 503
    }
   }
   */
 });

Calling the getLexicon operation

var params = {
  Name: 'STRING_VALUE' /* required */
};
polly.getLexicon(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Name — (String)

      Name of the lexicon.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • Lexicon — (map)

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

        • Content — (String)

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

        • Name — (String)

          Name of the lexicon.

      • LexiconAttributes — (map)

        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.

        • Alphabet — (String)

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

        • LanguageCode — (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.

          Possible values include:
          • "cy-GB"
          • "da-DK"
          • "de-DE"
          • "en-AU"
          • "en-GB"
          • "en-GB-WLS"
          • "en-IN"
          • "en-US"
          • "es-ES"
          • "es-US"
          • "fr-CA"
          • "fr-FR"
          • "is-IS"
          • "it-IT"
          • "ko-KR"
          • "ja-JP"
          • "nb-NO"
          • "nl-NL"
          • "pl-PL"
          • "pt-BR"
          • "pt-PT"
          • "ro-RO"
          • "ru-RU"
          • "sv-SE"
          • "tr-TR"
        • LastModified — (Date)

          Date lexicon was last modified (a timestamp value).

        • LexiconArn — (String)

          Amazon Resource Name (ARN) of the lexicon.

        • LexemesCount — (Integer)

          Number of lexemes in the lexicon.

        • Size — (Integer)

          Total size of the lexicon, in characters.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

listLexicons(params = {}, callback) ⇒ AWS.Request

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

Service Reference:

Examples:

To list all lexicons in a region


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

 var params = {
 };
 polly.listLexicons(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    Lexicons: [
       {
      Attributes: {
       Alphabet: "ipa", 
       LanguageCode: "en-US", 
       LastModified: <Date Representation>, 
       LexemesCount: 1, 
       LexiconArn: "arn:aws:polly:us-east-1:123456789012:lexicon/example", 
       Size: 503
      }, 
      Name: "example"
     }
    ]
   }
   */
 });

Calling the listLexicons operation

var params = {
  NextToken: 'STRING_VALUE'
};
polly.listLexicons(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • NextToken — (String)

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

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • Lexicons — (Array<map>)

        A list of lexicon names and attributes.

        • Name — (String)

          Name of the lexicon.

        • Attributes — (map)

          Provides lexicon metadata.

          • Alphabet — (String)

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

          • LanguageCode — (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.

            Possible values include:
            • "cy-GB"
            • "da-DK"
            • "de-DE"
            • "en-AU"
            • "en-GB"
            • "en-GB-WLS"
            • "en-IN"
            • "en-US"
            • "es-ES"
            • "es-US"
            • "fr-CA"
            • "fr-FR"
            • "is-IS"
            • "it-IT"
            • "ko-KR"
            • "ja-JP"
            • "nb-NO"
            • "nl-NL"
            • "pl-PL"
            • "pt-BR"
            • "pt-PT"
            • "ro-RO"
            • "ru-RU"
            • "sv-SE"
            • "tr-TR"
          • LastModified — (Date)

            Date lexicon was last modified (a timestamp value).

          • LexiconArn — (String)

            Amazon Resource Name (ARN) of the lexicon.

          • LexemesCount — (Integer)

            Number of lexemes in the lexicon.

          • Size — (Integer)

            Total size of the lexicon, in characters.

      • NextToken — (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.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

putLexicon(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

To save a lexicon


/* Stores a pronunciation lexicon in an AWS Region. */

 var params = {
  Content: "file://example.pls", 
  Name: "W3C"
 };
 polly.putLexicon(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the putLexicon operation

var params = {
  Content: 'STRING_VALUE', /* required */
  Name: 'STRING_VALUE' /* required */
};
polly.putLexicon(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • Name — (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.

    • Content — (String)

      Content of the PLS lexicon as string data.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

synthesizeSpeech(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

To synthesize speech


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

 var params = {
  LexiconNames: [
     "example"
  ], 
  OutputFormat: "mp3", 
  SampleRate: "8000", 
  Text: "All Gaul is divided into three parts", 
  TextType: "text", 
  VoiceId: "Joanna"
 };
 polly.synthesizeSpeech(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    AudioStream: <Binary String>, 
    ContentType: "audio/mpeg", 
    RequestCharacters: 37
   }
   */
 });

Calling the synthesizeSpeech operation

var params = {
  OutputFormat: json | mp3 | ogg_vorbis | pcm, /* required */
  Text: 'STRING_VALUE', /* required */
  VoiceId: Geraint | Gwyneth | Mads | Naja | Hans | Marlene | Nicole | Russell | Amy | Brian | Emma | Raveena | Ivy | Joanna | Joey | Justin | Kendra | Kimberly | Matthew | Salli | Conchita | Enrique | Miguel | Penelope | Chantal | Celine | Mathieu | Dora | Karl | Carla | Giorgio | Mizuki | Liv | Lotte | Ruben | Ewa | Jacek | Jan | Maja | Ricardo | Vitoria | Cristiano | Ines | Carmen | Maxim | Tatyana | Astrid | Filiz | Vicki | Takumi | Seoyeon | Aditi, /* required */
  LexiconNames: [
    'STRING_VALUE',
    /* more items */
  ],
  SampleRate: 'STRING_VALUE',
  SpeechMarkTypes: [
    sentence | ssml | viseme | word,
    /* more items */
  ],
  TextType: ssml | text
};
polly.synthesizeSpeech(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • LexiconNames — (Array<String>)

      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 — (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.

      Possible values include:
      • "json"
      • "mp3"
      • "ogg_vorbis"
      • "pcm"
    • SampleRate — (String)

      The audio frequency specified in Hz.

      The valid values for mp3 and ogg_vorbis are "8000", "16000", and "22050". The default value is "22050".

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

    • SpeechMarkTypes — (Array<String>)

      The type of speech marks returned for the input text.

    • Text — (String)

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

    • TextType — (String)

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

      Possible values include:
      • "ssml"
      • "text"
    • VoiceId — (String)

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

      Possible values include:
      • "Geraint"
      • "Gwyneth"
      • "Mads"
      • "Naja"
      • "Hans"
      • "Marlene"
      • "Nicole"
      • "Russell"
      • "Amy"
      • "Brian"
      • "Emma"
      • "Raveena"
      • "Ivy"
      • "Joanna"
      • "Joey"
      • "Justin"
      • "Kendra"
      • "Kimberly"
      • "Matthew"
      • "Salli"
      • "Conchita"
      • "Enrique"
      • "Miguel"
      • "Penelope"
      • "Chantal"
      • "Celine"
      • "Mathieu"
      • "Dora"
      • "Karl"
      • "Carla"
      • "Giorgio"
      • "Mizuki"
      • "Liv"
      • "Lotte"
      • "Ruben"
      • "Ewa"
      • "Jacek"
      • "Jan"
      • "Maja"
      • "Ricardo"
      • "Vitoria"
      • "Cristiano"
      • "Ines"
      • "Carmen"
      • "Maxim"
      • "Tatyana"
      • "Astrid"
      • "Filiz"
      • "Vicki"
      • "Takumi"
      • "Seoyeon"
      • "Aditi"

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • AudioStream — (Buffer, Typed Array, Blob, String, ReadableStream)

        Stream containing the synthesized speech.

      • ContentType — (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 audio/json.

      • RequestCharacters — (Integer)

        Number of characters synthesized.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.