Created
August 16, 2018 22:36
-
-
Save revodavid/d650bd6b31f5ec5b3ae633695aedb276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(checkpoint) | |
checkpoint("2018-08-14") | |
library(fortunes) | |
library(mscstts) | |
set_ms_tts_key("8e61ae64924647d1a2833d68eeced78e") | |
out <- ms_synthesize("hello, world!", output_format = "audio-16khz-128kbitrate-mono-mp3") | |
f <- tempfile(fileext=".mp3") | |
writeBin(out$content, f) | |
shell(paste("start ", f)) | |
say <- function(text, gender="Female", language="en-US", cmd="start") { | |
out <- ms_synthesize(gsub("[<>/]","",text), | |
gender=gender, | |
language=language, | |
output_format = "audio-16khz-128kbitrate-mono-mp3") | |
file <- tempfile(fileext=".mp3") | |
writeBin(out$content, file) | |
shell(paste(cmd, file)) | |
} | |
say("Welcome to R, a free software environment for statistical computing and graphics.") | |
say("I'm sorry Dave, I can't do that.", gender="Male") | |
say("Crikey! That's a big crocodile.", language="en-AU") | |
say("Non, je ne regrette rien", gender="Female", language = "fr-FR") | |
fortune(275) | |
say(fortune(275)$quote) |
I am keen to experiment with TTS and signed up for an account as per your August 16, 2018 Revolutions 'Make R speak' post.
However the shell(paste("start ", f)) and shell(paste(cmd, file)) statements result in '... error in running command'.
What are the equivalent commands for a Linux-Ubuntu platform?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm on a Mac and needed to replace line 11 with:
system2('afplay', f)
The
say()
function would also require modification.