Description Usage Arguments Details Value See Also Examples
View source: R/text-to-speech.R
Synthesizes speech synchronously: receive results after all text input has been processed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | gl_talk(
input,
output = "output.wav",
languageCode = "en",
gender = c("SSML_VOICE_GENDER_UNSPECIFIED", "MALE", "FEMALE", "NEUTRAL"),
name = NULL,
audioEncoding = c("LINEAR16", "MP3", "OGG_OPUS"),
speakingRate = 1,
pitch = 0,
volumeGainDb = 0,
sampleRateHertz = NULL,
inputType = c("text", "ssml"),
effectsProfileIds = NULL
)
|
input |
The text to turn into speech |
output |
Where to save the speech audio file |
languageCode |
The language of the voice as a |
gender |
The gender of the voice, if available |
name |
Name of the voice, see list via gl_talk_languages for supported voices. Set to |
audioEncoding |
Format of the requested audio stream |
speakingRate |
Speaking rate/speed between |
pitch |
Speaking pitch between |
volumeGainDb |
Volumne gain in dB |
sampleRateHertz |
Sample rate for returned audio |
inputType |
Choose between |
effectsProfileIds |
Optional. An identifier which selects 'audio effects' profiles that are applied on (post synthesized) text to speech. Effects are applied on top of each other in the order they are given |
Requires the Cloud Text-To-Speech API to be activated for your Google Cloud project.
Supported voices are here https://cloud.google.com/text-to-speech/docs/voices and can be imported into R via gl_talk_languages
To play the audio in code via a browser see gl_talk_player
To use Speech Synthesis Markup Language (SSML) select inputType=ssml
- more details on using this to insert pauses, sounds and breaks in your audio can be found here: https://cloud.google.com/text-to-speech/docs/ssml
To use audio profiles, supply a character vector of the available audio profiles listed here: https://cloud.google.com/text-to-speech/docs/audio-profiles - the audio profiles are applied in the order given. For instance effectsProfileIds="wearable-class-device"
will optimise output for smart watches, effectsProfileIds=c("wearable-class-device","telephony-class-application")
will apply sound filters optimised for smart watches, then telephonic devices.
The file output name you supplied as output
https://cloud.google.com/text-to-speech/docs/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
library(magrittr)
gl_talk("The rain in spain falls mainly in the plain",
output = "output.wav")
gl_talk("Testing my new audio player") %>% gl_talk_player()
# using SSML
gl_talk('<speak>The <say-as interpret-as=\"characters\">SSML</say-as>
standard <break time=\"1s\"/>is defined by the
<sub alias=\"World Wide Web Consortium\">W3C</sub>.</speak>',
inputType = "ssml")
# using effects profiles
gl_talk("This sounds great on headphones",
effectsProfileIds = "headphone-class-device")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.