Skip to content

Streaming data either too fast or too slow #927

Description

@changkun

Description

I try to send mic data to from browser across my server then to google for recognition, here is the core code for data sending to google cloud api.
My data get from a browser client, transferred by WebSocket.

const context = new AudioContext();
....//audioPromise --> micStream --> context.createMediaStreamSource(micStream)
const scriptNode = context.createScriptProcessor(4096, 1, 1); // context is AudioContext with 48000 sample rate
scriptNode.addEventListener('audioprocess', function(e) {
      const floatSamples = e.inputBuffer.getChannelData(0);
      const data = btoa(floatSamples);
      stompClient.send('/wss/speech/transcribe', {}, data);
});

Here is server-side data logic sending data to google:

StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder()
.setAudioContent(ByteString.copyFrom(java.util.Base64.getDecoder().decode(data)))
.build();
// Thread.sleep(2550); // without this line, i got too fast; with thread.sleep an other numbers yeild either too slow or too fast, what is optimial?
requestObserver.onNext(request);

Issues

  1. Audio data is being streamed too fast. Please stream audio data approximately at real time; or
  2. Audio data is being streamed too slow. Please stream audio data approximately at real time;
  3. io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Client GRPC deadline too short. Should be at least: 3 * audio-duration + 5 seconds. Current deadline is: 199.99576816754416 second(s). Required at least: 206 second(s).

Could you help me is there anything I did wrong? How can I solve these issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions