Skip to content

Commit 5285b14

Browse files
docs(samples): add example tags to generated samples (#819)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 408439482 Source-Link: googleapis/googleapis@b9f6184 Source-Link: googleapis/googleapis-gen@eb888bc Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWI4ODhiYzIxNGVmYzdiZjQzYmY0NjM0YjQ3MDI1NDU2NWE2NTlhNSJ9
1 parent 9e7243e commit 5285b14

22 files changed

+1379
-395
lines changed

packages/google-cloud-speech/linkinator.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"img.shields.io"
77
],
88
"silent": true,
9-
"concurrency": 10
9+
"concurrency": 5
1010
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(config, audio) {
18+
// [START speech_v1_generated_Speech_LongRunningRecognize_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. Provides information to the recognizer that specifies how to
24+
* process the request.
25+
*/
26+
// const config = {}
27+
/**
28+
* Required. The audio data to be recognized.
29+
*/
30+
// const audio = {}
31+
/**
32+
* Optional. Specifies an optional destination for the recognition results.
33+
*/
34+
// const outputConfig = {}
35+
36+
// Imports the Speech library
37+
const {SpeechClient} = require('@google-cloud/speech').v1;
38+
39+
// Instantiates a client
40+
const speechClient = new SpeechClient();
41+
42+
async function callLongRunningRecognize() {
43+
// Construct request
44+
const request = {
45+
config,
46+
audio,
47+
};
48+
49+
// Run request
50+
const [operation] = await speechClient.longRunningRecognize(request);
51+
const [response] = await operation.promise();
52+
console.log(response);
53+
}
54+
55+
callLongRunningRecognize();
56+
// [END speech_v1_generated_Speech_LongRunningRecognize_async]
57+
}
58+
59+
process.on('unhandledRejection', err => {
60+
console.error(err.message);
61+
process.exitCode = 1;
62+
});
63+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(config, audio) {
18+
// [START speech_v1_generated_Speech_Recognize_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. Provides information to the recognizer that specifies how to
24+
* process the request.
25+
*/
26+
// const config = {}
27+
/**
28+
* Required. The audio data to be recognized.
29+
*/
30+
// const audio = {}
31+
32+
// Imports the Speech library
33+
const {SpeechClient} = require('@google-cloud/speech').v1;
34+
35+
// Instantiates a client
36+
const speechClient = new SpeechClient();
37+
38+
async function callRecognize() {
39+
// Construct request
40+
const request = {
41+
config,
42+
audio,
43+
};
44+
45+
// Run request
46+
const response = await speechClient.recognize(request);
47+
console.log(response);
48+
}
49+
50+
callRecognize();
51+
// [END speech_v1_generated_Speech_Recognize_async]
52+
}
53+
54+
process.on('unhandledRejection', err => {
55+
console.error(err.message);
56+
process.exitCode = 1;
57+
});
58+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main() {
18+
// [START speech_v1_generated_Speech_StreamingRecognize_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Provides information to the recognizer that specifies how to process the
24+
* request. The first `StreamingRecognizeRequest` message must contain a
25+
* `streaming_config` message.
26+
*/
27+
// const streamingConfig = {}
28+
/**
29+
* The audio data to be recognized. Sequential chunks of audio data are sent
30+
* in sequential `StreamingRecognizeRequest` messages. The first
31+
* `StreamingRecognizeRequest` message must not contain `audio_content` data
32+
* and all subsequent `StreamingRecognizeRequest` messages must contain
33+
* `audio_content` data. The audio bytes must be encoded as specified in
34+
* `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a
35+
* pure binary representation (not base64). See
36+
* content limits (https://cloud.google.com/speech-to-text/quotas#content).
37+
*/
38+
// const audioContent = 'Buffer.from('string')'
39+
40+
// Imports the Speech library
41+
const {SpeechClient} = require('@google-cloud/speech').v1;
42+
43+
// Instantiates a client
44+
const speechClient = new SpeechClient();
45+
46+
async function callStreamingRecognize() {
47+
// Construct request
48+
const request = {};
49+
50+
// Run request
51+
const stream = await speechClient.streamingRecognize();
52+
stream.on('data', response => {
53+
console.log(response);
54+
});
55+
stream.on('error', err => {
56+
throw err;
57+
});
58+
stream.on('end', () => {
59+
/* API call completed */
60+
});
61+
stream.write(request);
62+
stream.end();
63+
}
64+
65+
callStreamingRecognize();
66+
// [END speech_v1_generated_Speech_StreamingRecognize_async]
67+
}
68+
69+
process.on('unhandledRejection', err => {
70+
console.error(err.message);
71+
process.exitCode = 1;
72+
});
73+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, customClassId, customClass) {
18+
// [START speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The parent resource where this custom class will be created.
24+
* Format:
25+
* {api_version}/projects/{project}/locations/{location}/customClasses
26+
*/
27+
// const parent = 'abc123'
28+
/**
29+
* Required. The ID to use for the custom class, which will become the final
30+
* component of the custom class' resource name.
31+
* This value should be 4-63 characters, and valid characters
32+
* are /[a-z][0-9]-/.
33+
*/
34+
// const customClassId = 'abc123'
35+
/**
36+
* Required. The custom class to create.
37+
*/
38+
// const customClass = {}
39+
40+
// Imports the Speech library
41+
const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1;
42+
43+
// Instantiates a client
44+
const speechClient = new AdaptationClient();
45+
46+
async function callCreateCustomClass() {
47+
// Construct request
48+
const request = {
49+
parent,
50+
customClassId,
51+
customClass,
52+
};
53+
54+
// Run request
55+
const response = await speechClient.createCustomClass(request);
56+
console.log(response);
57+
}
58+
59+
callCreateCustomClass();
60+
// [END speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async]
61+
}
62+
63+
process.on('unhandledRejection', err => {
64+
console.error(err.message);
65+
process.exitCode = 1;
66+
});
67+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, phraseSetId, phraseSet) {
18+
// [START speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The parent resource where this phrase set will be created.
24+
* Format:
25+
* {api_version}/projects/{project}/locations/{location}/phraseSets
26+
*/
27+
// const parent = 'abc123'
28+
/**
29+
* Required. The ID to use for the phrase set, which will become the final
30+
* component of the phrase set's resource name.
31+
* This value should be 4-63 characters, and valid characters
32+
* are /[a-z][0-9]-/.
33+
*/
34+
// const phraseSetId = 'abc123'
35+
/**
36+
* Required. The phrase set to create.
37+
*/
38+
// const phraseSet = {}
39+
40+
// Imports the Speech library
41+
const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1;
42+
43+
// Instantiates a client
44+
const speechClient = new AdaptationClient();
45+
46+
async function callCreatePhraseSet() {
47+
// Construct request
48+
const request = {
49+
parent,
50+
phraseSetId,
51+
phraseSet,
52+
};
53+
54+
// Run request
55+
const response = await speechClient.createPhraseSet(request);
56+
console.log(response);
57+
}
58+
59+
callCreatePhraseSet();
60+
// [END speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async]
61+
}
62+
63+
process.on('unhandledRejection', err => {
64+
console.error(err.message);
65+
process.exitCode = 1;
66+
});
67+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the custom class to delete.
24+
* Format:
25+
* {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class}
26+
*/
27+
// const name = 'abc123'
28+
29+
// Imports the Speech library
30+
const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1;
31+
32+
// Instantiates a client
33+
const speechClient = new AdaptationClient();
34+
35+
async function callDeleteCustomClass() {
36+
// Construct request
37+
const request = {
38+
name,
39+
};
40+
41+
// Run request
42+
const response = await speechClient.deleteCustomClass(request);
43+
console.log(response);
44+
}
45+
46+
callDeleteCustomClass();
47+
// [END speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async]
48+
}
49+
50+
process.on('unhandledRejection', err => {
51+
console.error(err.message);
52+
process.exitCode = 1;
53+
});
54+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)