2
votes

I have built a web based Speech-to-Text application with Google Speech-to-Text API.

The application flow:

  1. Get audio stream from browser
  2. Stream audio data to a speech recognition service and get real time results as our user talks

enter image description here

I have referenced the sample code in my application, the streamingRecognize request works perfectly with a signal client call, and my server can receive the interim-transcription result from Google Speech API. However, when there are more then one client call streamingRecognize simultaneously, Google Speech API will get stuck. So, may I know how to handle more than one streamingRecognize request concurrently? Do I need to create another client to process the second streamingRecognize request? Thanks.

Back-end server specifications:

  • NodeJS
  • Socket.io
2
Thanks for your reply @nikolay-shmyrev, I have tried to push the created client(s) into a global array, or even used eval() function to create dynamic client variables. However, Google Speech API only returns the interim-transcription result to the firstly created client... - New Hand

2 Answers

2
votes

You should be able to create multiple streaming threads by using the same StreamingRecognize() client, the ones that can be used to send the requests in parallel. You can take a look on this and this Github posts where it is discussed this topic.

I suggest you to try this alternative and verify if you can perform these streaming calls by creating 2 different objects or clients, such as:

const client = new speech.SpeechClient();
const recognizeStream = client.streamingRecognize(request)
...
const recognizeStream2 = client.streamingRecognize(request)
...

On the other hand, if you want to make audio recognitions for batch, it is rather recommended to use synchronous or asynchronous methods.

1
votes

Trying to do same, and meeting same troubles as you, or they stop working, or just one client works time to time and other giving strange results, sometimes both, looks like you have single buffer for your main account, have you tried generating api/tokens for each user? Does it worth it, or still there will be same buffer