-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Change speechContext to speechContexts. #3570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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)
|
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.
|
|
I signed it! |
|
CLAs look good, thanks! |
|
@p-siegel Thanks for the patch! We also need to adjust the tests to match (i.e., in |
|
It would be best if we could add / modify a system test which exercises the failing case, too. |
|
@tseaver We could just send commits to this PR to help it along? |
|
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 |
|
The speech system tests are failing on |
|
SGTM @tseaver |
|
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, |
|
Hi, |
|
@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. |
|
@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'],
) |
|
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"} |
|
@tseaver Here is what I used: Looks pretty much the same. The response is exactly the same as yours. |
|
I installed the PyPI version but changed _http.py to this one. |
|
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)