synthesize: Synthesize Speech

Description Usage Arguments Value Examples

View source: R/synthesize.R

Description

Pass text to the synthesis API and return an audio file

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

1
2
3
4
5
6
7
## Not run: 
hello <- synthesize("hello world!", voice = "Geraint")
if (interactive() & require("tuneR")) {
    try(play(hello))
}

## End(Not run)

aws.polly documentation built on April 14, 2020, 7:37 p.m.