Synthesizes speech synchronously: receive results after all text input has been processed.
Arguments
- input
The text to turn into speech
- output
Where to save the speech audio file
- languageCode
The language of the voice as a
BCP-47
language code- gender
The gender of the voice, if available
- name
Name of the voice, see list viagl_talk_languages for supported voices. Set to
NULL
to make the service choose a voice based onlanguageCode
andgender
.- audioEncoding
Format of the requested audio stream
- speakingRate
Speaking rate/speed between
0.25
and4.0
- pitch
Speaking pitch between
-20.0
and20.0
in semitones.- volumeGainDb
Volumne gain in dB
- sampleRateHertz
Sample rate for returned audio
- inputType
Choose between
text
(the default) or SSML markup. Theinput
text must be SSML markup if you choosessml
- 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
Details
Requires the Cloud Text-To-Speech API to be activated for your Google Cloud project.
Supported voices are herehttps://cloud.google.com/text-to-speech/docs/voices and can be imported into R viagl_talk_languages
To play the audio in code via a browser seegl_talk_player
To use Speech Synthesis Markup Language (SSML) selectinputType=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 instanceeffectsProfileIds="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.
Examples
if(FALSE){# \dontrun{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 SSMLgl_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 profilesgl_talk("This sounds great on headphones", effectsProfileIds="headphone-class-device")}# }