Uh oh!
There was an error while loading. Please reload this page.
Change speechContext to speechContexts. - #3570
Conversation
Append 's' to speechContext in order to work with the API. Stracktrace without: File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/sample.py", line 300, in recognize profanity_filter, speech_contexts) File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/_http.py", line 165, in recognize method='POST', path='speech:recognize', data=data) File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 303, in api_request error_info=method + ' ' + url) google.cloud.exceptions.BadRequest: 400 Invalid JSON payload received. Unknown name "speech_context" at 'config': Cannot find field. (POST https://speech.googleapis.com/v1/speech:recognize) Aborted (core dumped)
googlebot
commented
Jun 30, 2017
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
p-siegel
commented
Jun 30, 2017
I signed it! |
googlebot
commented
Jun 30, 2017
CLAs look good, thanks! |
tseaver
commented
Jun 30, 2017
@p-siegel Thanks for the patch! We also need to adjust the tests to match (i.e., in |
tseaver
commented
Jun 30, 2017
It would be best if we could add / modify a system test which exercises the failing case, too. |
dhermes
commented
Jun 30, 2017
@tseaver We could just send commits to this PR to help it along? |
googlebot
commented
Jun 30, 2017
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
tseaver
commented
Jun 30, 2017
The speech system tests are failing on |
dhermes
commented
Jun 30, 2017
SGTM @tseaver |
zoell
commented
Jul 3, 2017
Hello, I just tried these examples over the weekend here but it seems it works only when I specified one word: So if I add "shwazil" to speech_contexts, that works, but if I add ["shwazil", "hoful"], it just recognizes shwazil but leaves the hoful word untouched and it is not recognized properly. Is this example working for you? Thanks, |
p-siegel
commented
Jul 4, 2017
Hi, |
tseaver
commented
Jul 5, 2017
@zoell, are you running from a Git clone, or from the released version on PyPI. If the latter, this PRs changes have not yet been released. |
tseaver
commented
Jul 5, 2017
@p-siegel Can you provide a Python sample of how you pass in the multiple words? I'm assuming something like: sample=client.sample(
encoding=speech.Encoding.FLAC,
sample_rate_hertz=16000,
source_uri='gs://speech-demo/shwazil_hoful.flac',
)
results=sample.recognize(
language_code='en-US',
speech_contexts=['hoful', 'shwazil'],
)or else maybe: sample=client.sample(
encoding=speech.Encoding.FLAC,
sample_rate_hertz=16000,
source_uri='gs://speech-demo/shwazil_hoful.flac',
)
results=sample.recognize(
language_code='en-US',
speech_contexts=['shwazil hoful'],
) |
tseaver
commented
Jul 5, 2017
Here is what I get: >>>r1=sample.recognize(
... language_code='en-US',
... speech_contexts=['hoful', 'shwazil'],
... )
>>>r1[0].alternatives[0].__dict__
{'_confidence': 0.7818678021430969, '_transcript': u"it's a shwazil huffel day"}
>>>r2=sample.recognize(
... language_code='en-US',
... speech_contexts=['shwazil hoful'],
... )
>>>r2[0].alternatives[0].__dict__
{'_confidence': 0.7818678021430969, '_transcript': u"it's a shwazil huffel day"} |
p-siegel
commented
Jul 5, 2017
@tseaver Here is what I used: Looks pretty much the same. The response is exactly the same as yours. |
zoell
commented
Jul 5, 2017
I installed the PyPI version but changed _http.py to this one. |
tseaver
commented
Jul 5, 2017
This is an issue with the back-end API sample doc. I just tried the same request in the "Try It!" form for the {
"config": {
"encoding": "FLAC",
"sampleRateHertz": 16000,
"languageCode": "en-US",
"speechContexts": [
{
"phrases": [
"hoful",
"shwazil"
]
}
]
},
"audio": {
"uri": "gs://speech-demo/shwazil_hoful.flac"
}
}with the same result: {
"results": [
{
"alternatives": [
{
"transcript": "it's a shwazil huffel day",
"confidence": 0.7818678
}
]
}
]
} |
Append 's' to speechContext in order to work with the API. Stracktrace without:
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/sample.py", line 300, in recognize
profanity_filter, speech_contexts)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/_http.py", line 165, in recognize
method='POST', path='speech:recognize', data=data)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 303, in api_request
error_info=method + ' ' + url)
google.cloud.exceptions.BadRequest: 400 Invalid JSON payload received. Unknown name "speech_context" at 'config': Cannot find field. (POST https://speech.googleapis.com/v1/speech:recognize)
Aborted (core dumped)