Learn R Programming

mscstts (version 0.6.3)

ms_synthesize: Get Microsoft Text To Speech (TTS) or Cognitive Services Token from API Key

Description

Get Microsoft Text To Speech (TTS) or Cognitive Services Token from API Key

Usage

ms_synthesize(
  script,
  token = NULL,
  api_key = NULL,
  gender = c("Female", "Male"),
  language = "en-US",
  voice = NULL,
  output_format = c("raw-16khz-16bit-mono-pcm", "raw-8khz-8bit-mono-mulaw",
    "riff-8khz-8bit-mono-alaw", "riff-8khz-8bit-mono-mulaw", "riff-16khz-16bit-mono-pcm",
    "audio-16khz-128kbitrate-mono-mp3", "audio-16khz-64kbitrate-mono-mp3",
    "audio-16khz-32kbitrate-mono-mp3", "raw-24khz-16bit-mono-pcm",
    "riff-24khz-16bit-mono-pcm", "audio-24khz-160kbitrate-mono-mp3",
    "audio-24khz-96kbitrate-mono-mp3", "audio-24khz-48kbitrate-mono-mp3"),
  escape = FALSE,
  region = NULL,
  api = c("tts", "bing"),
  ...
)

ms_region(region = ms_regions())

ms_regions()

ms_set_region(region = ms_regions())

ms_synthesize_api_url(api = c("tts", "bing"), region = NULL)

Arguments

script

A character vector of lines to be spoken

token

An authentication token, base-64 encoded usually from ms_get_tts_token. If not provided, will be created from ms_get_tts_token

api_key

Microsoft Cognitive Services API key, if token is not provided.

gender

Sex of the Speaker

language

Language to be spoken, must be from ms_language_codes

voice

full voice name, usually from ms_language_to_ms_name. Will override language and gender.

escape

Should non-standard characters be substituted? Should not be used if script has SSML tags. See ms_create_ssml

api

which API to authorize on, either tts for text to speech or bing for Bing text to speech API

...

Additional arguments to send to POST

Value

A list of the request, content, token, and `SSML`.

Examples

Run this code
# NOT RUN {
if (ms_have_tts_key()) {
res = ms_synthesize(
script = "hey, how are you doing? I'm doing pretty good",
output_format = "audio-16khz-128kbitrate-mono-mp3")
tmp <- tempfile(fileext = ".mp3")
writeBin(res$content, con = tmp)
mp3 = tuneR::readMP3(tmp)
}

# }
# NOT RUN {
ms_regions()
# }

Run the code above in your browser using DataLab