synthesize: Synthesize Speech

View source: R/synthesize.R

get_synthesisR Documentation

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)

cloudyr/aws.polly documentation built on June 18, 2022, 3:45 a.m.