Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Perform text to speech

Source:R/text-to-speech.R
gl_talk.Rd

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,  inputType=c("text","ssml"),  effectsProfileIds=NULL)

Arguments

input

The text to turn into speech

output

Where to save the speech audio file

languageCode

The language of the voice as aBCP-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 toNULL to make the service choose a voice based onlanguageCode andgender.

audioEncoding

Format of the requested audio stream

speakingRate

Speaking rate/speed between0.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 betweentext (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

Value

The file output name you supplied asoutput

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.

See also

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

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")}# }

[8]ページ先頭

©2009-2025 Movatter.jp