The goal of mscstts
is to provide an R Client for the Microsoft Cognitive Services Text to Speech REST API, including voice synthesis. A valid account MUST be registered at the Microsoft Cognitive Services website https://www.microsoft.com/cognitive-services/ in order to obtain a (free) API key. Without an API key, this package will not work properly.
See the documentation here: https://docs.microsoft.com/en-us/azure/cognitive-services/speech/home
You can get a TTS API key here: https://azure.microsoft.com/en-us/try/cognitive-services/. The API you need to get one from is Bing Speech. (This will be deprecated! See below)
+ Create a Resource
+ Create
You can install mscstts
from GitHub with:
library(mscstts)
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("example", fileext = ".mp3")
writeBin(res$content, con = tmp)
mp3 = tuneR::readMP3(tmp)
}
testthat::expect_true(file.size(tmp) > 50000)
if (interactive()) {
tuneR::play(mp3, player = "play")
}