Skip to content
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

Adding Speech_Context to the Speech API stops Recogniztion #2036

Closed
LibertyBeta opened this issue Mar 1, 2017 · 5 comments
Closed

Adding Speech_Context to the Speech API stops Recogniztion #2036

LibertyBeta opened this issue Mar 1, 2017 · 5 comments
Assignees
Labels
api: speech Issues related to the Speech-to-Text API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@LibertyBeta
Copy link

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
@bjwatson bjwatson added api: speech Issues related to the Speech-to-Text API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue. labels Mar 1, 2017
@jmuk
Copy link
Contributor

jmuk commented Mar 2, 2017

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?

@stephenplusplus
Copy link
Contributor

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

@arnoldad
Copy link

arnoldad commented Apr 13, 2017

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)

@stephenplusplus
Copy link
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

@arnoldad
Copy link

arnoldad commented Apr 13, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: speech Issues related to the Speech-to-Text API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants