diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechClient.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechClient.java
index 50819bba2bd5..857b22dbbaa6 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechClient.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechClient.java
@@ -88,6 +88,20 @@
* TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
* }
*
+ * To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
+ * the wire:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * TextToSpeechSettings textToSpeechSettings =
+ * TextToSpeechSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechSettings.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechSettings.java
index 7aa9bde168c9..62223287d474 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechSettings.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechSettings.java
@@ -21,6 +21,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
@@ -103,11 +104,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return TextToSpeechStubSettings.defaultCredentialsProviderBuilder();
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return TextToSpeechStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return TextToSpeechStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return TextToSpeechStubSettings.defaultTransportChannelProvider();
}
@@ -117,11 +125,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return TextToSpeechStubSettings.defaultApiClientHeaderProviderBuilder();
}
- /** Returns a new builder for this class. */
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -159,6 +173,11 @@ private static Builder createDefault() {
return new Builder(TextToSpeechStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(TextToSpeechStubSettings.newHttpJsonBuilder());
+ }
+
public TextToSpeechStubSettings.Builder getStubSettingsBuilder() {
return ((TextToSpeechStubSettings.Builder) getStubSettings());
}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechCallableFactory.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechCallableFactory.java
new file mode 100644
index 000000000000..9ba85dfd3794
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonCallableFactory;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST callable factory implementation for the TextToSpeech service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonTextToSpeechCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechStub.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechStub.java
new file mode 100644
index 000000000000..90dac73e2500
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/HttpJsonTextToSpeechStub.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.texttospeech.v1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechResponse;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the TextToSpeech service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonTextToSpeechStub extends TextToSpeechStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor
+ listVoicesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/ListVoices")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/voices",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(
+ fields, "languageCode", request.getLanguageCode());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListVoicesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ synthesizeSpeechMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/text:synthesize",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("*", request.toBuilder().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(SynthesizeSpeechResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable listVoicesCallable;
+ private final UnaryCallable
+ synthesizeSpeechCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonTextToSpeechStub create(TextToSpeechStubSettings settings)
+ throws IOException {
+ return new HttpJsonTextToSpeechStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonTextToSpeechStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonTextToSpeechStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonTextToSpeechStub, using the given settings. This is protected
+ * so that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonTextToSpeechStub(TextToSpeechStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonTextToSpeechCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonTextToSpeechStub, using the given settings. This is protected
+ * so that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+
+ HttpJsonCallSettings listVoicesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listVoicesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ synthesizeSpeechTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(synthesizeSpeechMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listVoicesCallable =
+ callableFactory.createUnaryCallable(
+ listVoicesTransportSettings, settings.listVoicesSettings(), clientContext);
+ this.synthesizeSpeechCallable =
+ callableFactory.createUnaryCallable(
+ synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listVoicesMethodDescriptor);
+ methodDescriptors.add(synthesizeSpeechMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ @Override
+ public UnaryCallable listVoicesCallable() {
+ return listVoicesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ synthesizeSpeechCallable() {
+ return synthesizeSpeechCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/TextToSpeechStubSettings.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/TextToSpeechStubSettings.java
index f100bfd9f991..f3bb298554f4 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/TextToSpeechStubSettings.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/TextToSpeechStubSettings.java
@@ -24,6 +24,9 @@
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
@@ -105,6 +108,11 @@ public TextToSpeechStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcTextToSpeechStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonTextToSpeechStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -137,18 +145,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
- public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(TextToSpeechStubSettings.class))
@@ -156,11 +171,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- /** Returns a new builder for this class. */
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(TextToSpeechStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return TextToSpeechStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -258,6 +292,19 @@ private static Builder createDefault() {
return initDefaults(builder);
}
+ private static Builder createHttpJsonDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
private static Builder initDefaults(Builder builder) {
builder
.listVoicesSettings()
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java
index 98fbc1dc7519..6e65afe2a830 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java
@@ -89,6 +89,20 @@
* TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
* }
*
+ * To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
+ * the wire:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * TextToSpeechSettings textToSpeechSettings =
+ * TextToSpeechSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java
index 1a5f2069dcf2..beee9277bf7b 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java
@@ -21,6 +21,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
@@ -104,11 +105,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return TextToSpeechStubSettings.defaultCredentialsProviderBuilder();
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return TextToSpeechStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return TextToSpeechStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return TextToSpeechStubSettings.defaultTransportChannelProvider();
}
@@ -118,11 +126,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return TextToSpeechStubSettings.defaultApiClientHeaderProviderBuilder();
}
- /** Returns a new builder for this class. */
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -160,6 +174,11 @@ private static Builder createDefault() {
return new Builder(TextToSpeechStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(TextToSpeechStubSettings.newHttpJsonBuilder());
+ }
+
public TextToSpeechStubSettings.Builder getStubSettingsBuilder() {
return ((TextToSpeechStubSettings.Builder) getStubSettings());
}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechCallableFactory.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechCallableFactory.java
new file mode 100644
index 000000000000..0466028789a1
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonCallableFactory;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST callable factory implementation for the TextToSpeech service API.
+ *
+ *
This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonTextToSpeechCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechStub.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechStub.java
new file mode 100644
index 000000000000..08d2479374c5
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/HttpJsonTextToSpeechStub.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.texttospeech.v1beta1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1beta1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechResponse;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the TextToSpeech service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonTextToSpeechStub extends TextToSpeechStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor
+ listVoicesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.texttospeech.v1beta1.TextToSpeech/ListVoices")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/voices",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(
+ fields, "languageCode", request.getLanguageCode());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListVoicesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ synthesizeSpeechMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.texttospeech.v1beta1.TextToSpeech/SynthesizeSpeech")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/text:synthesize",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("*", request.toBuilder().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(SynthesizeSpeechResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable listVoicesCallable;
+ private final UnaryCallable
+ synthesizeSpeechCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonTextToSpeechStub create(TextToSpeechStubSettings settings)
+ throws IOException {
+ return new HttpJsonTextToSpeechStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonTextToSpeechStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonTextToSpeechStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonTextToSpeechStub, using the given settings. This is protected
+ * so that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonTextToSpeechStub(TextToSpeechStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonTextToSpeechCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonTextToSpeechStub, using the given settings. This is protected
+ * so that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonTextToSpeechStub(
+ TextToSpeechStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+
+ HttpJsonCallSettings listVoicesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listVoicesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ synthesizeSpeechTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(synthesizeSpeechMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listVoicesCallable =
+ callableFactory.createUnaryCallable(
+ listVoicesTransportSettings, settings.listVoicesSettings(), clientContext);
+ this.synthesizeSpeechCallable =
+ callableFactory.createUnaryCallable(
+ synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listVoicesMethodDescriptor);
+ methodDescriptors.add(synthesizeSpeechMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ @Override
+ public UnaryCallable listVoicesCallable() {
+ return listVoicesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ synthesizeSpeechCallable() {
+ return synthesizeSpeechCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java
index 61d7b83659f3..5984309bea2b 100644
--- a/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java
+++ b/java-texttospeech/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java
@@ -24,6 +24,9 @@
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
@@ -106,6 +109,11 @@ public TextToSpeechStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcTextToSpeechStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonTextToSpeechStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -138,18 +146,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
- public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(TextToSpeechStubSettings.class))
@@ -157,11 +172,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- /** Returns a new builder for this class. */
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(TextToSpeechStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return TextToSpeechStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -259,6 +293,19 @@ private static Builder createDefault() {
return initDefaults(builder);
}
+ private static Builder createHttpJsonDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
private static Builder initDefaults(Builder builder) {
builder
.listVoicesSettings()
diff --git a/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1/TextToSpeechClientHttpJsonTest.java b/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1/TextToSpeechClientHttpJsonTest.java
new file mode 100644
index 000000000000..03f26a5dcf72
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1/TextToSpeechClientHttpJsonTest.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.testing.MockHttpService;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ApiException;
+import com.google.api.gax.rpc.ApiExceptionFactory;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.testing.FakeStatusCode;
+import com.google.cloud.texttospeech.v1.stub.HttpJsonTextToSpeechStub;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Generated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Generated("by gapic-generator-java")
+public class TextToSpeechClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static TextToSpeechClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonTextToSpeechStub.getMethodDescriptors(),
+ TextToSpeechSettings.getDefaultEndpoint());
+ TextToSpeechSettings settings =
+ TextToSpeechSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = TextToSpeechClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void listVoicesTest() throws Exception {
+ ListVoicesResponse expectedResponse =
+ ListVoicesResponse.newBuilder().addAllVoices(new ArrayList()).build();
+ mockService.addResponse(expectedResponse);
+
+ String languageCode = "languageCode-2092349083";
+
+ ListVoicesResponse actualResponse = client.listVoices(languageCode);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void listVoicesExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String languageCode = "languageCode-2092349083";
+ client.listVoices(languageCode);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void synthesizeSpeechTest() throws Exception {
+ SynthesizeSpeechResponse expectedResponse =
+ SynthesizeSpeechResponse.newBuilder().setAudioContent(ByteString.EMPTY).build();
+ mockService.addResponse(expectedResponse);
+
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+
+ SynthesizeSpeechResponse actualResponse = client.synthesizeSpeech(input, voice, audioConfig);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void synthesizeSpeechExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+ client.synthesizeSpeech(input, voice, audioConfig);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClientHttpJsonTest.java b/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClientHttpJsonTest.java
new file mode 100644
index 000000000000..7c4057d78106
--- /dev/null
+++ b/java-texttospeech/google-cloud-texttospeech/src/test/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClientHttpJsonTest.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.testing.MockHttpService;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ApiException;
+import com.google.api.gax.rpc.ApiExceptionFactory;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.testing.FakeStatusCode;
+import com.google.cloud.texttospeech.v1beta1.stub.HttpJsonTextToSpeechStub;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Generated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Generated("by gapic-generator-java")
+public class TextToSpeechClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static TextToSpeechClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonTextToSpeechStub.getMethodDescriptors(),
+ TextToSpeechSettings.getDefaultEndpoint());
+ TextToSpeechSettings settings =
+ TextToSpeechSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = TextToSpeechClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void listVoicesTest() throws Exception {
+ ListVoicesResponse expectedResponse =
+ ListVoicesResponse.newBuilder().addAllVoices(new ArrayList()).build();
+ mockService.addResponse(expectedResponse);
+
+ String languageCode = "languageCode-2092349083";
+
+ ListVoicesResponse actualResponse = client.listVoices(languageCode);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void listVoicesExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String languageCode = "languageCode-2092349083";
+ client.listVoices(languageCode);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void synthesizeSpeechTest() throws Exception {
+ SynthesizeSpeechResponse expectedResponse =
+ SynthesizeSpeechResponse.newBuilder()
+ .setAudioContent(ByteString.EMPTY)
+ .addAllTimepoints(new ArrayList())
+ .setAudioConfig(AudioConfig.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+
+ SynthesizeSpeechResponse actualResponse = client.synthesizeSpeech(input, voice, audioConfig);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void synthesizeSpeechExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+ client.synthesizeSpeech(input, voice, audioConfig);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..d00d45cd750b
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.stub.samples;
+
+// [START texttospeech_v1_generated_texttospeechstubsettings_listvoices_sync]
+import com.google.cloud.texttospeech.v1.stub.TextToSpeechStubSettings;
+import java.time.Duration;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechStubSettings.Builder textToSpeechSettingsBuilder =
+ TextToSpeechStubSettings.newBuilder();
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .setRetrySettings(
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ TextToSpeechStubSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
+ }
+}
+// [END texttospeech_v1_generated_texttospeechstubsettings_listvoices_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java
new file mode 100644
index 000000000000..044014d5a907
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_create_setcredentialsprovider_sync]
+import com.google.api.gax.core.FixedCredentialsProvider;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.TextToSpeechSettings;
+import com.google.cloud.texttospeech.v1.myCredentials;
+
+public class SyncCreateSetCredentialsProvider {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider();
+ }
+
+ public static void syncCreateSetCredentialsProvider() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder()
+ .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ .build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_create_setcredentialsprovider_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java
new file mode 100644
index 000000000000..a39a792a7839
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_create_setcredentialsprovider1_sync]
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.TextToSpeechSettings;
+
+public class SyncCreateSetCredentialsProvider1 {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider1();
+ }
+
+ public static void syncCreateSetCredentialsProvider1() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder()
+ .setTransportChannelProvider(
+ TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder().build())
+ .build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_create_setcredentialsprovider1_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetEndpoint.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetEndpoint.java
new file mode 100644
index 000000000000..fedbd0d682cc
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/create/SyncCreateSetEndpoint.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_create_setendpoint_sync]
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.TextToSpeechSettings;
+import com.google.cloud.texttospeech.v1.myEndpoint;
+
+public class SyncCreateSetEndpoint {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetEndpoint();
+ }
+
+ public static void syncCreateSetEndpoint() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder().setEndpoint(myEndpoint).build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_create_setendpoint_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/AsyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/AsyncListVoices.java
new file mode 100644
index 000000000000..0f3a4007d553
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/AsyncListVoices.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_listvoices_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.texttospeech.v1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+
+public class AsyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ asyncListVoices();
+ }
+
+ public static void asyncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ ListVoicesRequest request =
+ ListVoicesRequest.newBuilder().setLanguageCode("languageCode-2092349083").build();
+ ApiFuture future =
+ textToSpeechClient.listVoicesCallable().futureCall(request);
+ // Do something.
+ ListVoicesResponse response = future.get();
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_listvoices_async]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..3e34ca250d59
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoices.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_listvoices_sync]
+import com.google.cloud.texttospeech.v1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ ListVoicesRequest request =
+ ListVoicesRequest.newBuilder().setLanguageCode("languageCode-2092349083").build();
+ ListVoicesResponse response = textToSpeechClient.listVoices(request);
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_listvoices_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoicesString.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoicesString.java
new file mode 100644
index 000000000000..02ce237ff588
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/listvoices/SyncListVoicesString.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_listvoices_string_sync]
+import com.google.cloud.texttospeech.v1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+
+public class SyncListVoicesString {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoicesString();
+ }
+
+ public static void syncListVoicesString() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ String languageCode = "languageCode-2092349083";
+ ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_listvoices_string_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java
new file mode 100644
index 000000000000..e15de8aae730
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_synthesizespeech_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.texttospeech.v1.AudioConfig;
+import com.google.cloud.texttospeech.v1.SynthesisInput;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.VoiceSelectionParams;
+
+public class AsyncSynthesizeSpeech {
+
+ public static void main(String[] args) throws Exception {
+ asyncSynthesizeSpeech();
+ }
+
+ public static void asyncSynthesizeSpeech() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesizeSpeechRequest request =
+ SynthesizeSpeechRequest.newBuilder()
+ .setInput(SynthesisInput.newBuilder().build())
+ .setVoice(VoiceSelectionParams.newBuilder().build())
+ .setAudioConfig(AudioConfig.newBuilder().build())
+ .build();
+ ApiFuture future =
+ textToSpeechClient.synthesizeSpeechCallable().futureCall(request);
+ // Do something.
+ SynthesizeSpeechResponse response = future.get();
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_synthesizespeech_async]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java
new file mode 100644
index 000000000000..1d127eb37d90
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_synthesizespeech_sync]
+import com.google.cloud.texttospeech.v1.AudioConfig;
+import com.google.cloud.texttospeech.v1.SynthesisInput;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.VoiceSelectionParams;
+
+public class SyncSynthesizeSpeech {
+
+ public static void main(String[] args) throws Exception {
+ syncSynthesizeSpeech();
+ }
+
+ public static void syncSynthesizeSpeech() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesizeSpeechRequest request =
+ SynthesizeSpeechRequest.newBuilder()
+ .setInput(SynthesisInput.newBuilder().build())
+ .setVoice(VoiceSelectionParams.newBuilder().build())
+ .setAudioConfig(AudioConfig.newBuilder().build())
+ .build();
+ SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(request);
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_synthesizespeech_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java
new file mode 100644
index 000000000000..f80442244487
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechclient_synthesizespeech_synthesisinputvoiceselectionparamsaudioconfig_sync]
+import com.google.cloud.texttospeech.v1.AudioConfig;
+import com.google.cloud.texttospeech.v1.SynthesisInput;
+import com.google.cloud.texttospeech.v1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1.VoiceSelectionParams;
+
+public class SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig {
+
+ public static void main(String[] args) throws Exception {
+ syncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig();
+ }
+
+ public static void syncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig()
+ throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+ SynthesizeSpeechResponse response =
+ textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
+ }
+ }
+}
+// [END texttospeech_v1_generated_texttospeechclient_synthesizespeech_synthesisinputvoiceselectionparamsaudioconfig_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechsettings/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechsettings/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..c81b5f3e81b2
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1/texttospeechsettings/listvoices/SyncListVoices.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1.samples;
+
+// [START texttospeech_v1_generated_texttospeechsettings_listvoices_sync]
+import com.google.cloud.texttospeech.v1.TextToSpeechSettings;
+import java.time.Duration;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings.Builder textToSpeechSettingsBuilder = TextToSpeechSettings.newBuilder();
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .setRetrySettings(
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ TextToSpeechSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
+ }
+}
+// [END texttospeech_v1_generated_texttospeechsettings_listvoices_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..a9d70ec5a752
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/stub/texttospeechstubsettings/listvoices/SyncListVoices.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.stub.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechstubsettings_listvoices_sync]
+import com.google.cloud.texttospeech.v1beta1.stub.TextToSpeechStubSettings;
+import java.time.Duration;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechStubSettings.Builder textToSpeechSettingsBuilder =
+ TextToSpeechStubSettings.newBuilder();
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .setRetrySettings(
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ TextToSpeechStubSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechstubsettings_listvoices_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java
new file mode 100644
index 000000000000..8d96df8533b5
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_create_setcredentialsprovider_sync]
+import com.google.api.gax.core.FixedCredentialsProvider;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechSettings;
+import com.google.cloud.texttospeech.v1beta1.myCredentials;
+
+public class SyncCreateSetCredentialsProvider {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider();
+ }
+
+ public static void syncCreateSetCredentialsProvider() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder()
+ .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ .build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_create_setcredentialsprovider_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java
new file mode 100644
index 000000000000..fd63bdd75d86
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetCredentialsProvider1.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_create_setcredentialsprovider1_sync]
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechSettings;
+
+public class SyncCreateSetCredentialsProvider1 {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider1();
+ }
+
+ public static void syncCreateSetCredentialsProvider1() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder()
+ .setTransportChannelProvider(
+ TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder().build())
+ .build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_create_setcredentialsprovider1_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetEndpoint.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetEndpoint.java
new file mode 100644
index 000000000000..41869be55d9b
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/create/SyncCreateSetEndpoint.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_create_setendpoint_sync]
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechSettings;
+import com.google.cloud.texttospeech.v1beta1.myEndpoint;
+
+public class SyncCreateSetEndpoint {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetEndpoint();
+ }
+
+ public static void syncCreateSetEndpoint() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings textToSpeechSettings =
+ TextToSpeechSettings.newBuilder().setEndpoint(myEndpoint).build();
+ TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_create_setendpoint_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/AsyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/AsyncListVoices.java
new file mode 100644
index 000000000000..abc0e5a3f181
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/AsyncListVoices.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_listvoices_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.texttospeech.v1beta1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1beta1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+
+public class AsyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ asyncListVoices();
+ }
+
+ public static void asyncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ ListVoicesRequest request =
+ ListVoicesRequest.newBuilder().setLanguageCode("languageCode-2092349083").build();
+ ApiFuture future =
+ textToSpeechClient.listVoicesCallable().futureCall(request);
+ // Do something.
+ ListVoicesResponse response = future.get();
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_listvoices_async]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..20c177694cb3
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoices.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_listvoices_sync]
+import com.google.cloud.texttospeech.v1beta1.ListVoicesRequest;
+import com.google.cloud.texttospeech.v1beta1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ ListVoicesRequest request =
+ ListVoicesRequest.newBuilder().setLanguageCode("languageCode-2092349083").build();
+ ListVoicesResponse response = textToSpeechClient.listVoices(request);
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_listvoices_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoicesString.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoicesString.java
new file mode 100644
index 000000000000..778e2d8c4d6c
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/listvoices/SyncListVoicesString.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_listvoices_string_sync]
+import com.google.cloud.texttospeech.v1beta1.ListVoicesResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+
+public class SyncListVoicesString {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoicesString();
+ }
+
+ public static void syncListVoicesString() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ String languageCode = "languageCode-2092349083";
+ ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_listvoices_string_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java
new file mode 100644
index 000000000000..29cb05afe42b
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/AsyncSynthesizeSpeech.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.texttospeech.v1beta1.AudioConfig;
+import com.google.cloud.texttospeech.v1beta1.SynthesisInput;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.VoiceSelectionParams;
+import java.util.ArrayList;
+
+public class AsyncSynthesizeSpeech {
+
+ public static void main(String[] args) throws Exception {
+ asyncSynthesizeSpeech();
+ }
+
+ public static void asyncSynthesizeSpeech() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesizeSpeechRequest request =
+ SynthesizeSpeechRequest.newBuilder()
+ .setInput(SynthesisInput.newBuilder().build())
+ .setVoice(VoiceSelectionParams.newBuilder().build())
+ .setAudioConfig(AudioConfig.newBuilder().build())
+ .addAllEnableTimePointing(new ArrayList())
+ .build();
+ ApiFuture future =
+ textToSpeechClient.synthesizeSpeechCallable().futureCall(request);
+ // Do something.
+ SynthesizeSpeechResponse response = future.get();
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_async]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java
new file mode 100644
index 000000000000..70d1c39a05fc
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeech.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_sync]
+import com.google.cloud.texttospeech.v1beta1.AudioConfig;
+import com.google.cloud.texttospeech.v1beta1.SynthesisInput;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechRequest;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.VoiceSelectionParams;
+import java.util.ArrayList;
+
+public class SyncSynthesizeSpeech {
+
+ public static void main(String[] args) throws Exception {
+ syncSynthesizeSpeech();
+ }
+
+ public static void syncSynthesizeSpeech() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesizeSpeechRequest request =
+ SynthesizeSpeechRequest.newBuilder()
+ .setInput(SynthesisInput.newBuilder().build())
+ .setVoice(VoiceSelectionParams.newBuilder().build())
+ .setAudioConfig(AudioConfig.newBuilder().build())
+ .addAllEnableTimePointing(new ArrayList())
+ .build();
+ SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(request);
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java
new file mode 100644
index 000000000000..476647bb4167
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechclient/synthesizespeech/SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_synthesisinputvoiceselectionparamsaudioconfig_sync]
+import com.google.cloud.texttospeech.v1beta1.AudioConfig;
+import com.google.cloud.texttospeech.v1beta1.SynthesisInput;
+import com.google.cloud.texttospeech.v1beta1.SynthesizeSpeechResponse;
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechClient;
+import com.google.cloud.texttospeech.v1beta1.VoiceSelectionParams;
+
+public class SyncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig {
+
+ public static void main(String[] args) throws Exception {
+ syncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig();
+ }
+
+ public static void syncSynthesizeSpeechSynthesisinputVoiceselectionparamsAudioconfig()
+ throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
+ SynthesisInput input = SynthesisInput.newBuilder().build();
+ VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
+ AudioConfig audioConfig = AudioConfig.newBuilder().build();
+ SynthesizeSpeechResponse response =
+ textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
+ }
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechclient_synthesizespeech_synthesisinputvoiceselectionparamsaudioconfig_sync]
diff --git a/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechsettings/listvoices/SyncListVoices.java b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechsettings/listvoices/SyncListVoices.java
new file mode 100644
index 000000000000..21c84d04b41e
--- /dev/null
+++ b/java-texttospeech/samples/snippets/generated/com/google/cloud/texttospeech/v1beta1/texttospeechsettings/listvoices/SyncListVoices.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2022 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
+ *
+ * https://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.
+ */
+
+package com.google.cloud.texttospeech.v1beta1.samples;
+
+// [START texttospeech_v1beta1_generated_texttospeechsettings_listvoices_sync]
+import com.google.cloud.texttospeech.v1beta1.TextToSpeechSettings;
+import java.time.Duration;
+
+public class SyncListVoices {
+
+ public static void main(String[] args) throws Exception {
+ syncListVoices();
+ }
+
+ public static void syncListVoices() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ TextToSpeechSettings.Builder textToSpeechSettingsBuilder = TextToSpeechSettings.newBuilder();
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .setRetrySettings(
+ textToSpeechSettingsBuilder
+ .listVoicesSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ TextToSpeechSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
+ }
+}
+// [END texttospeech_v1beta1_generated_texttospeechsettings_listvoices_sync]