Reference documentation and code samples for the Cloud Text-to-Speech V1 Client class AudioConfig.
Description of audio data to be synthesized.
Generated from protobuf messagegoogle.cloud.texttospeech.v1.AudioConfig
Namespace
Google \ Cloud \ TextToSpeech \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ audio_encoding
int
Required. The format of the audio byte stream.
↳ speaking_rate
float
Optional. Input only. Speaking rate/speed, in the range [0.25, 2.0]. 1.0 is the normal native speed supported by the specific voice. 2.0 is twice as fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any other values < 0.25 or > 2.0 will return an error.
↳ pitch
float
Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20 semitones from the original pitch. -20 means decrease 20 semitones from the original pitch.
↳ volume_gain_db
float
Optional. Input only. Volume gain (in dB) of the normal native volume supported by the specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB) will play at approximately half the amplitude of the normal native signal amplitude. A value of +6.0 (dB) will play at approximately twice the amplitude of the normal native signal amplitude. Strongly recommend not to exceed +10 (dB) as there's usually no effective increase in loudness for any value greater than that.
↳ sample_rate_hertz
int
Optional. The synthesis sample rate (in hertz) for this audio. When this is specified in SynthesizeSpeechRequest, if this is different from the voice's natural sample rate, then the synthesizer will honor this request by converting to the desired sample rate (which might result in worse audio quality), unless the specified sample rate is not supported for the encoding chosen, in which case it will fail the request and returngoogle.rpc.Code.INVALID_ARGUMENT.
↳ effects_profile_id
array
Optional. Input only. 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. Seeaudio profilesfor current supported profile ids.
getAudioEncoding
Required. The format of the audio byte stream.
Returns
Type
Description
int
Enum of typeAudioEncoding.
setAudioEncoding
Required. The format of the audio byte stream.
Parameter
Name
Description
var
int
Enum of typeAudioEncoding.
Returns
Type
Description
$this
getSpeakingRate
Optional. Input only. Speaking rate/speed, in the range [0.25, 2.0]. 1.0 is
the normal native speed supported by the specific voice. 2.0 is twice as
fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0
speed. Any other values < 0.25 or > 2.0 will return an error.
Returns
Type
Description
float
setSpeakingRate
Optional. Input only. Speaking rate/speed, in the range [0.25, 2.0]. 1.0 is
the normal native speed supported by the specific voice. 2.0 is twice as
fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0
speed. Any other values < 0.25 or > 2.0 will return an error.
Parameter
Name
Description
var
float
Returns
Type
Description
$this
getPitch
Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
increase 20 semitones from the original pitch. -20 means decrease 20
semitones from the original pitch.
Returns
Type
Description
float
setPitch
Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
increase 20 semitones from the original pitch. -20 means decrease 20
semitones from the original pitch.
Parameter
Name
Description
var
float
Returns
Type
Description
$this
getVolumeGainDb
Optional. Input only. Volume gain (in dB) of the normal native volume
supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
set to a value of 0.0 (dB), will play at normal native signal amplitude. A
value of -6.0 (dB) will play at approximately half the amplitude of the
normal native signal amplitude. A value of +6.0 (dB) will play at
approximately twice the amplitude of the normal native signal amplitude.
Strongly recommend not to exceed +10 (dB) as there's usually no effective
increase in loudness for any value greater than that.
Returns
Type
Description
float
setVolumeGainDb
Optional. Input only. Volume gain (in dB) of the normal native volume
supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
set to a value of 0.0 (dB), will play at normal native signal amplitude. A
value of -6.0 (dB) will play at approximately half the amplitude of the
normal native signal amplitude. A value of +6.0 (dB) will play at
approximately twice the amplitude of the normal native signal amplitude.
Strongly recommend not to exceed +10 (dB) as there's usually no effective
increase in loudness for any value greater than that.
Parameter
Name
Description
var
float
Returns
Type
Description
$this
getSampleRateHertz
Optional. The synthesis sample rate (in hertz) for this audio. When this is
specified in SynthesizeSpeechRequest, if this is different from the voice's
natural sample rate, then the synthesizer will honor this request by
converting to the desired sample rate (which might result in worse audio
quality), unless the specified sample rate is not supported for the
encoding chosen, in which case it will fail the request and returngoogle.rpc.Code.INVALID_ARGUMENT.
Returns
Type
Description
int
setSampleRateHertz
Optional. The synthesis sample rate (in hertz) for this audio. When this is
specified in SynthesizeSpeechRequest, if this is different from the voice's
natural sample rate, then the synthesizer will honor this request by
converting to the desired sample rate (which might result in worse audio
quality), unless the specified sample rate is not supported for the
encoding chosen, in which case it will fail the request and returngoogle.rpc.Code.INVALID_ARGUMENT.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getEffectsProfileId
Optional. Input only. 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. Seeaudio
profilesfor
current supported profile ids.
Optional. Input only. 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. Seeaudio
profilesfor
current supported profile ids.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# Cloud Text-to-Speech V1 Client - Class AudioConfig (2.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.2.2 (latest)](/php/docs/reference/cloud-text-to-speech/latest/V1.AudioConfig)\n- [2.2.1](/php/docs/reference/cloud-text-to-speech/2.2.1/V1.AudioConfig)\n- [2.0.1](/php/docs/reference/cloud-text-to-speech/2.0.1/V1.AudioConfig)\n- [1.12.2](/php/docs/reference/cloud-text-to-speech/1.12.2/V1.AudioConfig)\n- [1.11.0](/php/docs/reference/cloud-text-to-speech/1.11.0/V1.AudioConfig)\n- [1.10.0](/php/docs/reference/cloud-text-to-speech/1.10.0/V1.AudioConfig)\n- [1.9.1](/php/docs/reference/cloud-text-to-speech/1.9.1/V1.AudioConfig)\n- [1.8.5](/php/docs/reference/cloud-text-to-speech/1.8.5/V1.AudioConfig)\n- [1.7.2](/php/docs/reference/cloud-text-to-speech/1.7.2/V1.AudioConfig)\n- [1.6.1](/php/docs/reference/cloud-text-to-speech/1.6.1/V1.AudioConfig)\n- [1.5.6](/php/docs/reference/cloud-text-to-speech/1.5.6/V1.AudioConfig)\n- [1.4.5](/php/docs/reference/cloud-text-to-speech/1.4.5/V1.AudioConfig) \nReference documentation and code samples for the Cloud Text-to-Speech V1 Client class AudioConfig.\n\nDescription of audio data to be synthesized.\n\nGenerated from protobuf message `google.cloud.texttospeech.v1.AudioConfig`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ TextToSpeech \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getAudioEncoding\n\nRequired. The format of the audio byte stream.\n\n### setAudioEncoding\n\nRequired. The format of the audio byte stream.\n\n### getSpeakingRate\n\nOptional. Input only. Speaking rate/speed, in the range \\[0.25, 2.0\\]. 1.0 is\nthe normal native speed supported by the specific voice. 2.0 is twice as\nfast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0\nspeed. Any other values \\\u003c 0.25 or \\\u003e 2.0 will return an error.\n\n### setSpeakingRate\n\nOptional. Input only. Speaking rate/speed, in the range \\[0.25, 2.0\\]. 1.0 is\nthe normal native speed supported by the specific voice. 2.0 is twice as\nfast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0\nspeed. Any other values \\\u003c 0.25 or \\\u003e 2.0 will return an error.\n\n### getPitch\n\nOptional. Input only. Speaking pitch, in the range \\[-20.0, 20.0\\]. 20 means\nincrease 20 semitones from the original pitch. -20 means decrease 20\nsemitones from the original pitch.\n\n### setPitch\n\nOptional. Input only. Speaking pitch, in the range \\[-20.0, 20.0\\]. 20 means\nincrease 20 semitones from the original pitch. -20 means decrease 20\nsemitones from the original pitch.\n\n### getVolumeGainDb\n\nOptional. Input only. Volume gain (in dB) of the normal native volume\nsupported by the specific voice, in the range \\[-96.0, 16.0\\]. If unset, or\nset to a value of 0.0 (dB), will play at normal native signal amplitude. A\nvalue of -6.0 (dB) will play at approximately half the amplitude of the\nnormal native signal amplitude. A value of +6.0 (dB) will play at\napproximately twice the amplitude of the normal native signal amplitude.\n\nStrongly recommend not to exceed +10 (dB) as there's usually no effective\nincrease in loudness for any value greater than that.\n\n### setVolumeGainDb\n\nOptional. Input only. Volume gain (in dB) of the normal native volume\nsupported by the specific voice, in the range \\[-96.0, 16.0\\]. If unset, or\nset to a value of 0.0 (dB), will play at normal native signal amplitude. A\nvalue of -6.0 (dB) will play at approximately half the amplitude of the\nnormal native signal amplitude. A value of +6.0 (dB) will play at\napproximately twice the amplitude of the normal native signal amplitude.\n\nStrongly recommend not to exceed +10 (dB) as there's usually no effective\nincrease in loudness for any value greater than that.\n\n### getSampleRateHertz\n\nOptional. The synthesis sample rate (in hertz) for this audio. When this is\nspecified in SynthesizeSpeechRequest, if this is different from the voice's\nnatural sample rate, then the synthesizer will honor this request by\nconverting to the desired sample rate (which might result in worse audio\nquality), unless the specified sample rate is not supported for the\nencoding chosen, in which case it will fail the request and return\n[google.rpc.Code.INVALID_ARGUMENT](https://cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Code.html#_Google_Rpc_Code__INVALID_ARGUMENT).\n\n### setSampleRateHertz\n\nOptional. The synthesis sample rate (in hertz) for this audio. When this is\nspecified in SynthesizeSpeechRequest, if this is different from the voice's\nnatural sample rate, then the synthesizer will honor this request by\nconverting to the desired sample rate (which might result in worse audio\nquality), unless the specified sample rate is not supported for the\nencoding chosen, in which case it will fail the request and return\n[google.rpc.Code.INVALID_ARGUMENT](https://cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Code.html#_Google_Rpc_Code__INVALID_ARGUMENT).\n\n### getEffectsProfileId\n\nOptional. Input only. An identifier which selects 'audio effects' profiles\nthat are applied on (post synthesized) text to speech. Effects are applied\non top of each other in the order they are given. See\n[audio\nprofiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for\ncurrent supported profile ids.\n\n### setEffectsProfileId\n\nOptional. Input only. An identifier which selects 'audio effects' profiles\nthat are applied on (post synthesized) text to speech. Effects are applied\non top of each other in the order they are given. See\n[audio\nprofiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for\ncurrent supported profile ids."]]