TsgcTextToSpeechGoogleProperties › GoogleOptions

GoogleOptions Property

Google Cloud Text-To-Speech configuration: service-account settings, voice, language and audio encoding.

Syntax

property GoogleOptions: TsgcTextToSpeechGoogleOptions read FGoogleOptions write SetGoogleOptions;

Default Value

Remarks

Configures the Google Cloud Text-To-Speech request. Settings holds the JSON service-account key downloaded from the Google Cloud Console - it is used to build the JWT exchanged for a Bearer token. Language is the BCP-47 language code (default es-ES), VoiceId selects the voice name (default es-ES-Neural2-C), Gender sets the SSML gender (FEMALE or MALE), AudioEncoding picks the output codec (default MP3) and FileName is the local path where the decoded audio will be stored.

Example

oTTS := TsgcTextToSpeech_Google.Create(nil);
oTTS.GoogleOptions.Settings.LoadFromFile('service-account.json');
oTTS.GoogleOptions.Language := 'en-US';
oTTS.GoogleOptions.VoiceId := 'en-US-Standard-A';
oTTS.GoogleOptions.Gender := 'FEMALE';
oTTS.GoogleOptions.AudioEncoding := 'MP3';
oTTS.GoogleOptions.FileName := 'response.mp3';
oTTS.TextToSpeech('Hello from Google Cloud');

Back to Properties