Google Cloud Text-to-Speech v1beta1 API - Class TextToSpeechClient (2.0.0-beta04)

public abstract class TextToSpeechClient

Reference documentation and code samples for the Google Cloud Text-to-Speech v1beta1 API class TextToSpeechClient.

TextToSpeech client wrapper, for convenient use.

Inheritance

object > TextToSpeechClient

Derived Types

Namespace

Google.Cloud.TextToSpeech.V1Beta1

Assembly

Google.Cloud.TextToSpeech.V1Beta1.dll

Remarks

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

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the TextToSpeech service, which is a host of "texttospeech.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default TextToSpeech scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default TextToSpeech scopes are:

GrpcClient

public virtual TextToSpeech.TextToSpeechClient GrpcClient { get; }

The underlying gRPC TextToSpeech client

Property Value
TypeDescription
TextToSpeechTextToSpeechClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

Create()

public static TextToSpeechClient Create()

Synchronously creates a TextToSpeechClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TextToSpeechClientBuilder.

Returns
TypeDescription
TextToSpeechClient

The created TextToSpeechClient.

CreateAsync(CancellationToken)

public static Task<TextToSpeechClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a TextToSpeechClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TextToSpeechClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskTextToSpeechClient

The task representing the created TextToSpeechClient.

ListVoices(ListVoicesRequest, CallSettings)

public virtual ListVoicesResponse ListVoices(ListVoicesRequest request, CallSettings callSettings = null)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
requestListVoicesRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
ListVoicesResponse

The RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create();
// Initialize request argument(s)
ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "", };
// Make the request
ListVoicesResponse response = textToSpeechClient.ListVoices(request);

ListVoices(string, CallSettings)

public virtual ListVoicesResponse ListVoices(string languageCode, CallSettings callSettings = null)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
languageCodestring

Optional. Recommended. BCP-47 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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
ListVoicesResponse

The RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create();
// Initialize request argument(s)
string languageCode = "";
// Make the request
ListVoicesResponse response = textToSpeechClient.ListVoices(languageCode);

ListVoicesAsync(ListVoicesRequest, CallSettings)

public virtual Task<ListVoicesResponse> ListVoicesAsync(ListVoicesRequest request, CallSettings callSettings = null)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
requestListVoicesRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskListVoicesResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "", };
// Make the request
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(request);

ListVoicesAsync(ListVoicesRequest, CancellationToken)

public virtual Task<ListVoicesResponse> ListVoicesAsync(ListVoicesRequest request, CancellationToken cancellationToken)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
requestListVoicesRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskListVoicesResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "", };
// Make the request
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(request);

ListVoicesAsync(string, CallSettings)

public virtual Task<ListVoicesResponse> ListVoicesAsync(string languageCode, CallSettings callSettings = null)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
languageCodestring

Optional. Recommended. BCP-47 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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskListVoicesResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
string languageCode = "";
// Make the request
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(languageCode);

ListVoicesAsync(string, CancellationToken)

public virtual Task<ListVoicesResponse> ListVoicesAsync(string languageCode, CancellationToken cancellationToken)

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
languageCodestring

Optional. Recommended. BCP-47 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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskListVoicesResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
string languageCode = "";
// Make the request
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(languageCode);

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

SynthesizeSpeech(SynthesisInput, VoiceSelectionParams, AudioConfig, CallSettings)

public virtual SynthesizeSpeechResponse SynthesizeSpeech(SynthesisInput input, VoiceSelectionParams voice, AudioConfig audioConfig, CallSettings callSettings = null)

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

Parameters
NameDescription
inputSynthesisInput

Required. The Synthesizer requires either plain text or SSML as input.

voiceVoiceSelectionParams

Required. The desired voice of the synthesized audio.

audioConfigAudioConfig

Required. The configuration of the synthesized audio.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SynthesizeSpeechResponse

The RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create();
// Initialize request argument(s)
SynthesisInput input = new SynthesisInput();
VoiceSelectionParams voice = new VoiceSelectionParams();
AudioConfig audioConfig = new AudioConfig();
// Make the request
SynthesizeSpeechResponse response = textToSpeechClient.SynthesizeSpeech(input, voice, audioConfig);

SynthesizeSpeech(SynthesizeSpeechRequest, CallSettings)

public virtual SynthesizeSpeechResponse SynthesizeSpeech(SynthesizeSpeechRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestSynthesizeSpeechRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SynthesizeSpeechResponse

The RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create();
// Initialize request argument(s)
SynthesizeSpeechRequest request = new SynthesizeSpeechRequest
{
    Input = new SynthesisInput(),
    Voice = new VoiceSelectionParams(),
    AudioConfig = new AudioConfig(),
    EnableTimePointing =
    {
        SynthesizeSpeechRequest.Types.TimepointType.Unspecified,
    },
};
// Make the request
SynthesizeSpeechResponse response = textToSpeechClient.SynthesizeSpeech(request);

SynthesizeSpeechAsync(SynthesisInput, VoiceSelectionParams, AudioConfig, CallSettings)

public virtual Task<SynthesizeSpeechResponse> SynthesizeSpeechAsync(SynthesisInput input, VoiceSelectionParams voice, AudioConfig audioConfig, CallSettings callSettings = null)

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

Parameters
NameDescription
inputSynthesisInput

Required. The Synthesizer requires either plain text or SSML as input.

voiceVoiceSelectionParams

Required. The desired voice of the synthesized audio.

audioConfigAudioConfig

Required. The configuration of the synthesized audio.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskSynthesizeSpeechResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
SynthesisInput input = new SynthesisInput();
VoiceSelectionParams voice = new VoiceSelectionParams();
AudioConfig audioConfig = new AudioConfig();
// Make the request
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(input, voice, audioConfig);

SynthesizeSpeechAsync(SynthesisInput, VoiceSelectionParams, AudioConfig, CancellationToken)

public virtual Task<SynthesizeSpeechResponse> SynthesizeSpeechAsync(SynthesisInput input, VoiceSelectionParams voice, AudioConfig audioConfig, CancellationToken cancellationToken)

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

Parameters
NameDescription
inputSynthesisInput

Required. The Synthesizer requires either plain text or SSML as input.

voiceVoiceSelectionParams

Required. The desired voice of the synthesized audio.

audioConfigAudioConfig

Required. The configuration of the synthesized audio.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskSynthesizeSpeechResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
SynthesisInput input = new SynthesisInput();
VoiceSelectionParams voice = new VoiceSelectionParams();
AudioConfig audioConfig = new AudioConfig();
// Make the request
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(input, voice, audioConfig);

SynthesizeSpeechAsync(SynthesizeSpeechRequest, CallSettings)

public virtual Task<SynthesizeSpeechResponse> SynthesizeSpeechAsync(SynthesizeSpeechRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestSynthesizeSpeechRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskSynthesizeSpeechResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
SynthesizeSpeechRequest request = new SynthesizeSpeechRequest
{
    Input = new SynthesisInput(),
    Voice = new VoiceSelectionParams(),
    AudioConfig = new AudioConfig(),
    EnableTimePointing =
    {
        SynthesizeSpeechRequest.Types.TimepointType.Unspecified,
    },
};
// Make the request
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(request);

SynthesizeSpeechAsync(SynthesizeSpeechRequest, CancellationToken)

public virtual Task<SynthesizeSpeechResponse> SynthesizeSpeechAsync(SynthesizeSpeechRequest request, CancellationToken cancellationToken)

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

Parameters
NameDescription
requestSynthesizeSpeechRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskSynthesizeSpeechResponse

A Task containing the RPC response.

Example
// Create client
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync();
// Initialize request argument(s)
SynthesizeSpeechRequest request = new SynthesizeSpeechRequest
{
    Input = new SynthesisInput(),
    Voice = new VoiceSelectionParams(),
    AudioConfig = new AudioConfig(),
    EnableTimePointing =
    {
        SynthesizeSpeechRequest.Types.TimepointType.Unspecified,
    },
};
// Make the request
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(request);