I'm using python api for Google Cloud Speech to Text. I'm getting the following error when performing client.streaming_recognize
google.api_core.exceptions.InvalidArgument: 400 Unable to recognize speech, code=-73532, possible error in recognition config. Please correct the config and retry the request.
I searched for the error code but didn't find any result.
For the client application I followed this. The web server is Flask based, below is the part where I process data from client.
@socketio.on('initRecording')
def init_recording(data):
print('Initiated recording on server')
config = types.RecognitionConfig(
encoding='LINEAR16',
sample_rate_hertz=16000,
language_code='en-US')
streaming_config = types.StreamingRecognitionConfig(
config=config, interim_results=False)
streaming_client = StreamingClient()
streaming_client.configure(streaming_config)
@socketio.on('binaryData')
def process_recording(data):
emit('speechData', streaming_client.write(data))
class StreamingClient():
def __init__(self):
self.client = speech.SpeechClient()
self.buffer = []
def configure(self, streaming_config):
self.streaming_config = streaming_config
def write(self, data):
self.buffer.append(types.StreamingRecognizeRequest(audio_content=data))
responses = self.client.streaming_recognize(
self.streaming_config, self.buffer)
for response in responses:
if response.error:
continue
if not response.results:
continue
result = response.results[0]
if not result.alternatives:
continue
if result.is_final:
self.buffer = []
return result.alternatives[0].transcript
pip install --upgrade google-cloud-speech. Take into account that you need to set theGOOGLE_APPLICATION_CREDENTIALS. Follow this documentation: cloud.google.com/speech-to-text/docs/reference/… - Alex Riquelme