Skip to content

Adding Speech_Context to the Speech API stops Recogniztion #2036

Description

@LibertyBeta

It seems that the Speech Context config breaks the recognition stream.

Environment details

  • OS: *nix(Raspian, Ubuntu, etc)
  • Node.js version: 7.5
  • npm version:
  • google-cloud-node version: 0.6

Steps to reproduce

  1. require google-cloud
  2. Start Recognition Stream with a config values of
const request = {
  config: {
      encoding: encoding,
      sampleRate: sampleRate,
      speech_context: ['one', 'two]
  },
  interimResults: true
};
  1. .pipe() audio stream to the Recognition Stream

Activity

  1. added
    api: speechIssues related to the Speech-to-Text API.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: questionRequest for information or clarification. Not an issue.
    on Mar 1, 2017
  2. jmuk commented on Mar 2, 2017

    @jmuk
    Contributor

    Looks like your code specifying speech_context, but that should be speechContext?
    Did you know what happens on the recognition streams? Is there any errors reported?

  3. stephenplusplus commented on Mar 16, 2017

    @stephenplusplus
    Contributor

    @LibertyBeta I believe @jmuk caught the issue with speech_context vs speechContext, but please let us know if this is still an issue.

  4. arnoldad commented on Apr 13, 2017

    @arnoldad

    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)
    
  5. stephenplusplus commented on Apr 13, 2017

    @stephenplusplus
    Contributor

    We started using v1 of the Speech API (compared to v1beta1 previously), and it looks like it expects an array for speech_context now: https://github.com/googleapis/googleapis/blob/2b761d5190e3de4764fb58c312286ae043aec02d/google/cloud/speech/v1/cloud_speech.proto#L215

    That 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

  6. arnoldad commented on Apr 13, 2017

    @arnoldad

    Thanks 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

  7. added a commit that references this issue on Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: speechIssues related to the Speech-to-Text API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions