Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit 1492dc7

Browse files
docs: generate sample code in the Java microgenerator (#427)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/a9b5fd25-95c9-46d7-a769-83a3ceb9ee7b/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: googleapis/googleapis@8d8c008
1 parent c99e52c commit 1492dc7

5 files changed

Lines changed: 235 additions & 5 deletions

File tree

‎google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
* <p>This class provides the ability to make remote calls to the backing service through method
3838
* calls that map to API methods. Sample code to get started:
3939
*
40+
* <pre>{@code
41+
* try (SpeechClient speechClient = SpeechClient.create()) {
42+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
43+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
44+
* RecognizeResponse response = speechClient.recognize(config, audio);
45+
* }
46+
* }</pre>
47+
*
4048
* <p>Note: close() needs to be called on the SpeechClient object to clean up resources such as
4149
* threads. In the example above, try-with-resources is used, which automatically calls close().
4250
*
@@ -149,6 +157,16 @@ public final OperationsClient getOperationsClient() {
149157
* Performs synchronous speech recognition: receive results after all audio has been sent and
150158
* processed.
151159
*
160+
* <p>Sample code:
161+
*
162+
* <pre>{@code
163+
* try (SpeechClient speechClient = SpeechClient.create()) {
164+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
165+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
166+
* RecognizeResponse response = speechClient.recognize(config, audio);
167+
* }
168+
* }</pre>
169+
*
152170
* @param config Required. Provides information to the recognizer that specifies how to process
153171
* the request.
154172
* @param audio Required. The audio data to be recognized.
@@ -165,6 +183,19 @@ public final RecognizeResponse recognize(RecognitionConfig config, RecognitionAu
165183
* Performs synchronous speech recognition: receive results after all audio has been sent and
166184
* processed.
167185
*
186+
* <p>Sample code:
187+
*
188+
* <pre>{@code
189+
* try (SpeechClient speechClient = SpeechClient.create()) {
190+
* RecognizeRequest request =
191+
* RecognizeRequest.newBuilder()
192+
* .setConfig(RecognitionConfig.newBuilder().build())
193+
* .setAudio(RecognitionAudio.newBuilder().build())
194+
* .build();
195+
* RecognizeResponse response = speechClient.recognize(request);
196+
* }
197+
* }</pre>
198+
*
168199
* @param request The request object containing all of the parameters for the API call.
169200
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
170201
*/
@@ -178,6 +209,19 @@ public final RecognizeResponse recognize(RecognizeRequest request) {
178209
* processed.
179210
*
180211
* <p>Sample code:
212+
*
213+
* <pre>{@code
214+
* try (SpeechClient speechClient = SpeechClient.create()) {
215+
* RecognizeRequest request =
216+
* RecognizeRequest.newBuilder()
217+
* .setConfig(RecognitionConfig.newBuilder().build())
218+
* .setAudio(RecognitionAudio.newBuilder().build())
219+
* .build();
220+
* ApiFuture<RecognizeResponse> future = speechClient.recognizeCallable().futureCall(request);
221+
* // Do something.
222+
* RecognizeResponse response = future.get();
223+
* }
224+
* }</pre>
181225
*/
182226
public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallable() {
183227
return stub.recognizeCallable();
@@ -190,6 +234,17 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
190234
* `LongRunningRecognizeResponse` message. For more information on asynchronous speech
191235
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
192236
*
237+
* <p>Sample code:
238+
*
239+
* <pre>{@code
240+
* try (SpeechClient speechClient = SpeechClient.create()) {
241+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
242+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
243+
* LongRunningRecognizeResponse response =
244+
* speechClient.longRunningRecognizeAsync(config, audio).get();
245+
* }
246+
* }</pre>
247+
*
193248
* @param config Required. Provides information to the recognizer that specifies how to process
194249
* the request.
195250
* @param audio Required. The audio data to be recognized.
@@ -209,6 +264,19 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
209264
* `LongRunningRecognizeResponse` message. For more information on asynchronous speech
210265
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
211266
*
267+
* <p>Sample code:
268+
*
269+
* <pre>{@code
270+
* try (SpeechClient speechClient = SpeechClient.create()) {
271+
* LongRunningRecognizeRequest request =
272+
* LongRunningRecognizeRequest.newBuilder()
273+
* .setConfig(RecognitionConfig.newBuilder().build())
274+
* .setAudio(RecognitionAudio.newBuilder().build())
275+
* .build();
276+
* LongRunningRecognizeResponse response = speechClient.longRunningRecognizeAsync(request).get();
277+
* }
278+
* }</pre>
279+
*
212280
* @param request The request object containing all of the parameters for the API call.
213281
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
214282
*/
@@ -225,6 +293,20 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
225293
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
226294
*
227295
* <p>Sample code:
296+
*
297+
* <pre>{@code
298+
* try (SpeechClient speechClient = SpeechClient.create()) {
299+
* LongRunningRecognizeRequest request =
300+
* LongRunningRecognizeRequest.newBuilder()
301+
* .setConfig(RecognitionConfig.newBuilder().build())
302+
* .setAudio(RecognitionAudio.newBuilder().build())
303+
* .build();
304+
* OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> future =
305+
* speechClient.longRunningRecognizeOperationCallable().futureCall(request);
306+
* // Do something.
307+
* LongRunningRecognizeResponse response = future.get();
308+
* }
309+
* }</pre>
228310
*/
229311
public final OperationCallable<
230312
LongRunningRecognizeRequest, LongRunningRecognizeResponse, LongRunningRecognizeMetadata>
@@ -240,6 +322,19 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
240322
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
241323
*
242324
* <p>Sample code:
325+
*
326+
* <pre>{@code
327+
* try (SpeechClient speechClient = SpeechClient.create()) {
328+
* LongRunningRecognizeRequest request =
329+
* LongRunningRecognizeRequest.newBuilder()
330+
* .setConfig(RecognitionConfig.newBuilder().build())
331+
* .setAudio(RecognitionAudio.newBuilder().build())
332+
* .build();
333+
* ApiFuture<Operation> future = speechClient.longRunningRecognizeCallable().futureCall(request);
334+
* // Do something.
335+
* Operation response = future.get();
336+
* }
337+
* }</pre>
243338
*/
244339
public final UnaryCallable<LongRunningRecognizeRequest, Operation>
245340
longRunningRecognizeCallable() {
@@ -252,6 +347,18 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
252347
* method is only available via the gRPC API (not REST).
253348
*
254349
* <p>Sample code:
350+
*
351+
* <pre>{@code
352+
* try (SpeechClient speechClient = SpeechClient.create()) {
353+
* BidiStream<StreamingRecognizeRequest, StreamingRecognizeResponse> bidiStream =
354+
* speechClient.streamingRecognizeCallable().call();
355+
* StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build();
356+
* bidiStream.send(request);
357+
* for (StreamingRecognizeResponse response : bidiStream) {
358+
* // Do something when a response is received.
359+
* }
360+
* }
361+
* }</pre>
255362
*/
256363
public final BidiStreamingCallable<StreamingRecognizeRequest, StreamingRecognizeResponse>
257364
streamingRecognizeCallable() {

‎google-cloud-speech/src/main/java/com/google/cloud/speech/v1/package-info.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
* <p>Service Description: Service that implements Google Cloud Speech API.
2323
*
2424
* <p>Sample for SpeechClient:
25+
*
26+
* <pre>{@code
27+
* try (SpeechClient speechClient = SpeechClient.create()) {
28+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
29+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
30+
* RecognizeResponse response = speechClient.recognize(config, audio);
31+
* }
32+
* }</pre>
2533
*/
2634
@Generated("by gapic-generator-java")
2735
package com.google.cloud.speech.v1;

‎google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
* <p>This class provides the ability to make remote calls to the backing service through method
3838
* calls that map to API methods. Sample code to get started:
3939
*
40+
* <pre>{@code
41+
* try (SpeechClient speechClient = SpeechClient.create()) {
42+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
43+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
44+
* RecognizeResponse response = speechClient.recognize(config, audio);
45+
* }
46+
* }</pre>
47+
*
4048
* <p>Note: close() needs to be called on the SpeechClient object to clean up resources such as
4149
* threads. In the example above, try-with-resources is used, which automatically calls close().
4250
*
@@ -150,6 +158,16 @@ public final OperationsClient getOperationsClient() {
150158
* Performs synchronous speech recognition: receive results after all audio has been sent and
151159
* processed.
152160
*
161+
* <p>Sample code:
162+
*
163+
* <pre>{@code
164+
* try (SpeechClient speechClient = SpeechClient.create()) {
165+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
166+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
167+
* RecognizeResponse response = speechClient.recognize(config, audio);
168+
* }
169+
* }</pre>
170+
*
153171
* @param config Required. Provides information to the recognizer that specifies how to process
154172
* the request.
155173
* @param audio Required. The audio data to be recognized.
@@ -166,6 +184,19 @@ public final RecognizeResponse recognize(RecognitionConfig config, RecognitionAu
166184
* Performs synchronous speech recognition: receive results after all audio has been sent and
167185
* processed.
168186
*
187+
* <p>Sample code:
188+
*
189+
* <pre>{@code
190+
* try (SpeechClient speechClient = SpeechClient.create()) {
191+
* RecognizeRequest request =
192+
* RecognizeRequest.newBuilder()
193+
* .setConfig(RecognitionConfig.newBuilder().build())
194+
* .setAudio(RecognitionAudio.newBuilder().build())
195+
* .build();
196+
* RecognizeResponse response = speechClient.recognize(request);
197+
* }
198+
* }</pre>
199+
*
169200
* @param request The request object containing all of the parameters for the API call.
170201
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
171202
*/
@@ -179,6 +210,19 @@ public final RecognizeResponse recognize(RecognizeRequest request) {
179210
* processed.
180211
*
181212
* <p>Sample code:
213+
*
214+
* <pre>{@code
215+
* try (SpeechClient speechClient = SpeechClient.create()) {
216+
* RecognizeRequest request =
217+
* RecognizeRequest.newBuilder()
218+
* .setConfig(RecognitionConfig.newBuilder().build())
219+
* .setAudio(RecognitionAudio.newBuilder().build())
220+
* .build();
221+
* ApiFuture<RecognizeResponse> future = speechClient.recognizeCallable().futureCall(request);
222+
* // Do something.
223+
* RecognizeResponse response = future.get();
224+
* }
225+
* }</pre>
182226
*/
183227
public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallable() {
184228
return stub.recognizeCallable();
@@ -191,6 +235,17 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
191235
* `LongRunningRecognizeResponse` message. For more information on asynchronous speech
192236
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
193237
*
238+
* <p>Sample code:
239+
*
240+
* <pre>{@code
241+
* try (SpeechClient speechClient = SpeechClient.create()) {
242+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
243+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
244+
* LongRunningRecognizeResponse response =
245+
* speechClient.longRunningRecognizeAsync(config, audio).get();
246+
* }
247+
* }</pre>
248+
*
194249
* @param config Required. Provides information to the recognizer that specifies how to process
195250
* the request.
196251
* @param audio Required. The audio data to be recognized.
@@ -210,6 +265,19 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
210265
* `LongRunningRecognizeResponse` message. For more information on asynchronous speech
211266
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
212267
*
268+
* <p>Sample code:
269+
*
270+
* <pre>{@code
271+
* try (SpeechClient speechClient = SpeechClient.create()) {
272+
* LongRunningRecognizeRequest request =
273+
* LongRunningRecognizeRequest.newBuilder()
274+
* .setConfig(RecognitionConfig.newBuilder().build())
275+
* .setAudio(RecognitionAudio.newBuilder().build())
276+
* .build();
277+
* LongRunningRecognizeResponse response = speechClient.longRunningRecognizeAsync(request).get();
278+
* }
279+
* }</pre>
280+
*
213281
* @param request The request object containing all of the parameters for the API call.
214282
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
215283
*/
@@ -226,6 +294,20 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
226294
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
227295
*
228296
* <p>Sample code:
297+
*
298+
* <pre>{@code
299+
* try (SpeechClient speechClient = SpeechClient.create()) {
300+
* LongRunningRecognizeRequest request =
301+
* LongRunningRecognizeRequest.newBuilder()
302+
* .setConfig(RecognitionConfig.newBuilder().build())
303+
* .setAudio(RecognitionAudio.newBuilder().build())
304+
* .build();
305+
* OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> future =
306+
* speechClient.longRunningRecognizeOperationCallable().futureCall(request);
307+
* // Do something.
308+
* LongRunningRecognizeResponse response = future.get();
309+
* }
310+
* }</pre>
229311
*/
230312
public final OperationCallable<
231313
LongRunningRecognizeRequest, LongRunningRecognizeResponse, LongRunningRecognizeMetadata>
@@ -241,6 +323,19 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
241323
* recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
242324
*
243325
* <p>Sample code:
326+
*
327+
* <pre>{@code
328+
* try (SpeechClient speechClient = SpeechClient.create()) {
329+
* LongRunningRecognizeRequest request =
330+
* LongRunningRecognizeRequest.newBuilder()
331+
* .setConfig(RecognitionConfig.newBuilder().build())
332+
* .setAudio(RecognitionAudio.newBuilder().build())
333+
* .build();
334+
* ApiFuture<Operation> future = speechClient.longRunningRecognizeCallable().futureCall(request);
335+
* // Do something.
336+
* Operation response = future.get();
337+
* }
338+
* }</pre>
244339
*/
245340
public final UnaryCallable<LongRunningRecognizeRequest, Operation>
246341
longRunningRecognizeCallable() {
@@ -253,6 +348,18 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
253348
* method is only available via the gRPC API (not REST).
254349
*
255350
* <p>Sample code:
351+
*
352+
* <pre>{@code
353+
* try (SpeechClient speechClient = SpeechClient.create()) {
354+
* BidiStream<StreamingRecognizeRequest, StreamingRecognizeResponse> bidiStream =
355+
* speechClient.streamingRecognizeCallable().call();
356+
* StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build();
357+
* bidiStream.send(request);
358+
* for (StreamingRecognizeResponse response : bidiStream) {
359+
* // Do something when a response is received.
360+
* }
361+
* }
362+
* }</pre>
256363
*/
257364
public final BidiStreamingCallable<StreamingRecognizeRequest, StreamingRecognizeResponse>
258365
streamingRecognizeCallable() {

‎google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/package-info.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
* <p>Service Description: Service that implements Google Cloud Speech API.
2323
*
2424
* <p>Sample for SpeechClient:
25+
*
26+
* <pre>{@code
27+
* try (SpeechClient speechClient = SpeechClient.create()) {
28+
* RecognitionConfig config = RecognitionConfig.newBuilder().build();
29+
* RecognitionAudio audio = RecognitionAudio.newBuilder().build();
30+
* RecognizeResponse response = speechClient.recognize(config, audio);
31+
* }
32+
* }</pre>
2533
*/
2634
@Generated("by gapic-generator-java")
2735
package com.google.cloud.speech.v1p1beta1;

‎synth.metadata‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-speech.git",
7-
"sha": "11e873e9ff047bb02881be8633c047e091fb27ce"
7+
"sha": "c99e52c7e034fd061f5ce5f16991a9aaa6e46bd6"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3",
15-
"internalRef": "350949863"
14+
"sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb",
15+
"internalRef": "356341083"
1616
}
1717
},
1818
{
1919
"git": {
2020
"name": "googleapis",
2121
"remote": "https://github.com/googleapis/googleapis.git",
22-
"sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3",
23-
"internalRef": "350949863"
22+
"sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb",
23+
"internalRef": "356341083"
2424
}
2525
},
2626
{

0 commit comments

Comments
 (0)