jhudsl / mscstts

R Client for the Microsoft Cognitive Services Text to Speech REST API
GNU General Public License v3.0
8 stars 6 forks source link

Example in README not working as is #12

Open moodymudskipper opened 3 years ago

moodymudskipper commented 3 years ago

I had to change it to (see my comments inline) :

library(mscstts)
if (ms_have_tts_key(api_key = "c7611c44ed05426088dc2bf4c762bf65")) {
  res = ms_synthesize(
    region ="westeurope", # default seems to be the first of `ms_regions()` i.e. "westus"
    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" wasn't recognized, probably because I'm on windows, removing the default worked ok
}

Thanks for this package!