Repository navigation
Adding Speech_Context to the Speech API stops Recogniztion #2036
Description
Activity
- addedapi: speechIssues related to the Speech-to-Text API.Issues related to the Speech-to-Text API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
on Mar 1, 2017 Looks like your code specifying
speech_context, but that should bespeechContext?
Did you know what happens on the recognition streams? Is there any errors reported?@LibertyBeta I believe @jmuk caught the issue with
speech_contextvsspeechContext, but please let us know if this is still an issue.Actually, this does not seem to be resolved (at least in version 0.9.0 from npm)-trying to supply the speech context any which way (see below request config) results in the following error for me:
Interestingly, passing the additional "profanityFilter" config param works fine.
const request = { config: { encoding: encoding, sampleRateHertz: sampleRateHertz, profanityFilter: true, // speechContext: {"phrases": ["dog", "cat"]}, //speech_context: {"phrases": ["dog", "cat"]}, //speechContext: ["dog", "cat"], //speech_context: ["dog", "cat"], languageCode: languageCode } };Error: .google.cloud.speech.v1.RecognitionConfig#speechContext is not a field: undefined at Error (native) at MessagePrototype.set (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2490:35) at MessagePrototype.set (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2483:38) at Message (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2411:34) at Element.ProtoBuf.Reflect.ElementPrototype.verifyValue (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:1925:28) at T.ProtoBuf.Reflect.FieldPrototype.verifyValue (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:3499:33) at MessagePrototype.set (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2493:59) at MessagePrototype.set (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2483:38) at Message (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:2411:34) at Element.ProtoBuf.Reflect.ElementPrototype.verifyValue (/Users/arnolda/GitHub/nodejs-docs-samples/speech/node_modules/protobufjs/dist/protobuf.js:1925:28)We started using v1 of the Speech API (compared to v1beta1 previously), and it looks like it expects an array for
speech_contextnow: https://github.com/googleapis/googleapis/blob/2b761d5190e3de4764fb58c312286ae043aec02d/google/cloud/speech/v1/cloud_speech.proto#L215That would mean:
const request = { config: { encoding: encoding, sampleRateHertz, sampleRateHertz, profanityFilter: true, speechContexts: [ { phrases: ["dog", "cat"] } ], languageCode: languageCode } }
Sorry for the trouble. I opened an issue to fix our links in the docs: #2219
Reacted by Adam Arnold, Théo Chamley, Bruno Quintana, Michel Nagano and Wladimir CokaThanks for the quick reply. I can confirm that the configuration you supplied works as expected with the @google-cloud/speech NPM module version 0.9.0
- added 2 commits that reference this issue
on Feb 25, 2026 - added a commit that references this issue
on Mar 11, 2026 - added a commit that references this issue
on Mar 17, 2026
It seems that the Speech Context config breaks the recognition stream.
Environment details
Steps to reproduce
google-cloud.pipe()audio stream to the Recognition Stream