Open avinashs24 opened 6 years ago
This issue was solved with pull request #304. Seems it is still present when installing via pip rather than from sources
@dcam0050 I install from sources but still have the issue somehow, I don't see that in the code. The issue not speechContexts
over speechContext
at the moment. It is something else, looking into it.
I believe the issue is "speechContexts" over "speechContext", please check your pip installed code again. :-)
This must be updated in pypi as well. When will it be done?
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.
same here - changed it locally meanwhile but I'm sure havign this packaged would be nice for a lot of people since you stumble upon this pretty quickly when using google cloud speech
Bug is still here. Downloaded the latest speech_recognition package (Version 3.8.1) from pip. Had to manually change it from speechContext to SpeechContexts in the speech_recognition init file.
After the DYI fix on the init file, passphrase doesn't error anymore but I haven't noticed any increase in response time for the short one word commands I'm shouting. shouting doesn't help either
Does anyone have any tips for speeding up these one word requests? preferred_phrases=['yes','no','stop']
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?)
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!
@dcam0050 I installed the latest version from source (as suggested above) and ran r.recognize_google_cloud(audio, credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS)
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/speech_recognition/__init__.py", line 933, in recognize_google_cloud
from google.cloud.speech import enums
ImportError: cannot import name 'enums' from 'google.cloud.speech' (/opt/homebrew/lib/python3.9/site-packages/google/cloud/speech/__init__.py)
Perhaps version incompatibility?
Was having the same issue. I fixed locally by changing it to speech_contexts
On line 979 of init.py: config['speech_contexts'] = [speech.SpeechContext(
Steps to reproduce
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,
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 ']