I am trying to configure google speech api to work in my project within the company's firewall. I have configured the SpeechSettings as following:
InputStream is = this.getClass().getResourceAsStream("/my-service-account.json");
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(is));
SpeechSettings.Builder builder = SpeechSettings.newBuilder();
builder.setTransportProvider(SpeechSettings.defaultTransportProvider());
builder.setCredentialsProvider(credentialsProvider);
SpeechSettings settings = builder.build();
SpeechClient.create(settings);
Using this works outside proxy network correctly and starts a speech recognize session. But it fails to transcribe anything under a proxy authenticated network and times out with this error- UNAVAILABLE: Transport closed for unknown reason
in ApiStreamObserver class.I am thinking the Grpc transport is being closed because of the firewall timeout.
Is it possible to authenticate with the proxy authentication credentials while creating the speech client session? Thanks.
The environment variable
GRPC_PROXY_EXP
has been deprecated, and while it currently still works, you should be able to use the standard java propertieshttps.proxyHost
andhttps.proxyPort
. Either setting them programmatically directly in the current JVM (not recommended):or when starting the JVM, e.g.