Open prokulit06 opened 5 years ago
please help me :(
Hey @prokulit06 Did you find any solution?
same problem , any solution ???
@viet97 i solved this by upgrading the version of the beta of google speech api you can search that in google and protobuf java and grpc just try upgrade to new latest version
@ravinderpayal yes by upgrading the version on it in grpc speech to text api and protobuf java
I tried using the official version released and the authentication works. Then I'll try the the Beta version but it doesn't work. So, whats the problem with this? Is there a new Key in Beta version or is there something wrong of my method?
This is how I implement the Google Cloud Speech To Text API beta version:
implementation group: 'com.google.api.grpc', name: 'grpc-google-cloud-speech-v1p1beta1', version: '0.6.0' implementation group: 'com.google.api.grpc', name: 'proto-google-cloud-speech-v1p1beta1', version: '0.50.0' implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.3.1' When I tried using the Beta version, this is the error that I encountered.
Process: com.example.ezminute, PID: 25333 java.lang.AbstractMethodError: abstract method "java.util.concurrent.ScheduledExecutorService io.grpc.internal.ClientTransportFactory.getScheduledExecutorService()" at io.grpc.internal.CallCredentialsApplyingTransportFactory.getScheduledExecutorService(CallCredentialsApplyingTransportFactory.java:52) at io.grpc.internal.ManagedChannelImpl.(ManagedChannelImpl.java:569)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:440)
at com.example.ezminute.CloudSpeechService$AccessTokenTask.onPostExecute(CloudSpeechService.java:422)
at com.example.ezminute.CloudSpeechService$AccessTokenTask.onPostExecute(CloudSpeechService.java:375)
at android.os.AsyncTask.finish(AsyncTask.java:695)
at android.os.AsyncTask.-wrap1(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
And these is the method that I used in authenticating the Google Cloud Beta Version.
private class AccessTokenTask extends AsyncTask<Void, Void, AccessToken> {
}
/**
Authenticates the gRPC channel using the specified {@link GoogleCredentials}. */ private static class GoogleCredentialsInterceptor implements ClientInterceptor {
private final Credentials mCredentials;
private Metadata mCached;
private Map<String, List> mLastMetadata;
GoogleCredentialsInterceptor(Credentials credentials) { mCredentials = credentials; }
@Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, final Channel next) { return new ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>( next.newCall(method, callOptions)) { @Override protected void checkedStart(Listener responseListener, Metadata headers)
throws StatusException {
Metadata cachedSaved;
URI uri = serviceUri(next, method);
synchronized (this) {
Map<String, List> latestMetadata = getRequestMetadata(uri);
if (mLastMetadata == null || mLastMetadata != latestMetadata) {
mLastMetadata = latestMetadata;
mCached = toHeaders(mLastMetadata);
}
cachedSaved = mCached;
}
headers.merge(cachedSaved);
delegate().start(responseListener, headers);
}
};
}
/**
private URI removePort(URI uri) throws StatusException { try { return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), -1 / port /, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { throw Status.UNAUTHENTICATED .withDescription("Unable to construct service URI after removing port") .withCause(e).asException(); } }
private Map<String, List> getRequestMetadata(URI uri) throws StatusException {
try {
return mCredentials.getRequestMetadata(uri);
} catch (IOException e) {
throw Status.UNAUTHENTICATED.withCause(e).asException();
}
}
private static Metadata toHeaders(Map<String, List> metadata) {
Metadata headers = new Metadata();
if (metadata != null) {
for (String key : metadata.keySet()) {
Metadata.Key headerKey = Metadata.Key.of(
key, Metadata.ASCII_STRING_MARSHALLER);
for (String value : metadata.get(key)) {
headers.put(headerKey, value);
}
}
}
return headers;
}
}