TsgcTextToSpeechGoogle › Methods › TextToSpeech
Sends the text to Google Cloud Text-To-Speech and stores the synthesized audio in GoogleOptions.FileName.
procedure TextToSpeech(const aText: string);
| Name | Type | Description |
|---|---|---|
aText | const string | Text to be synthesized. Sent as the input.text field of the Google Cloud request. |
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.
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.');