TsgcTextToSpeechGoogleMethods › TextToSpeech

TextToSpeech Method

Sends the text to Google Cloud Text-To-Speech and stores the synthesized audio in GoogleOptions.FileName.

Syntax

procedure TextToSpeech(const aText: string);

Parameters

NameTypeDescription
aTextconst stringText to be synthesized. Sent as the input.text field of the Google Cloud request.

Remarks

Builds a Google Cloud text:synthesize request using GoogleOptions, obtains a Bearer token through the service-account JWT defined by GoogleOptions.Settings, base64-decodes the audioContent returned by Google into GoogleOptions.FileName and - if an AudioPlayer is assigned - plays the file. The file is deleted after playback.

Example

oTTS.GoogleOptions.VoiceId := 'en-US-Standard-A';
oTTS.GoogleOptions.Language := 'en-US';
oTTS.GoogleOptions.FileName := 'out.mp3';
oTTS.TextToSpeech('The quick brown fox jumps over the lazy dog.');

Back to Methods