Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfiniteStreamRecognize - io.grpc.StatusRuntimeException: CANCELLED: Failed to read message when EnableVoiceActivityEvents is true #8950

Open
stefalbi opened this issue Dec 21, 2023 · 5 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.

Comments

@stefalbi
Copy link

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/speech/src/main/java/com/example/speech/InfiniteStreamRecognize.java

Did you change the file? If so, how?

Added enable voice activity event option and set audio channel count to 1

RecognitionConfig recognitionConfig =
RecognitionConfig.newBuilder()
.setEncoding(RecognitionConfig.AudioEncoding.LINEAR16)
.setLanguageCode(languageCode)
.setSampleRateHertz(16000)
.setAudioChannelCount(1)
.build();

StreamingRecognitionConfig streamingRecognitionConfig =
StreamingRecognitionConfig.newBuilder()
.setConfig(recognitionConfig)
.setInterimResults(true)
.setEnableVoiceActivityEvents(true)
.setVoiceActivityTimeout(VoiceActivityTimeout.newBuilder()
.setSpeechStartTimeout(Duration.newBuilder().setSeconds(15L))
)

.build();

Describe the issue

After I receive the event SPEECH_ACTIVITY_BEGIN I get the CancelledException: Failed to read message.

@stefalbi stefalbi added priority: p2 Moderately-important priority. Fix may not be included in next release. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 21, 2023
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 21, 2023
@minherz minherz assigned Shabirmean and unassigned minherz Dec 21, 2023
@minherz
Copy link
Contributor

minherz commented Dec 21, 2023

@Shabirmean please, triage this issue. If the problem is with the sample, please submit a fix or comment with the problem description and/or fix suggestion

@minherz
Copy link
Contributor

minherz commented Dec 21, 2023

@stefalbi it will help us to triage the problem if you are able to answer to a few questions below:

  1. Can you please confirm that the original example (without your changes) works as expected?
  2. I assume that you added the links to this code block. Can you run your code without setting VoiceActivityTimeout and report whether you get this exception?
  3. I assume that the CancelledException is catched by the catch exception block at the end of the sample. Can you please post the full content of the exception printed by the catch block?

Thank you

@stefalbi
Copy link
Author

stefalbi commented Dec 21, 2023

  1. yes, it works
  2. without setting VoiceActivityTimeout it does not works
  3. I made a new test and printed the error wirh the stack trace on this method, the exception causing the CANCELLED message was an IndexOutOfBoundsException , the sample does not handle StreamingRecognizeResponse on the ResponseObserver onResponse method with empty ResultList, causing IndexOutOfBoundsException here

Here the stack tracecom.google.api.gax.rpc.CancelledException: io.grpc.StatusRuntimeException: CANCELLED: Failed to read message. at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:88) at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:41) at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:86) at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:66) at com.google.api.gax.grpc.ExceptionResponseObserver.onErrorImpl(ExceptionResponseObserver.java:82) at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(StateCheckingResponseObserver.java:84) at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(GrpcDirectStreamController.java:148) at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) at com.google.api.gax.grpc.ChannelPool$ReleasingClientCall$1.onClose(ChannelPool.java:541) at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489) at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453) at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:567) at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:71) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:735) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:716) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: io.grpc.StatusRuntimeException: CANCELLED: Failed to read message. at io.grpc.Status.asRuntimeException(Status.java:539) ... 17 more Caused by: java.lang.IndexOutOfBoundsException: Index: 0 at java.util.Collections$EmptyList.get(Collections.java:4454) at com.example.speech.InfiniteStreamRecognize$1.onResponse(InfiniteStreamRecognize.java:141) at com.example.speech.InfiniteStreamRecognize$1.onResponse(InfiniteStreamRecognize.java:1) at com.google.api.gax.tracing.TracedResponseObserver.onResponse(TracedResponseObserver.java:91) at com.google.api.gax.grpc.ExceptionResponseObserver.onResponseImpl(ExceptionResponseObserver.java:74) at com.google.api.gax.rpc.StateCheckingResponseObserver.onResponse(StateCheckingResponseObserver.java:60) at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onMessage(GrpcDirectStreamController.java:133) at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33) at io.grpc.internal.DelayedClientCall$DelayedListener.onMessage(DelayedClientCall.java:473) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:660) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:647) ... 5 more

@averikitsch averikitsch assigned minherz and unassigned Shabirmean Jan 2, 2024
@averikitsch
Copy link
Contributor

@minherz Shabir does not work on samples anymore, can you reroute? Thanks!

@minherz minherz assigned gericdong and unassigned minherz Jan 2, 2024
@minherz minherz added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 2, 2024
@minherz
Copy link
Contributor

minherz commented Jan 2, 2024

@gericdong you are listed as one of the owners of the /speech code samples. Can you please look into the info about and provide feedback about use of the modified code and a possible problem for the observed behavior?

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

8 participants
@minherz @averikitsch @Shabirmean @ssvir @stefalbi @gericdong and others