Convert text to speech by using Speech Synthesis Markup Language (SSML)
Usage
ms_synthesize(
script,
region = "westus",
api_key = NULL,
token = NULL,
gender = c("Female", "Male"),
language = "en-US",
voice = NULL,
escape = FALSE
)
Arguments
- script
A character vector of text to be converted to speech
- region
Subscription region for API key. For more info, see https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/regions
- api_key
Microsoft Azure Cognitive Services API key
- token
An authentication token
- gender
Sex of the speaker
- language
Language to be spoken
- voice
Full voice name
- escape
Should non-standard characters be substituted?
Details
For more info, see Section Convert text to speech of the Microsoft documentation.
Examples
if (FALSE) { # ms_exist_key()
# Convert text to speech
res <- ms_synthesize(script = "Hello world, this is a talking computer testing test",
region = "westus",
gender = "Female")
# Returns hexadecimal representation of binary data
# Create temporary file to store audio output
output_path <- tempfile(fileext = ".wav")
# Write binary data to output path
writeBin(res, con = output_path)
# Play audio in browser
# play_audio(audio = output_path)
# Delete temporary file
file.remove(output_path)
}