GoogleCloudPlatform / android-docs-samples

Apache License 2.0
373 stars 594 forks source link

Getting io.grpc.StatusRuntimeException #3

Closed NilaySheth closed 8 years ago

NilaySheth commented 8 years ago

Hi,

I am getting following error while transcribing long audio:

Error calling the API. io.grpc.StatusRuntimeException: UNKNOWN at io.grpc.Status.asRuntimeException(Status.java:545) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:370) at io.grpc.ClientInterceptors$CheckedForwardingClientCall.start(ClientInterceptors.java:203) at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:248) at io.grpc.stub.ClientCalls.asyncStreamingRequestCall(ClientCalls.java:241) at io.grpc.stub.ClientCalls.asyncBidiStreamingCall(ClientCalls.java:106) at com.google.cloud.speech.v1beta1.SpeechGrpc$SpeechStub.streamingRecognize(SpeechGrpc.java:232) at com.google.cloud.android.speech.ApiFragment.startRecognizing(ApiFragment.java:188) at com.google.cloud.android.speech.MainActivity$1.onVoiceStart(MainActivity.java:64) at com.google.cloud.android.speech.VoiceRecorder$ProcessVoice.run(VoiceRecorder.java:201) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.IllegalStateException: OAuth2Credentials instance does not support refreshing the access token. An instance with a new access token should be used, or a derived type that supports refreshing should be used. at com.google.auth.oauth2.OAuth2Credentials.refreshAccessToken(OAuth2Credentials.java:115) at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:97) at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:74) at com.google.cloud.android.speech.ApiFragment$GoogleCredentialsInterceptor.getRequestMetadata(ApiFragment.java:326) at com.google.cloud.android.speech.ApiFragment$GoogleCredentialsInterceptor.access$200(ApiFragment.java:244) at com.google.cloud.android.speech.ApiFragment$GoogleCredentialsInterceptor$1.checkedStart(ApiFragment.java:268) at io.grpc.ClientInterceptors$CheckedForwardingClientCall.start(ClientInterceptors.java:195) at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:248)  at io.grpc.stub.ClientCalls.asyncStreamingRequestCall(ClientCalls.java:241)  at io.grpc.stub.ClientCalls.asyncBidiStreamingCall(ClientCalls.java:106)  at com.google.cloud.speech.v1beta1.SpeechGrpc$SpeechStub.streamingRecognize(SpeechGrpc.java:232)  at com.google.cloud.android.speech.ApiFragment.startRecognizing(ApiFragment.java:188)  at com.google.cloud.android.speech.MainActivity$1.onVoiceStart(MainActivity.java:64)  at com.google.cloud.android.speech.VoiceRecorder$ProcessVoice.run(VoiceRecorder.java:201)  at java.lang.Thread.run(Thread.java:818) 

I cannot find out the reason for this issue.

yaraki commented 8 years ago

What do you mean by "long audio"? Did you edit the code?

NilaySheth commented 8 years ago

I am trying to transcribe a video with length of more than 2 minutes. But after sometime, I am getting following error and audio transcribing suddenly gets stopped. I am getting this error in onError of ApiFragment.

I am just using the As Is code uploaded here.

yaraki commented 8 years ago

The API cannot process very long audio, for example more than 30 seconds, in a single API call.

The sample tries to find silence while recording (see VoiceRecorder.java). This should work fine for most use cases unless you can keep on talking for a very long time with a single breath.

If you are directly feeding audio streaming of the video to the API, please add some logic to separate them into smaller segments just like VoiceRecorder.java does.

NilaySheth commented 8 years ago

So if I keep SPEECH_TIMEOUT_MILLIS as low as possible, then will it work ?

yaraki commented 8 years ago

It might work. It really depends on the input, though.

SPEECH_TIMEOUT_MILLIS is a constant used to detect silence. If the level of audio is below AMPLITUDE_THRESHOLD for more than SPEECH_TIMEOUT_MILLIS milliseconds, VoiceRecorder determines that as silence.

Probably I should just forcibly cut the input when the audio is recorded longer than 30 seconds or so.

NilaySheth commented 8 years ago

Great. Thanks a lot. I think I can implement that too.

NilaySheth commented 8 years ago

But does this error say the same thing:

io.grpc.StatusRuntimeException: OUT_OF_RANGE: Operation was attempted past the valid range. at io.grpc.Status.asRuntimeException(Status.java:545) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:370) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:458) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$500(ClientCallImpl.java:385) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$3.runInContext(ClientCallImpl.java:486) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52) at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:154) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)

yaraki commented 8 years ago

OK, reading the deep parts of original error, it seems like a different issue. It is complaining about the access token expiration. I didn't add logic to refresh access tokens in this sample, so you will get the error when you have the app open for too long, such as over an hour.

The second error you posted does seem like the one about audio too long. Do you constantly get the error or only sometimes?

NilaySheth commented 8 years ago

Only sometimes. I can say that I am getting it once every 5 to 6 times.

yaraki commented 8 years ago

I suppose it is about audio too long. I can't be sure as I cannot take a look at the app screen and what's going on, but I guess that VoiceRecorder.java sometimes detects silence, sometimes not, thus resulting in an inconsistent error pattern. I'll improve the class, but it will take some time. Thank you for reporting the issue.

NilaySheth commented 8 years ago

Sure. thanks a lot for the support. I will be waiting for the update.

danaharon commented 8 years ago

For streaming, we only support up to 60 seconds at a time.

If you get an error while streaming less than 60 seconds please let us know, we would love to work with you on resolving.

NilaySheth commented 8 years ago

The streaming stops and start based silence detection. So by going that logic, streaming is always less then 60 seconds. But if I continue this demo for more than 60 seconds (with start and stop included) then it should work.

NilaySheth commented 8 years ago

Hi Guys,

Any updates on this ?

yaraki commented 8 years ago

Uploaded a pull request for VoiceRecorder.

MohitDixit commented 6 years ago

Hi, I am getting below errors during calling cloud speech API in this demo, and the outcomes are like

  1. It gets falling sometimes continuously.
  2. It takes quick response from us and produces less accurate results so we have to hit it again and again.
  3. Audio data is being streamed too slow. Please stream audio data approximately at real time.
  4. Error calling the API.

Case 1:

    09-03 12:40:13.945 13676-14146//SpeechService: Error calling the API.
io.grpc.StatusRuntimeException: UNAVAILABLE
    at io.grpc.Status.asRuntimeException(Status.java:543)
    at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:395)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
    at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:512)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:429)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:544)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)
 Caused by: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7bbeca98: Failure in SSL library, usually a protocol error
error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x72dccd74:0x00000000)
    at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:449)
    at io.grpc.okhttp.OkHttpProtocolNegotiator.negotiate(OkHttpProtocolNegotiator.java:103)
    at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.negotiate(OkHttpProtocolNegotiator.java:169)
    at io.grpc.okhttp.OkHttpTlsUpgrader.upgrade(OkHttpTlsUpgrader.java:76)
    at io.grpc.okhttp.OkHttpClientTransport$1.run(OkHttpClientTransport.java:433)
        ... 4 more
 Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7bbeca98: Failure in SSL library, usually a protocol error
error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x72dccd74:0x00000000)
    at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
    at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:406)

Case 2:

         09-05 17:08:54.795 18401-19870/com.google.cloud.android.speech E/SpeechService: Error calling the API.
io.grpc.StatusRuntimeException: UNAVAILABLE: Transport stopped
    at io.grpc.Status.asRuntimeException(Status.java:543)
    at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:395)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
    at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:512)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:429)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:544)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:761)

Case 3:

    08-30 16:20:21.575 10494-10970/ E/SpeechService: Error calling the API.
io.grpc.StatusRuntimeException: OUT_OF_RANGE: Audio data is being streamed too slow. Please stream audio data approximately at real time.
    at io.grpc.Status.asRuntimeException(Status.java:543)
    at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:395)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
    at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:512)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:429)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:544)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)

Kindly help us out for smooth operation in Speech api.

aravindanf22labs commented 5 years ago

io.grpc.StatusRuntimeException: OUT_OF_RANGE: Audio Timeout Error: Long duration elapsed without audio. Audio should be sent close to real time. at io.grpc.Status.asRuntimeException(Status.java:543) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:395) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426) at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:512) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:429) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:544) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Unable to solve this issue. Whats the cause and solution for this issue?