Package 'aws.polly'

Title: Client for AWS Polly
Description: A client for AWS Polly <http://aws.amazon.com/documentation/polly>, a speech synthesis service.
Authors: Thomas J. Leeper [aut] (ORCID: <https://orcid.org/0000-0003-4097-6326>), Antoine Sachet [cre], John Muschelli [ctb] (ORCID: <https://orcid.org/0000-0001-6469-1750>)
Maintainer: Antoine Sachet <[email protected]>
License: GPL (>= 2)
Version: 0.1.6
Built: 2026-05-24 08:13:04 UTC
Source: https://github.com/cloudyr/aws.polly

Help Index


aws.polly

Description

Client for AWS Polly

Details

This is a client for AWS Polly, a speech synthesis service.

Author(s)

Thomas J. Leeper <[email protected]>

See Also

AWS Polly Documentation


Lexicons

Description

List, put, and delete lexicons

Usage

get_lexicon(lexicon, token, ...)

put_lexicon(lexicon, content, ...)

delete_lexicon(lexicon, ...)

Arguments

lexicon

A character string specifying the name of a lexicon. If missing, a list of available lexicons is returned.

token

Optionally, a pagination token.

...

Additional arguments passed to pollyHTTP.

content

A character string containing the content of the PLS lexicon.

Details

Note: put_lexicon will overwrite an existing lexicon with the same name.

Value

A list.

Examples

## Not run: 
list_lexicons()

## End(Not run)

Synthesize Speech

Description

Pass text to the synthesis API and return an audio file

Usage

get_synthesis(
  text,
  voice,
  format = c("mp3", "ogg_vorbis", "pcm"),
  rate = deprecated(),
  lexicon = deprecated(),
  ssml = FALSE,
  lexicon_names = NULL,
  sample_rate = NULL,
  engine = c("standard", "neural"),
  language = NULL,
  ...
)

synthesize(text, voice, ...)

Arguments

text

Either a plain text character string (maximum 1500 characters) or a character string containing SSML (ssml should be set to TRUE).

voice

Name of an AWS Polly voice. See list_voices.

format

Output file format: one of ''mp3'‘ (default), '’ogg_vorbis'' or ''pcm''.

rate

Deprecated. Use sample_rate instead.

lexicon

Deprecated. Use lexicon_names instead.

ssml

A logical indicating whether text contains SSML markup.

lexicon_names

Optional character vector (max length 5) specifying the names of lexicons to apply during synthesis. See get_lexicon.

sample_rate

Audio frequency in Hertz. One of '24000', '22050', '16000' or '8000'. If 'NULL' (default), 'AWS' will pick an appropriate value depending on the voice, engine and output format.

engine

Engine type: either ''standard'‘ (default) or '’neural''. Not all voices support the neural engine, see list_voices.

language

Optional language code. This is useful for bilingual voices.

...

Additional arguments passed to pollyHTTP.

Value

get_synthesis returns a raw vector (i.e., the bytes representing the audio as the requested file format). synthesize is a convenience wrapper around that, which returns an object of class “Wave” (see Wave).

Examples

## Not run: 
hello <- synthesize("hello world!", voice = "Geraint")
if (interactive() & require("tuneR")) {
    try(play(hello))
}

## End(Not run)

List available voices

Description

Retrieve a list of available voices

Usage

list_voices(
  language = NULL,
  token = NULL,
  engine = NULL,
  include_additional_languages = FALSE,
  ...
)

Arguments

language

Optional ISO 3166 country identification tag. If 'NULL', voices for all available languages are returned.

token

Optional pagination token.

engine

Optional engine name: '"standard"' or '"neural"'. If specified, only voices available for that engine are returned.

...

Additional arguments passed to pollyHTTP.

include_additional_language

Optional boolean specifying whether to return bilingual voices listing the requested language as an additional language (as opposed to their main default language).

Value

A data frame of available names.

Examples

## Not run: 
list_voices(language = "cy-GB")
list_voices()

## End(Not run)

Execute AWS Polly API Request

Description

This is the workhorse function to execute calls to the Polly API.

Usage

pollyHTTP(
  action,
  query = list(),
  headers = list(),
  body = NULL,
  verb = c("GET", "POST", "PUT", "DELETE"),
  version = "v1",
  raw_response = if (verb == "POST") TRUE else FALSE,
  verbose = getOption("verbose", FALSE),
  region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"),
  key = NULL,
  secret = NULL,
  session_token = NULL,
  ...
)

Arguments

action

A character string specifying the API action to take

query

An optional named list containing query string parameters and their character values.

headers

A list of headers to pass to the HTTP request.

body

A request body

verb

A character string specifying the HTTP verb to implement.

version

A character string specifying the API version.

raw_response

A logical indicating whether to return the raw response body.

verbose

A logical indicating whether to be verbose. Default is given by options("verbose").

region

A character string specifying an AWS region. See locate_credentials.

key

A character string specifying an AWS Access Key. See locate_credentials.

secret

A character string specifying an AWS Secret Key. See locate_credentials.

session_token

Optionally, a character string specifying an AWS temporary Session Token to use in signing a request. See locate_credentials.

...

Additional arguments passed to GET.

Details

This function constructs and signs an Polly API request and returns the results thereof, or relevant debugging information in the case of error.

Value

If successful, a named list. Otherwise, a data structure of class “aws-error” containing any error message(s) from AWS and information about the request attempt.

Author(s)

Thomas J. Leeper