Skip to content

Commit

Permalink
docs(samples): add example tags to generated samples (#561)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 408439482

Source-Link: googleapis/googleapis@b9f6184

Source-Link: googleapis/googleapis-gen@eb888bc
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWI4ODhiYzIxNGVmYzdiZjQzYmY0NjM0YjQ3MDI1NDU2NWE2NTlhNSJ9
  • Loading branch information
gcf-owl-bot[bot] authored Nov 10, 2021
1 parent 72bb2b0 commit d20d763
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 108 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-texttospeech/linkinator.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"img.shields.io"
],
"silent": true,
"concurrency": 10
"concurrency": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main() {
// [START texttospeech_v1_generated_TextToSpeech_ListVoices_async]
/**
* 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
* 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-\*" 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-\*" voices.
*/
// const languageCode = 'abc123'

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

// 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();
// [END texttospeech_v1_generated_TextToSpeech_ListVoices_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(input, voice, audioConfig) {
// [START texttospeech_v1_generated_TextToSpeech_SynthesizeSpeech_async]
/**
* 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 = {}

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

// 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();
// [END texttospeech_v1_generated_TextToSpeech_SynthesizeSpeech_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main() {
// [START texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async]
/**
* 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();
// [END texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(input, voice, audioConfig) {
// [START texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async]
/**
* 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();
// [END texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
96 changes: 50 additions & 46 deletions packages/google-cloud-texttospeech/src/v1/text_to_speech_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,30 @@ export class TextToSpeechClient {
// -------------------
// -- Service calls --
// -------------------
/**
* Returns a list of Voice supported for synthesis.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} [request.languageCode]
* Optional. Recommended.
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. 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-\*" 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-\*" voices.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [ListVoicesResponse]{@link google.cloud.texttospeech.v1.ListVoicesResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example <caption>include:samples/generated/v1/text_to_speech.list_voices.js</caption>
* region_tag:texttospeech_v1_generated_TextToSpeech_ListVoices_async
*/
listVoices(
request?: protos.google.cloud.texttospeech.v1.IListVoicesRequest,
options?: CallOptions
Expand Down Expand Up @@ -308,30 +332,6 @@ export class TextToSpeechClient {
{} | null | undefined
>
): void;
/**
* Returns a list of Voice supported for synthesis.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} [request.languageCode]
* Optional. Recommended.
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. 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-\*" 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-\*" voices.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [ListVoicesResponse]{@link google.cloud.texttospeech.v1.ListVoicesResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.listVoices(request);
*/
listVoices(
request?: protos.google.cloud.texttospeech.v1.IListVoicesRequest,
optionsOrCallback?:
Expand Down Expand Up @@ -364,9 +364,33 @@ export class TextToSpeechClient {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
this.initialize();
return this.innerApiCalls.listVoices(request, options, callback);
}
/**
* Synthesizes speech synchronously: receive results after all text input
* has been processed.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.texttospeech.v1.SynthesisInput} request.input
* Required. The Synthesizer requires either plain text or SSML as input.
* @param {google.cloud.texttospeech.v1.VoiceSelectionParams} request.voice
* Required. The desired voice of the synthesized audio.
* @param {google.cloud.texttospeech.v1.AudioConfig} request.audioConfig
* Required. The configuration of the synthesized audio.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [SynthesizeSpeechResponse]{@link google.cloud.texttospeech.v1.SynthesizeSpeechResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example <caption>include:samples/generated/v1/text_to_speech.synthesize_speech.js</caption>
* region_tag:texttospeech_v1_generated_TextToSpeech_SynthesizeSpeech_async
*/
synthesizeSpeech(
request?: protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest,
options?: CallOptions
Expand Down Expand Up @@ -398,28 +422,6 @@ export class TextToSpeechClient {
{} | null | undefined
>
): void;
/**
* Synthesizes speech synchronously: receive results after all text input
* has been processed.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.texttospeech.v1.SynthesisInput} request.input
* Required. The Synthesizer requires either plain text or SSML as input.
* @param {google.cloud.texttospeech.v1.VoiceSelectionParams} request.voice
* Required. The desired voice of the synthesized audio.
* @param {google.cloud.texttospeech.v1.AudioConfig} request.audioConfig
* Required. The configuration of the synthesized audio.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [SynthesizeSpeechResponse]{@link google.cloud.texttospeech.v1.SynthesizeSpeechResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.synthesizeSpeech(request);
*/
synthesizeSpeech(
request?: protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest,
optionsOrCallback?:
Expand Down Expand Up @@ -454,6 +456,8 @@ export class TextToSpeechClient {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
this.initialize();
return this.innerApiCalls.synthesizeSpeech(request, options, callback);
}
Expand Down
Loading

0 comments on commit d20d763

Please sign in to comment.