Learn R Programming

aws.polly (version 0.1.5)

get_synthesis: 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 = c(22050, 16000, 8000),
  lexicon = NULL,
  ssml = FALSE,
  ...
)

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

A character string specifying the name of an AWS Polly voice. See list_voices.

format

A character string specifying an output file format.

rate

An integer value specifying the audio frequency in Hertz.

lexicon

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

ssml

A logical indicating whether text contains SSML markup.

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

Run this code
# NOT RUN {
hello <- synthesize("hello world!", voice = "Geraint")
if (interactive() & require("tuneR")) {
    try(play(hello))
}
# }

Run the code above in your browser using DataLab