Class TextToSpeechClient

Service that implements Google Cloud Text-to-Speech API.

Inheritance

builtins.object > TextToSpeechClient

Properties

transport

Returns the transport used by the client instance.

Returns
TypeDescription
TextToSpeechTransportThe transport used by the client instance.

Methods

__exit__

__exit__(type, value, traceback)

Releases underlying transport's resources.

.. warning:: ONLY use as a context manager if the transport is NOT shared with other clients! Exiting the with block will CLOSE the transport and may cause errors in other clients!

common_billing_account_path

common_billing_account_path(billing_account: str)

Returns a fully-qualified billing_account string.

Parameter
NameDescription
billing_account str

common_folder_path

common_folder_path(folder: str)

Returns a fully-qualified folder string.

Parameter
NameDescription
folder str

common_location_path

common_location_path(project: str, location: str)

Returns a fully-qualified location string.

Parameters
NameDescription
project str
location str

common_organization_path

common_organization_path(organization: str)

Returns a fully-qualified organization string.

Parameter
NameDescription
organization str

common_project_path

common_project_path(project: str)

Returns a fully-qualified project string.

Parameter
NameDescription
project str

from_service_account_file

from_service_account_file(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameters
NameDescription
filename str

The path to the service account private key json file.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TextToSpeechClientThe constructed client.

from_service_account_info

from_service_account_info(info: dict, *args, **kwargs)

Creates an instance of this client using the provided credentials info.

Parameters
NameDescription
info dict

The service account private key info.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TextToSpeechClientThe constructed client.

from_service_account_json

from_service_account_json(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameters
NameDescription
filename str

The path to the service account private key json file.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TextToSpeechClientThe constructed client.

list_voices

list_voices(request: Optional[Union[google.cloud.texttospeech_v1beta1.types.cloud_tts.ListVoicesRequest, dict]] = None, *, language_code: Optional[str] = None, retry: Union[google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
request Union[google.cloud.texttospeech_v1beta1.types.ListVoicesRequest, dict]

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

language_code str

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. E.g. when specifying "en-NZ", you will get supported "en-NZ" voices; when specifying "no", you will get supported "no-\*" (Norwegian) and "nb-\*" (Norwegian Bokmal) voices; specifying "zh" will also get supported "cmn-\*" voices; specifying "zh-hk" will also get supported "yue-hk" voices. This corresponds to the language_code field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.texttospeech_v1beta1.types.ListVoicesResponseThe message returned to the client by the ListVoices method.

model_path

model_path(project: str, location: str, model: str)

Returns a fully-qualified model string.

Parameters
NameDescription
project str
location str
model str

parse_common_billing_account_path

parse_common_billing_account_path(path: str)

Parse a billing_account path into its component segments.

Parameter
NameDescription
path str

parse_common_folder_path

parse_common_folder_path(path: str)

Parse a folder path into its component segments.

Parameter
NameDescription
path str

parse_common_location_path

parse_common_location_path(path: str)

Parse a location path into its component segments.

Parameter
NameDescription
path str

parse_common_organization_path

parse_common_organization_path(path: str)

Parse a organization path into its component segments.

Parameter
NameDescription
path str

parse_common_project_path

parse_common_project_path(path: str)

Parse a project path into its component segments.

Parameter
NameDescription
path str

parse_model_path

parse_model_path(path: str)

Parses a model path into its component segments.

Parameter
NameDescription
path str

synthesize_speech

synthesize_speech(request: Optional[Union[google.cloud.texttospeech_v1beta1.types.cloud_tts.SynthesizeSpeechRequest, dict]] = None, *, input: Optional[google.cloud.texttospeech_v1beta1.types.cloud_tts.SynthesisInput] = None, voice: Optional[google.cloud.texttospeech_v1beta1.types.cloud_tts.VoiceSelectionParams] = None, audio_config: Optional[google.cloud.texttospeech_v1beta1.types.cloud_tts.AudioConfig] = None, retry: Union[google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Synthesizes speech synchronously: receive results after all text input has been processed.

Parameters
NameDescription
request Union[google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechRequest, dict]

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

input google.cloud.texttospeech_v1beta1.types.SynthesisInput

Required. The Synthesizer requires either plain text or SSML as input. This corresponds to the input field on the request instance; if request is provided, this should not be set.

voice google.cloud.texttospeech_v1beta1.types.VoiceSelectionParams

Required. The desired voice of the synthesized audio. This corresponds to the voice field on the request instance; if request is provided, this should not be set.

audio_config google.cloud.texttospeech_v1beta1.types.AudioConfig

Required. The configuration of the synthesized audio. This corresponds to the audio_config field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechResponseThe message returned to the client by the SynthesizeSpeech method.