GoogleCloudPlatform / android-docs-samples

Apache License 2.0
375 stars 596 forks source link

io.grpc.StatusRuntimeException: OUT_OF_RANGE: Audio data is being streamed too slow. Please stream audio data approximately at real time. #37

Open sckalman opened 6 years ago

sckalman commented 6 years ago

07-25 18:15:52.504 12312-12312/com.google.cloud.android.speech D/HwCust: Create obj success use class android.widget.HwCustTextViewImpl 07-25 18:15:52.504 12312-12312/com.google.cloud.android.speech D/HwCust: Create obj success use class android.widget.HwCustTextViewImpl 07-25 18:15:52.784 12312-12735/com.google.cloud.android.speech I/SpeechService: API completed. 07-25 18:16:23.064 12312-12735/com.google.cloud.android.speech I/SpeechService: API completed. 07-25 18:16:53.034 12312-12735/com.google.cloud.android.speech 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:833) 07-25 18:17:09.484 12312-12312/com.google.cloud.android.speech V/AudioManager: preDispatchKeyEvent keycode: 4 stream: -2147483648 07-25 18:17:09.564 12312-12312/com.google.cloud.android.speech V/AudioManager: preDispatchKeyEvent keycode: 4 stream: -2147483648 07-25 18:17:10.084 12312-12312/com.google.cloud.android.speech I/View: ssignParent(ViewParent parent) parent is: null 07-25 18:17:10.094 12312-12312/com.google.cloud.android.speech I/View: ssignParent(ViewParent parent) parent is: null

dan6886 commented 6 years ago

i am also meet the issue?

aravindanf22labs commented 5 years ago

I am facing similar issue. The listener does not work until this issue comes up. Post crash, the listener starts working. Below is the trace

Service: Error calling the API. io.grpc.StatusRuntimeException: OUT_OF_RANGE: Audio data is being streamed too fast. 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:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764)

Ravipatel401 commented 5 years ago

Please Suggest Same I am facing.

Caused by: 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:530) ... 23 more java.util.concurrent.ExecutionException: com.google.api.gax.rpc.OutOfRangeException: io.grpc.StatusRuntimeException: OUT_OF_RANGE: Audio Timeout Error: Long duration elapsed without audio. Audio should be sent close to real time. at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:531) at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:512) at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83) at org.apache.jsp.speechToText_jsp._jspService(speechToText_jsp.java:255) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

lansedebing commented 5 years ago

Is there someone slove this?

Ravipatel401 commented 5 years ago

Not yet i need solution and looking for it

Sent from my iPhone

On 14-Jun-2019, at 2:59 PM, lansedebing notifications@github.com wrote:

Is there someone slove this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ped7g commented 4 years ago

I was facing this issue while using streamingRecognizeCallable() (in Kotlin), after the user signalled end of audio by clicking button, I just stopped audio emitter and thus stopped streaming sound data to recognition service. While the interim results were good, the "final=true" result was received only several seconds (like 3-5s) later, after the OUT_OF_RANGE error.

I managed to figure it out, when user signals end of transmission, instead of building another StreamingRecognizeRequest with new audio data, I call requestStream.onCompleted(). This let's google service know there will be no more data and it will send the "final" result back quickly, and I don't get the OUT_OF_RANGE exception any more.

Santhu commented 4 years ago

I was facing this issue while using streamingRecognizeCallable() (in Kotlin), after the user signalled end of audio by clicking button, I just stopped audio emitter and thus stopped streaming sound data to recognition service. While the interim results were good, the "final=true" result was received only several seconds (like 3-5s) later, after the OUT_OF_RANGE error.

I managed to figure it out, when user signals end of transmission, instead of building another StreamingRecognizeRequest with new audio data, I call requestStream.onCompleted(). This let's google service know there will be no more data and it will send the "final" result back quickly, and I don't get the OUT_OF_RANGE exception any more.

Hello ped, i am also facing similar issue it would really help full if you can throw some sample. thanks in advance

ped7g commented 4 years ago

Hello ped, i am also facing similar issue it would really help full if you can throw some sample. thanks in advance

https://github.com/GoogleCloudPlatform/android-docs-samples/blob/a49dd7157ee56e5ff8d05d29416f44403b241a46/speech/SpeechRecognitionClient/app/src/main/java/com/google/cloud/examples/speechrecognition/MainActivity.kt#L117

I have similar code to this example, here in the "bytes ->" callback, I test new class variable mUserRequestedStop (set to true in new onPause function, which I call when I know the audio stream from mic should be ended, like the user does tap the mic-off button or app goes to background):

        mAudioEmitter?.start { bytes ->
            if (mUserRequestedStop) {
                // ensure mic data stops
                mAudioEmitter?.stop()
                mAudioEmitter = null
                // and give nudge to SpeechToText service that this is all done
                requestStream.onCompleted()
                return@start
            }

Before I was only stopping the audio emitter (stop() call), which leads to OUT_OF_RANGE timeout error in recognizer.

edit: now I see they do this mAudioEmitter?.stop() in the example in the Activity.onPause, but they don't call the onComplete on the request, so this example will also cause the OUT_OF_RANGE errors when you put its activity into background while it is listening.

I guess one way is to extract recognition requestStream as class property and call onCompleted in the onPause, or add boolean flag like I have, and let it stop in the next data callback (which happens every few milliseconds when new audio data are available, so the real pause will be delayed only 100-200ms maybe).

Santhu commented 4 years ago

Thanks Ped,

for your quick response will work on it.

Santhu commented 4 years ago

Thanks Ped it worked.