Class v1beta1.TextToSpeechClient

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

Package

@google-cloud/text-to-speech

Constructors

(constructor)(opts)

constructor(opts?: ClientOptions);

Construct an instance of TextToSpeechClient.

Parameter
NameDescription
opts ClientOptions

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

textToSpeechStub

textToSpeechStub?: Promise<{
        [name: string]: Function;
    }>;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listVoices(request, options)

listVoices(request?: protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest, options?: CallOptions): Promise<[protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | undefined, {} | undefined]>;

Returns a list of Voice supported for synthesis.

Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | undefined, {} | undefined]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [ListVoicesResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  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.
   */
  // const languageCode = 'abc123'

  // Imports the Texttospeech library
  const {TextToSpeechClient} = require('@google-cloud/text-to-speech').v1beta1;

  // Instantiates a client
  const texttospeechClient = new TextToSpeechClient();

  async function callListVoices() {
    // Construct request
    const request = {};

    // Run request
    const response = await texttospeechClient.listVoices(request);
    console.log(response);
  }

  callListVoices();

listVoices(request, options, callback)

listVoices(request: protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest, options: CallOptions, callback: Callback<protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest
options CallOptions
callback Callback<protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

listVoices(request, callback)

listVoices(request: protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest, callback: Callback<protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest
callback Callback<protos.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protos.google.cloud.texttospeech.v1beta1.IListVoicesRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

matchLocationFromModelName(modelName)

matchLocationFromModelName(modelName: string): string | number;

Parse the location from Model resource.

Parameter
NameDescription
modelName string

A fully-qualified path representing Model resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchModelFromModelName(modelName)

matchModelFromModelName(modelName: string): string | number;

Parse the model from Model resource.

Parameter
NameDescription
modelName string

A fully-qualified path representing Model resource.

Returns
TypeDescription
string | number

{string} A string representing the model.

matchProjectFromModelName(modelName)

matchProjectFromModelName(modelName: string): string | number;

Parse the project from Model resource.

Parameter
NameDescription
modelName string

A fully-qualified path representing Model resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

modelPath(project, location, model)

modelPath(project: string, location: string, model: string): string;

Return a fully-qualified model resource name string.

Parameters
NameDescription
project string
location string
model string
Returns
TypeDescription
string

{string} Resource name string.

synthesizeSpeech(request, options)

synthesizeSpeech(request?: protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest, options?: CallOptions): Promise<[protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, (protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | undefined), {} | undefined]>;

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

Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, (protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | undefined), {} | undefined]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [SynthesizeSpeechResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The Synthesizer requires either plain text or SSML as input.
   */
  // const input = {}
  /**
   *  Required. The desired voice of the synthesized audio.
   */
  // const voice = {}
  /**
   *  Required. The configuration of the synthesized audio.
   */
  // const audioConfig = {}
  /**
   *  Whether and what timepoints are returned in the response.
   */
  // const enableTimePointing = 1234

  // Imports the Texttospeech library
  const {TextToSpeechClient} = require('@google-cloud/text-to-speech').v1beta1;

  // Instantiates a client
  const texttospeechClient = new TextToSpeechClient();

  async function callSynthesizeSpeech() {
    // Construct request
    const request = {
      input,
      voice,
      audioConfig,
    };

    // Run request
    const response = await texttospeechClient.synthesizeSpeech(request);
    console.log(response);
  }

  callSynthesizeSpeech();

synthesizeSpeech(request, options, callback)

synthesizeSpeech(request: protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest, options: CallOptions, callback: Callback<protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest
options CallOptions
callback Callback<protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

synthesizeSpeech(request, callback)

synthesizeSpeech(request: protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest, callback: Callback<protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest
callback Callback<protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, protos.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void