question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Cloud Speech : "Invalid JSON payload received. Unknown name "speech_context" at 'config': Cannot find field."

See original GitHub issue

Steps to reproduce

  1. The error occurs when recognize_google_cloud method is used with preferred_phrases parameter.
  2. Use the google cloud speech recognition like this, r.recognize_google_cloud(audio, credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS,preferred_phrases=['hi, hello']))

Expected behaviour

The request should be processed successfully and the audio input from microphone should be recognized as text.

Actual behaviour

Received the following exception,

Could not request results from Google Cloud Speech service; <HttpError 400 when requesting https://speech.googleapis.com/v1/spee
ch:recognize?alt=json returned "Invalid JSON payload received. Unknown name "speech_context" at 'config': Cannot find field.">

I looked into the source of the recognize_google_cloud method,

if preferred_phrases is not None: speech_config["speechContext"] = {"phrases": preferred_phrases}

The key where preferred_phrases is included is given as speechContext, but when referred to official google cloud speech docs, its actually speechContexts. Below is the sample request json obtained from docs,

{ "config": { "encoding":"FLAC", "sampleRateHertz": 16000, "languageCode":"en-US", "speechContexts": { "phrases":["hoful","shwazil"] } }, "audio":{ "uri":"gs://speech-demo/shwazil_hoful.flac" } }

System information

My system is Windows 10 x64. My Python version is 3.6.4. My Pip version is 9.0.1

My SpeechRecognition library version is 3.8.1

My PyAudio library version is 0.2.11

My microphones are: [‘Microsoft Sound Mapper - Input’, ‘Microphone (Realtek Audio)’, ‘Microsoft Sound Mapper - Output’, 'Speakers / Headphones (Realtek ']

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Jan 12, 2021

Is it really fixed?

"Invalid JSON payload received. Unknown name "speechContext" at 'config': Cannot find field.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'config', 'description': 'Invalid JSON payload received. Unknown name "speechContext" at \'config\': Cannot find field.'}]"

I see that it was merged, but it was sent to PyPi? (or better, will it be sent?)

image

Speech Recognition 3.8.1 (holy shit, last release in 2017 ^ - ^ - it looks that the native client can be a good choice for context fine-tune)

This package is just dead!

2reactions
pranjaldagacommented, May 9, 2018

Thanks, @avinashs24 for asking this! I was having the same trouble but on the suggestion of @lichengunc I changed from “SpeechContext” to “SpeechContexts” in the speech_recognition init file and it works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid JSON payload received. Unknown name "encoding" at ...
Google Cloud - Invalid JSON payload received. Unknown name "encoding" at 'config': Proto field is not repeating, cannot start list · Ask ...
Read more >
Google Cloud Speech : "Invalid JSON payload received ...
Google Cloud Speech : "Invalid JSON payload received. Unknown name "speech_context" at 'config': Cannot find field."
Read more >
RecognitionConfig | Cloud Speech-to-Text Documentation
Encoding of audio data sent in all RecognitionAudio messages. This field is optional for FLAC and WAV audio files and required for all...
Read more >
googleapis documentation - Google Cloud
This field is set to the value of the QueryParameters.payload field passed in the request. Some integrations that query a Dialogflow agent may...
Read more >
Index | Google GAX and Proto Client PHP
Configuration of authorization. AuditLog — Class in namespace Google\Cloud\Audit: Common audit log format for Google Cloud Platform API operations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found