Service Client: Google::Cloud::Texttospeech::V1beta1::CloudTts::TextToSpeechClient

Client stub representing the remote TextToSpeech gRPC service. Delegates call dispatching to Google::gRPC::Client.

target

The endpoint target address. Defaults to texttospeech.googleapis.com:443.

credentials

The authentication credentials provider. Defaults to application default credentials via Google::Auth.

NAME

Google::Cloud::Texttospeech::V1beta1::CloudTts - Compiled Protocol Buffers messages for google/cloud/texttospeech/v1beta1/cloud_tts.proto

SYNOPSIS

use Google::Cloud::Texttospeech::V1beta1::CloudTts;

my $msg = Google::Cloud::Texttospeech::V1beta1::CloudTts::ListVoicesRequest->new({
    language_code => $language_code,
});

# Read or update a field
my $val = $msg->language_code();

# Binary wire-format roundtrip
my $bytes   = $msg->serialize();
my $decoded = Google::Cloud::Texttospeech::V1beta1::CloudTts::ListVoicesRequest->parse($bytes);

# Canonical ProtoJSON
my $json = $msg->to_json();

DESCRIPTION

Auto-generated Protobuf message classes compiled from google/cloud/texttospeech/v1beta1/cloud_tts.proto. All message classes inherit from Protobuf::Message and support new(), serialize(), parse(), to_json(), from_json(), to_text(), and to_perl().

MESSAGES

Google::Cloud::Texttospeech::V1beta1::CloudTts::ListVoicesRequest

The top-level message sent by the client for the `ListVoices` method.

Inherits from Protobuf::Message.

Accessors

  • $msg->language_code() / $msg->language_code($value)

    Type: String

    Optional. Recommended. [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If not specified, the API will return all supported voices. If specified, the ListVoices call will only return voices that can be used to synthesize this language_code. For example, if you specify `"en-NZ"`, all `"en-NZ"` voices will be returned. If you specify `"no"`, both `"no-\*"` (Norwegian) and `"nb-\*"` (Norwegian Bokmal) voices will be returned.

Google::Cloud::Texttospeech::V1beta1::CloudTts::ListVoicesResponse

The message returned to the client by the `ListVoices` method.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::Voice

Description of a voice supported by the TTS service.

Inherits from Protobuf::Message.

Accessors

  • $msg->language_codes() / $msg->language_codes($value)

    Type: String

    The languages that this voice supports, expressed as [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g. "en-US", "es-419", "cmn-tw").

  • $msg->name() / $msg->name($value)

    Type: String

    The name of this voice. Each distinct voice has a unique name.

  • $msg->ssml_gender() / $msg->ssml_gender($value)

    Type: Enum (Google::Cloud::Texttospeech::V1beta1::SsmlVoiceGender)

    The gender of this voice.

  • $msg->natural_sample_rate_hertz() / $msg->natural_sample_rate_hertz($value)

    Type: Int32

    The natural sample rate (in hertz) for this voice.

Google::Cloud::Texttospeech::V1beta1::CloudTts::AdvancedVoiceOptions

Used for advanced voice options.

Inherits from Protobuf::Message.

Accessors

  • $msg->low_latency_journey_synthesis() / $msg->low_latency_journey_synthesis($value)

    Type: Bool

    Only for Journey voices. If false, the synthesis is context aware and has a higher latency.

  • $msg->relax_safety_filters() / $msg->relax_safety_filters($value)

    Type: Bool

    Optional. Input only. Deprecated, use safety_settings instead. If true, relaxes safety filters for Gemini TTS.

  • $msg->safety_settings() / $msg->safety_settings($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::AdvancedVoiceOptions::SafetySettings)

    Optional. Input only. This applies to Gemini TTS only. If set, the category specified in the safety setting will be blocked if the harm probability is above the threshold. Otherwise, the safety filter will be disabled by default.

  • $msg->enable_textnorm() / $msg->enable_textnorm($value)

    Type: Bool

    Optional. If true, textnorm will be applied to text input. This feature is enabled by default. Only applies for Gemini TTS.

Enum: AdvancedVoiceOptions::HarmCategory

  • HARM_CATEGORY_UNSPECIFIED => 0

  • HARM_CATEGORY_HATE_SPEECH => 1

  • HARM_CATEGORY_DANGEROUS_CONTENT => 2

  • HARM_CATEGORY_HARASSMENT => 3

  • HARM_CATEGORY_SEXUALLY_EXPLICIT => 4

Enum: AdvancedVoiceOptions::HarmBlockThreshold

  • HARM_BLOCK_THRESHOLD_UNSPECIFIED => 0

  • BLOCK_LOW_AND_ABOVE => 1

  • BLOCK_MEDIUM_AND_ABOVE => 2

  • BLOCK_ONLY_HIGH => 3

  • BLOCK_NONE => 4

  • OFF => 5

Google::Cloud::Texttospeech::V1beta1::CloudTts::SynthesizeSpeechRequest

The top-level message sent by the client for the `SynthesizeSpeech` method.

Inherits from Protobuf::Message.

Accessors

Enum: SynthesizeSpeechRequest::TimepointType

  • TIMEPOINT_TYPE_UNSPECIFIED => 0

  • SSML_MARK => 1

Google::Cloud::Texttospeech::V1beta1::CloudTts::CustomPronunciationParams

Pronunciation customization for a phrase.

Inherits from Protobuf::Message.

Accessors

  • $msg->phrase() / $msg->phrase($value)

    Type: String

    The phrase to which the customization is applied. The phrase can be multiple words, such as proper nouns, but shouldn't span the length of the sentence.

  • $msg->phonetic_encoding() / $msg->phonetic_encoding($value)

    Type: Enum (Google::Cloud::Texttospeech::V1beta1::CustomPronunciationParams::PhoneticEncoding)

    The phonetic encoding of the phrase.

  • $msg->pronunciation() / $msg->pronunciation($value)

    Type: String

    The pronunciation of the phrase. This must be in the phonetic encoding specified above.

Enum: CustomPronunciationParams::PhoneticEncoding

  • PHONETIC_ENCODING_UNSPECIFIED => 0

  • PHONETIC_ENCODING_IPA => 1

  • PHONETIC_ENCODING_X_SAMPA => 2

  • PHONETIC_ENCODING_JAPANESE_YOMIGANA => 3

  • PHONETIC_ENCODING_PINYIN => 4

Google::Cloud::Texttospeech::V1beta1::CloudTts::CustomPronunciations

A collection of pronunciation customizations.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::MultiSpeakerMarkup

A collection of turns for multi-speaker synthesis.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::MultispeakerPrebuiltVoice

Configuration for a single speaker in a Gemini TTS multi-speaker setup. Enables dialogue between two speakers.

Inherits from Protobuf::Message.

Accessors

  • $msg->speaker_alias() / $msg->speaker_alias($value)

    Type: String

    Required. The speaker alias of the voice. This is the user-chosen speaker name that is used in the multispeaker text input, such as "Speaker1".

  • $msg->speaker_id() / $msg->speaker_id($value)

    Type: String

    Required. The speaker ID of the voice. See https://cloud.google.com/text-to-speech/docs/gemini-tts#voice_options for available values.

Google::Cloud::Texttospeech::V1beta1::CloudTts::MultiSpeakerVoiceConfig

Configuration for a multi-speaker text-to-speech setup. Enables the use of up to two distinct voices in a single synthesis request.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::SynthesisInput

Contains text input to be synthesized. Either `text` or `ssml` must be supplied. Supplying both or neither returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. The input size is limited to 5000 bytes.

Inherits from Protobuf::Message.

Accessors

  • $msg->text() / $msg->text($value)

    Type: String

    The raw text to be synthesized.

  • $msg->markup() / $msg->markup($value)

    Type: String

    Markup for Chirp 3: HD voices specifically. This field may not be used with any other voices.

  • $msg->ssml() / $msg->ssml($value)

    Type: String

    The SSML document to be synthesized. The SSML document must be valid and well-formed. Otherwise the RPC will fail and return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. For more information, see [SSML](https://cloud.google.com/text-to-speech/docs/ssml).

  • $msg->multi_speaker_markup() / $msg->multi_speaker_markup($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::MultiSpeakerMarkup)

    The multi-speaker input to be synthesized. Only applicable for multi-speaker synthesis.

  • $msg->prompt() / $msg->prompt($value)

    Type: String

    This system instruction is supported only for controllable/promptable voice models. If this system instruction is used, we pass the unedited text to Gemini-TTS. Otherwise, a default system instruction is used. AI Studio calls this system instruction, Style Instructions.

  • $msg->custom_pronunciations() / $msg->custom_pronunciations($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::CustomPronunciations)

    Optional. The pronunciation customizations are applied to the input. If this is set, the input is synthesized using the given pronunciation customizations.

    The initial support is for en-us, with plans to expand to other locales in the future. Instant Clone voices aren't supported.

    In order to customize the pronunciation of a phrase, there must be an exact match of the phrase in the input types. If using SSML, the phrase must not be inside a phoneme tag.

Google::Cloud::Texttospeech::V1beta1::CloudTts::VoiceSelectionParams

Description of which voice to use for a synthesis request.

Inherits from Protobuf::Message.

Accessors

  • $msg->language_code() / $msg->language_code($value)

    Type: String

    Required. The language (and potentially also the region) of the voice expressed as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g. "en-US". This should not include a script tag (e.g. use "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred from the input provided in the SynthesisInput. The TTS service will use this parameter to help choose an appropriate voice. Note that the TTS service may choose a voice with a slightly different language code than the one selected; it may substitute a different region (e.g. using en-US rather than en-CA if there isn't a Canadian voice available), or even a different language, e.g. using "nb" (Norwegian Bokmal) instead of "no" (Norwegian)".

  • $msg->name() / $msg->name($value)

    Type: String

    The name of the voice. If both the name and the gender are not set, the service will choose a voice based on the other parameters such as language_code.

  • $msg->ssml_gender() / $msg->ssml_gender($value)

    Type: Enum (Google::Cloud::Texttospeech::V1beta1::SsmlVoiceGender)

    The preferred gender of the voice. If not set, the service will choose a voice based on the other parameters such as language_code and name. Note that this is only a preference, not requirement; if a voice of the appropriate gender is not available, the synthesizer should substitute a voice with a different gender rather than failing the request.

  • $msg->custom_voice() / $msg->custom_voice($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::CustomVoiceParams)

    The configuration for a custom voice. If [CustomVoiceParams.model] is set, the service will choose the custom voice matching the specified configuration.

  • $msg->voice_clone() / $msg->voice_clone($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::VoiceCloneParams)

    Optional. The configuration for a voice clone. If [VoiceCloneParams.voice_clone_key] is set, the service chooses the voice clone matching the specified configuration.

  • $msg->model_name() / $msg->model_name($value)

    Type: String

    Optional. The name of the model. If set, the service will choose the model matching the specified configuration.

  • $msg->multi_speaker_voice_config() / $msg->multi_speaker_voice_config($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::MultiSpeakerVoiceConfig)

    Optional. The configuration for a Gemini multi-speaker text-to-speech setup. Enables the use of two distinct voices in a single synthesis request.

Google::Cloud::Texttospeech::V1beta1::CloudTts::AudioConfig

Description of audio data to be synthesized.

Inherits from Protobuf::Message.

Accessors

  • $msg->audio_encoding() / $msg->audio_encoding($value)

    Type: Enum (Google::Cloud::Texttospeech::V1beta1::AudioEncoding)

    Required. The format of the audio byte stream.

  • $msg->speaking_rate() / $msg->speaking_rate($value)

    Type: Double

    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.

  • $msg->pitch() / $msg->pitch($value)

    Type: Double

    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.

  • $msg->volume_gain_db() / $msg->volume_gain_db($value)

    Type: Double

    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.

  • $msg->sample_rate_hertz() / $msg->sample_rate_hertz($value)

    Type: Int32

    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 return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].

  • $msg->effects_profile_id() / $msg->effects_profile_id($value)

    Type: String

    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. See [audio profiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for current supported profile ids.

Google::Cloud::Texttospeech::V1beta1::CloudTts::CustomVoiceParams

Description of the custom voice to be synthesized.

Inherits from Protobuf::Message.

Accessors

Enum: CustomVoiceParams::ReportedUsage

  • REPORTED_USAGE_UNSPECIFIED => 0

  • REALTIME => 1

  • OFFLINE => 2

Google::Cloud::Texttospeech::V1beta1::CloudTts::VoiceCloneParams

The configuration of Voice Clone feature.

Inherits from Protobuf::Message.

Accessors

  • $msg->voice_cloning_key() / $msg->voice_cloning_key($value)

    Type: String

    Required. Created by GenerateVoiceCloningKey.

Google::Cloud::Texttospeech::V1beta1::CloudTts::SynthesizeSpeechResponse

The message returned to the client by the `SynthesizeSpeech` method.

Inherits from Protobuf::Message.

Accessors

  • $msg->audio_content() / $msg->audio_content($value)

    Type: Bytes

    The audio data bytes encoded as specified in the request, including the header for encodings that are wrapped in containers (e.g. MP3, OGG_OPUS). For LINEAR16 audio, we include the WAV header. Note: as with all bytes fields, protobuffers use a pure binary representation, whereas JSON representations use base64.

  • $msg->timepoints() / $msg->timepoints($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::Timepoint)

    A link between a position in the original request input and a corresponding time in the output audio. It's only supported via `<mark>` of SSML input.

  • $msg->audio_config() / $msg->audio_config($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::AudioConfig)

    The audio metadata of `audio_content`.

Google::Cloud::Texttospeech::V1beta1::CloudTts::Timepoint

This contains a mapping between a certain point in the input text and a corresponding time in the output audio.

Inherits from Protobuf::Message.

Accessors

  • $msg->mark_name() / $msg->mark_name($value)

    Type: String

    Timepoint name as received from the client within `<mark>` tag.

  • $msg->time_seconds() / $msg->time_seconds($value)

    Type: Double

    Time offset in seconds from the start of the synthesized audio.

Google::Cloud::Texttospeech::V1beta1::CloudTts::StreamingAudioConfig

Description of the desired output audio data.

Inherits from Protobuf::Message.

Accessors

  • $msg->audio_encoding() / $msg->audio_encoding($value)

    Type: Enum (Google::Cloud::Texttospeech::V1beta1::AudioEncoding)

    Required. The format of the audio byte stream. Streaming supports PCM, ALAW, MULAW and OGG_OPUS. All other encodings return an error.

  • $msg->sample_rate_hertz() / $msg->sample_rate_hertz($value)

    Type: Int32

    Optional. The synthesis sample rate (in hertz) for this audio.

  • $msg->speaking_rate() / $msg->speaking_rate($value)

    Type: Double

    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.

Google::Cloud::Texttospeech::V1beta1::CloudTts::StreamingSynthesizeConfig

Provides configuration information for the StreamingSynthesize request.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::StreamingSynthesisInput

Input to be synthesized.

Inherits from Protobuf::Message.

Accessors

  • $msg->text() / $msg->text($value)

    Type: String

    The raw text to be synthesized. It is recommended that each input contains complete, terminating sentences, which results in better prosody in the output audio.

  • $msg->markup() / $msg->markup($value)

    Type: String

    Markup for Chirp 3: HD voices specifically. This field may not be used with any other voices.

  • $msg->multi_speaker_markup() / $msg->multi_speaker_markup($value)

    Type: Message (Google::Cloud::Texttospeech::V1beta1::CloudTts::MultiSpeakerMarkup)

    Multi-speaker markup for Gemini TTS. This field may not be used with any other voices.

  • $msg->prompt() / $msg->prompt($value)

    Type: String

    This is system instruction supported only for controllable voice models.

Google::Cloud::Texttospeech::V1beta1::CloudTts::StreamingSynthesizeRequest

Request message for the `StreamingSynthesize` method. Multiple `StreamingSynthesizeRequest` messages are sent in one call. The first message must contain a `streaming_config` that fully specifies the request configuration and must not contain `input`. All subsequent messages must only have `input` set.

Inherits from Protobuf::Message.

Accessors

Google::Cloud::Texttospeech::V1beta1::CloudTts::StreamingSynthesizeResponse

`StreamingSynthesizeResponse` is the only message returned to the client by `StreamingSynthesize` method. A series of zero or more `StreamingSynthesizeResponse` messages are streamed back to the client.

Inherits from Protobuf::Message.

Accessors

  • $msg->audio_content() / $msg->audio_content($value)

    Type: Bytes

    The audio data bytes encoded as specified in the request. This is headerless LINEAR16 audio with a sample rate of 24000.

SEE ALSO

Protobuf, Protobuf::Message, Google::Cloud::Texttospeech::V1beta1::CloudTts::Types, https://protobuf.dev/

LICENSE AND COPYRIGHT

Copyright (C) 2026 Google LLC

This program is released under the Apache 2.0 license.