ms_synthesize

0th

Percentile

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

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.

output_format

Format of the output, see https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-migrate-from-bing-speech for more information

escape

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

region

Subscription region for your key. See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/overview#reference-docs

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`.

Note

The content is likely in a binary format and the output depends on the `output_format` chosen. For example, if the `output_format` is an `MP3`, then see below example

Aliases
  • ms_synthesize
  • ms_region
  • ms_regions
  • ms_set_region
  • ms_synthesize_api_url
Examples
# 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()
# }
Documentation reproduced from package mscstts, version 0.6.2, License: GPL-3

Community examples

Looks like there are no examples yet.