diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java index 64b7be25c..bca8ce282 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java @@ -37,6 +37,14 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (SpeechClient speechClient = SpeechClient.create()) {
+ *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+ *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+ *   RecognizeResponse response = speechClient.recognize(config, audio);
+ * }
+ * }
+ * *

Note: close() needs to be called on the SpeechClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -149,6 +157,16 @@ public final OperationsClient getOperationsClient() { * Performs synchronous speech recognition: receive results after all audio has been sent and * processed. * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+   *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+   *   RecognizeResponse response = speechClient.recognize(config, audio);
+   * }
+   * }
+ * * @param config Required. Provides information to the recognizer that specifies how to process * the request. * @param audio Required. The audio data to be recognized. @@ -165,6 +183,19 @@ public final RecognizeResponse recognize(RecognitionConfig config, RecognitionAu * Performs synchronous speech recognition: receive results after all audio has been sent and * processed. * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognizeRequest request =
+   *       RecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   RecognizeResponse response = speechClient.recognize(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -178,6 +209,19 @@ public final RecognizeResponse recognize(RecognizeRequest request) { * processed. * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognizeRequest request =
+   *       RecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = speechClient.recognizeCallable().futureCall(request);
+   *   // Do something.
+   *   RecognizeResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable recognizeCallable() { return stub.recognizeCallable(); @@ -190,6 +234,17 @@ public final UnaryCallable recognizeCallabl * `LongRunningRecognizeResponse` message. For more information on asynchronous speech * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+   *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+   *   LongRunningRecognizeResponse response =
+   *       speechClient.longRunningRecognizeAsync(config, audio).get();
+   * }
+   * }
+ * * @param config Required. Provides information to the recognizer that specifies how to process * the request. * @param audio Required. The audio data to be recognized. @@ -209,6 +264,19 @@ public final UnaryCallable recognizeCallabl * `LongRunningRecognizeResponse` message. For more information on asynchronous speech * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   LongRunningRecognizeResponse response = speechClient.longRunningRecognizeAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -225,6 +293,20 @@ public final UnaryCallable recognizeCallabl * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       speechClient.longRunningRecognizeOperationCallable().futureCall(request);
+   *   // Do something.
+   *   LongRunningRecognizeResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< LongRunningRecognizeRequest, LongRunningRecognizeResponse, LongRunningRecognizeMetadata> @@ -240,6 +322,19 @@ public final UnaryCallable recognizeCallabl * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = speechClient.longRunningRecognizeCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable longRunningRecognizeCallable() { @@ -252,6 +347,18 @@ public final UnaryCallable recognizeCallabl * method is only available via the gRPC API (not REST). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   BidiStream bidiStream =
+   *       speechClient.streamingRecognizeCallable().call();
+   *   StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (StreamingRecognizeResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable streamingRecognizeCallable() { diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/package-info.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/package-info.java index aa4ebcec2..3439d8318 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/package-info.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/package-info.java @@ -22,6 +22,14 @@ *

Service Description: Service that implements Google Cloud Speech API. * *

Sample for SpeechClient: + * + *

{@code
+ * try (SpeechClient speechClient = SpeechClient.create()) {
+ *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+ *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+ *   RecognizeResponse response = speechClient.recognize(config, audio);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.speech.v1; diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java index 64bf21ffd..7a950c180 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java @@ -37,6 +37,14 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (SpeechClient speechClient = SpeechClient.create()) {
+ *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+ *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+ *   RecognizeResponse response = speechClient.recognize(config, audio);
+ * }
+ * }
+ * *

Note: close() needs to be called on the SpeechClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -150,6 +158,16 @@ public final OperationsClient getOperationsClient() { * Performs synchronous speech recognition: receive results after all audio has been sent and * processed. * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+   *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+   *   RecognizeResponse response = speechClient.recognize(config, audio);
+   * }
+   * }
+ * * @param config Required. Provides information to the recognizer that specifies how to process * the request. * @param audio Required. The audio data to be recognized. @@ -166,6 +184,19 @@ public final RecognizeResponse recognize(RecognitionConfig config, RecognitionAu * Performs synchronous speech recognition: receive results after all audio has been sent and * processed. * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognizeRequest request =
+   *       RecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   RecognizeResponse response = speechClient.recognize(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -179,6 +210,19 @@ public final RecognizeResponse recognize(RecognizeRequest request) { * processed. * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognizeRequest request =
+   *       RecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = speechClient.recognizeCallable().futureCall(request);
+   *   // Do something.
+   *   RecognizeResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable recognizeCallable() { return stub.recognizeCallable(); @@ -191,6 +235,17 @@ public final UnaryCallable recognizeCallabl * `LongRunningRecognizeResponse` message. For more information on asynchronous speech * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+   *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+   *   LongRunningRecognizeResponse response =
+   *       speechClient.longRunningRecognizeAsync(config, audio).get();
+   * }
+   * }
+ * * @param config Required. Provides information to the recognizer that specifies how to process * the request. * @param audio Required. The audio data to be recognized. @@ -210,6 +265,19 @@ public final UnaryCallable recognizeCallabl * `LongRunningRecognizeResponse` message. For more information on asynchronous speech * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * + *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   LongRunningRecognizeResponse response = speechClient.longRunningRecognizeAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -226,6 +294,20 @@ public final UnaryCallable recognizeCallabl * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       speechClient.longRunningRecognizeOperationCallable().futureCall(request);
+   *   // Do something.
+   *   LongRunningRecognizeResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< LongRunningRecognizeRequest, LongRunningRecognizeResponse, LongRunningRecognizeMetadata> @@ -241,6 +323,19 @@ public final UnaryCallable recognizeCallabl * recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   LongRunningRecognizeRequest request =
+   *       LongRunningRecognizeRequest.newBuilder()
+   *           .setConfig(RecognitionConfig.newBuilder().build())
+   *           .setAudio(RecognitionAudio.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = speechClient.longRunningRecognizeCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable longRunningRecognizeCallable() { @@ -253,6 +348,18 @@ public final UnaryCallable recognizeCallabl * method is only available via the gRPC API (not REST). * *

Sample code: + * + *

{@code
+   * try (SpeechClient speechClient = SpeechClient.create()) {
+   *   BidiStream bidiStream =
+   *       speechClient.streamingRecognizeCallable().call();
+   *   StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (StreamingRecognizeResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable streamingRecognizeCallable() { diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/package-info.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/package-info.java index 01e8bc782..dc873e742 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/package-info.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/package-info.java @@ -22,6 +22,14 @@ *

Service Description: Service that implements Google Cloud Speech API. * *

Sample for SpeechClient: + * + *

{@code
+ * try (SpeechClient speechClient = SpeechClient.create()) {
+ *   RecognitionConfig config = RecognitionConfig.newBuilder().build();
+ *   RecognitionAudio audio = RecognitionAudio.newBuilder().build();
+ *   RecognizeResponse response = speechClient.recognize(config, audio);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.speech.v1p1beta1; diff --git a/synth.metadata b/synth.metadata index b05eb7894..05887fa01 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,23 +4,23 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-speech.git", - "sha": "11e873e9ff047bb02881be8633c047e091fb27ce" + "sha": "c99e52c7e034fd061f5ce5f16991a9aaa6e46bd6" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {