Learn R Programming

googleLanguageR (version 0.2.0)

gl_talk: Perform text to speech

Description

Synthesizes speech synchronously: receive results after all text input has been processed.

Usage

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)

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 via gl_talk_languages for supported voices. Set to NULL to make the service choose a voice based on languageCode and gender.

audioEncoding

Format of the requested audio stream

speakingRate

Speaking rate/speed between 0.25 and 4.0

pitch

Speaking pitch between -20.0 and 20.0 in semitones.

volumeGainDb

Volumne gain in dB

sampleRateHertz

Sample rate for returned audio

Value

The file output name you supplied as output

Details

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

See Also

https://cloud.google.com/text-to-speech/docs/

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
gl_talk("The rain in spain falls mainly in the plain",
        output = "output.wav")

gl_talk("Testing my new audio player") %>% gl_talk_player()

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab