Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google speech API throws Invalid audio channel count

Google Speech API throws Invalid audio channel count Exception for the audio recorded on a Mac machine.

I'm just using the sample application provided by Google.

com.google.api.gax.grpc.ApiException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid audio channel count
    at com.google.api.gax.grpc.ExceptionTransformingCallable$ExceptionTransformingFuture.onFailure(ExceptionTransformingCallable.java:109)
    at com.google.api.gax.core.ApiFutures$1.onFailure(ApiFutures.java:52)
    at com.google.common.util.concurrent.Futures$6.run(Futures.java:1764)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:753)
    at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
    at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:466)
    at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:442)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:481)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:398)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:513)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
    at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:154)
    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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid audio channel count
    at io.grpc.Status.asRuntimeException(Status.java:545)
    ... 13 more

Does this require any special configuration?

What does this error mean?

like image 362
Vijay Innamuri Avatar asked Apr 06 '17 07:04

Vijay Innamuri


1 Answers

Audio recorded on a Mac is most likely stereo, but currently the API seems to only support 1-channel (mono) audio. From the Audio Encoding section of the docs:

Audio encoding of the data sent in the audio message. All encodings support only 1 channel (mono) audio.

The simplest solution here might be to just convert your sample to mono using something like Audacity.

like image 199
Alex Chao Avatar answered Sep 18 '22 10:09

Alex Chao