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

Failed to unpack object from 'any' field. Expected com.google.cloud.speech.v1.LongRunningRecognizeResponse, found #1038

Closed
andr3medeiros opened this issue Feb 24, 2018 · 6 comments
Assignees

Comments

@andr3medeiros
Copy link

In which file did you encounter the issue?

java-docs-samples/blob/master/speech/cloud-client/src/main/java/com/example/speech/Recognize.java

Describe the issue

Using attached file as an example, upload to a bucket and try to long recognize:

java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar
com.example.speech.Recognize asyncrecognize gs://bucket/omelete_hyperdrive.ogg

After completion, the exception:

Caused by: com.google.api.gax.rpc.UnknownException: java.lang.IllegalStateException: Failed to unpack object from 'any' field. Expected com.google.cloud.speech.v1.LongRunningRecognizeResponse, found
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:117)
at com.google.api.gax.grpc.ProtoOperationTransformers$ResponseTransformer.apply(ProtoOperationTransformers.java:69)
at com.google.api.gax.grpc.ProtoOperationTransformers$ResponseTransformer.apply(ProtoOperationTransformers.java:46)
at com.google.api.core.ApiFutures$GaxFunctionToGuavaFunction.apply(ApiFutures.java:153)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:239)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:229)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:130)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:811)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:653)
at com.google.api.gax.retrying.BasicRetryingFuture.handleAttempt(BasicRetryingFuture.java:159)
at com.google.api.gax.retrying.CallbackChainRetryingFuture$AttemptCompletionListener.handle(CallbackChainRetryingFuture.java:134)
at com.google.api.gax.retrying.CallbackChainRetryingFuture$AttemptCompletionListener.run(CallbackChainRetryingFuture.java:114)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:811)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:653)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.setResult(AbstractTransformFuture.java:245)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:177)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:811)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:653)
at com.google.api.core.AbstractApiFuture$InternalSettableFuture.set(AbstractApiFuture.java:90)
at com.google.api.core.AbstractApiFuture.set(AbstractApiFuture.java:73)
at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onSuccess(GrpcExceptionCallable.java:86)
at com.google.api.core.ApiFutures$1.onSuccess(ApiFutures.java:66)
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1132)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:811)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:653)
at io.grpc.stub.ClientCalls$GrpcFuture.set(ClientCalls.java:487)
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:465)
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:684)
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:392)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:475)
at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:557)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:478)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:590)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to unpack object from 'any' field. Expected com.google.cloud.speech.v1.LongRunningRecognizeResponse, found
at com.google.api.gax.grpc.ProtoOperationTransformers$AnyTransformer.apply(ProtoOperationTransformers.java:131)
at com.google.api.gax.grpc.ProtoOperationTransformers$ResponseTransformer.apply(ProtoOperationTransformers.java:67)
... 51 common frames omitted

Same error when used inside my project:

RecognitionConfig config = RecognitionConfig.newBuilder()
                                            .setEncoding(AudioEncoding.OGG_OPUS)
                                            .setLanguageCode("pt-BR")
                                            .setSampleRateHertz(16000)
                                            .setEnableWordTimeOffsets(true)
                                            .build()

RecognitionAudio audio = RecognitionAudio.newBuilder().setUri(gcsUri).build();
OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = speech.longRunningRecognizeAsync(config, audio);

while (!response.isDone()) {
          LOG.debug("Waiting for response...");
          Thread.sleep(10000);
}
				
results = response.get().getResultsList();
...

Gradle:

compile('com.google.cloud:google-cloud-storage:1.14.0')
compile('com.google.cloud:google-cloud-speech:0.34.0-alpha')

Tried with different files (including FLAC files) and got the same result.

P.S.: FIles under 1min duration are working fine.

omelete_hyperdrive.zip

@lesv
Copy link
Contributor

lesv commented Feb 25, 2018

@nnegrey Is this yours?
@dzlier-gcp If not Noah's could you look at this?

@nnegrey
Copy link
Contributor

nnegrey commented Feb 26, 2018

I think it's mine now.

Taking a quick look (still have to try this myself).

The audio file has a sample rate hertz of 44100.

  1. Possibly change the sample rate hertz to 44100
    .setSampleRateHertz(44100)

A problem might come up though from this page: https://cloud.google.com/speech/reference/rpc/google.cloud.speech.v1#google.cloud.speech.v1.RecognitionConfig.AudioEncoding

Which states:
"Opus encoded audio frames in Ogg container (OggOpus). sample_rate_hertz must be one of 8000, 12000, 16000, 24000, or 48000."

I'm not too knowledgable on audio files, so not sure if that will solve the issue. Gonna try that out first though.

@andr3medeiros
Copy link
Author

andr3medeiros commented Feb 26, 2018

@nnegrey Just adding my 2c on your first thoughts, this message indeed appears with wrong sampleRateHertz, but with files lesser than a minute length.

@nnegrey
Copy link
Contributor

nnegrey commented Feb 26, 2018

One other possible thing I've seen on that same page above: "All encodings support only 1 channel (mono) audio. "

The audio is formatted as stereo. However, I converted it and still had no success.

@nnegrey
Copy link
Contributor

nnegrey commented Feb 26, 2018

So I converted the audio file to FLAC (.raw) and was able to get a transcription back. Still looking in to why the OGG_OPUS format is not working.

Transcription: Ragnarok Liga da Justiça E as novidades do mundo de Star Wars 7 pendrive De hoje em diante da televisão explique de atenção protagonista Ela será Ellen Page ela vai interpretar a personagem Vânia que é meio que uma ovelha negra dentro de um grupo de super-heróis Ainda não temos detalhes de quem vai dirigir o Como está o desenvolvimento da produção dessa nova série da Netflix que deve estrear no próximo ano fica Júlio Aquino Mallet pen drive para mais novidades nos Estados Unidos a previsão é que ele consiga ultrapassar a bilheteria de 700 milhões de dólares se tornando um dos filmes que mais arrecadou dinheiro em 2017 vamos ver se ele vai conseguir superar a marca de Guardiões da Galáxia 2 e também de Mulher Maravilha 2 dos filmes de super-heróis mais lucrativos de 2017 de Liga da Justiça vemos pela primeira vez o Superman
Transcription: liga aí Ricardinho está com uma roupa completa do Herói ao lado do Batman da Mulher Maravilha do Flash e do Produtor Charles roven além de Zack Snyder naquela época ainda estava dirigindo o filme não custa lembrar que liga da justiça chega aos cinemas na próxima quarta-feira aqui no Brasil e olha fica de olho no Twitter no Facebook no YouTube do omelete que hoje hoje na sexta-feira saem as primeiras impressões da gente sobre o filme nós assistimos ele na semana passada e a crítica completa sai na próxima terça-feira deixa nos comentários O que que você está esperando de Liga da Justiça pede para o 2 ganhou seu primeiro cachê como não podia ser diferente ele faz uma nova piada todos os novos personagens do filme estão dentro dessa arte onde você vê o Deadpool segurando um peru para o Dia de Ação de Graças que é uma data muito comemorada nos Estados Unidos e ao lado dele está o cable também nos próximos dias já que a campanha de marketing
Transcription: Deadpool está marcada para o começo do ano que vem dia 9 de novembro a última quinta-feira foi um dia bombástico para os fãs de Star Wars a Disney junto com a lucasfilm anunciou que uma nova trilogia da série vai ser produzida dirigida escrita por Brian Johnson o diretor de Star Wars os últimos Jedi espere uma trilogia com personagens completamente novos isso não teremos mais a família Sky Walker nem Rei Nem sim nem ninguém que a gente conhece agora vai ser uma coisa completamente nova no universo de Star Wars ainda não existe previsão de estreia e a única coisa certa é que o Brian Johnson vai encabeçar esse novo projeto além disso a Disney confirmou também que uma série com atores para franquia Star Wars está sendo produzida e vai estrear no novo serviço de streaming deles que vai chegar ao mercado em 2019 junto com essa série de Star Wars teremos também uma série de High School Music 1 de monstros s.a. muitas novidades que vão ser discutidas
Transcription: gilete nos próximos dias não esquece de deixar seu comentário sobre as notícias curtir o vídeo e assinar o canal tchau

@nnegrey
Copy link
Contributor

nnegrey commented Dec 7, 2018

Was able to dig into this a bit more and finally found the issue. Turns out that underlying codec in that audio file is OGG Vorbis where the Speech API only supports OGG_OPUS

@nnegrey nnegrey closed this as completed Dec 7, 2018
anguillanneuf pushed a commit that referenced this issue Nov 15, 2022
…#1038)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-core](https://togithub.com/googleapis/java-core) | `2.8.19` -> `2.8.20` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.20/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.20/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.20/compatibility-slim/2.8.19)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.20/confidence-slim/2.8.19)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-video-intelligence).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTMuMCIsInVwZGF0ZWRJblZlciI6IjMyLjIxMy4wIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants