Learn R Programming

text2speech (version 0.2.13)

tts_google: Text to Speech

Description

Text to Speech

Usage

tts_google(
  text,
  output_format = c("mp3", "wav"),
  voice = "en-US-Standard-C",
  bind_audio = TRUE,
  ...
)

tts_amazon( text, output_format = c("mp3", "wav"), voice = "Joanna", bind_audio = TRUE, ... )

tts_microsoft( text, output_format = c("mp3", "wav"), voice = "Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)", bind_audio = TRUE, ... )

tts_default_voice(service = c("amazon", "google", "microsoft"))

tts( text, output_format = c("mp3", "wav"), ..., service = c("amazon", "google", "microsoft"), bind_audio = TRUE )

Value

A data.frame of text and wav files

Arguments

text

A character vector of text to speak

output_format

Format of output files

voice

A full voice name that can be passed to the service, such as the argument voice for get_synthesis`` from \code{aws.polly}, or or [mscstts::ms_synthesize()] or the name` argument for googleLanguageR::gl_talk()

bind_audio

Should the text2speech::tts_bind_wav() be run on after the audio has been created, to ensure that the length of text and the number of rows is consistent? This affects the output format of some audio.

...

Additional arguments to text2speech::tts_google(), text2speech::tts_amazon(), or text2speech::tts_microsoft()

service

service to use

Examples

Run this code
tts_default_voice("amazon")
tts_default_voice("google")
tts_default_voice("microsoft")
if (FALSE) {
text='
  He was caught up in the game. In the middle of the
  10/3/2014 W3C meeting,
  he shouted, "Nice job!" quite loudly. When his boss stared at him, he repeated
  "Nice job," in a
  whisper.
'
}

if (requireNamespace("stringi", quietly = TRUE)) {
    set.seed(1)
    text = stringi::stri_rand_lipsum(10)
    text[3] = paste0(text[3:length(text)], collapse = " " )
    text = text[c(1,3)]
    nchar(text)
    if (tts_auth("google")) {
        res = tts(text, service = "google", bind_audio = FALSE)
        testthat::expect_equal(nrow(res), length(text) + 1)
        bound = tts_bind_wav(res)
        testthat::expect_equal(nrow(bound), length(text))
    }
}

Run the code above in your browser using DataLab