Convert text-to-speech using various engines, including Amazon Polly, Coqui TTS, Google Cloud Text-to-Speech API, Microsoft Cognitive Services Text to Speech REST API, and Speechify Text-to-Speech API.
With the exception of Coqui TTS and Speechify, all these engines are accessible as R packages:
aws.polly is a client for Amazon Polly.
googleLanguageR is a client to the Google Cloud Text-to-Speech API.
conrad is a client to the Microsoft Cognitive Services Text to Speech REST API
Speechify is called directly through its REST API
(https://docs.speechify.ai) using the key in the SPEECHIFY_API_KEY
environment variable.
tts(
text,
output_format = c("mp3", "wav"),
service = c("amazon", "google", "microsoft", "coqui", "speechify"),
bind_audio = TRUE,
...
)tts_amazon(
text,
output_format = c("mp3", "wav"),
voice = "Joanna",
bind_audio = TRUE,
save_local = FALSE,
save_local_dest = NULL,
...
)
tts_google(
text,
output_format = c("mp3", "wav"),
voice = "en-US-Standard-C",
bind_audio = TRUE,
save_local = FALSE,
save_local_dest = NULL,
...
)
tts_microsoft(
text,
output_format = c("mp3", "wav"),
voice = NULL,
bind_audio = TRUE,
save_local = FALSE,
save_local_dest = NULL,
...
)
tts_coqui(
text,
exec_path,
output_format = c("wav", "mp3"),
model_name = "tacotron2-DDC_ph",
vocoder_name = "ljspeech/univnet",
bind_audio = TRUE,
save_local = FALSE,
save_local_dest = NULL,
...
)
tts_speechify(
text,
output_format = c("mp3", "wav"),
voice = "geffen_32",
model = "simba-3.2",
bind_audio = TRUE,
save_local = FALSE,
save_local_dest = NULL,
...
)
A standardized tibble featuring the following columns:
index : Sequential identifier number
original_text : The text input provided by the user
text : In case original_text exceeds the character limit, text represents the outcome of splitting original_text. Otherwise, text remains the same as original_text.
wav : Wave object (S4 class)
file : File path to the audio file
audio_type : The audio format, either mp3 or wav
duration : The duration of the audio file
service : The text-to-speech engine used
A character vector of text to be spoken
Format of output files: "mp3" or "wav"
Service to use (Amazon, Google, Microsoft, Coqui, or Speechify)
Should the 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?
Additional arguments
Full voice name
Should the audio file be saved locally?
If to be saved locally, destination where output file will be saved
System path to Coqui TTS executable
(Coqui TTS only) Deep Learning model for Text-to-Speech Conversion
(Coqui TTS only) Voice coder used for speech coding and transmission
(Speechify only) Model used for synthesis. The default, "simba-3.2", is English only; use "simba-3.0" for voices in other languages
if (FALSE) {
# Amazon Polly
tts("Hello world! This is Amazon Polly", service = "amazon")
tts("Hello world! This is Coqui TTS", service = "coqui")
tts("Hello world! This is Google Cloud", service = "google")
tts("Hello world! This is Microsoft", service = "microsoft")
tts("Hello world! This is Speechify", service = "speechify")
}
Run the code above in your browser using DataLab