Skip to content

Regenerate speech API. Now it contains streamingRecognize method. #1775

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

Merged
merged 4 commits into from
Nov 14, 2016

Conversation

jmuk
Copy link
Contributor

@jmuk jmuk commented Nov 8, 2016

This does not change src/index.js yet.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 8, 2016
@stephenplusplus stephenplusplus added the api: speech Issues related to the Speech-to-Text API. label Nov 8, 2016
@stephenplusplus
Copy link
Contributor

I've tried to integrate this with src/index, and it seems to work, except for the response event. Does gax expose a way to get the API's raw response? Currently:

speech.createRecognizeStream({...})
  .on('response', function(response) {
    response === {
      "code": 200,
      "details": "",
      "metadata": {
        "_internal_repr": {
          "content-disposition": [
            "attachment"
          ]
        }
      },
      "message": "OK"
    }
  })
  .on('data', function() {...})

@stephenplusplus
Copy link
Contributor

@jmuk to clarify, this response is from the grpc stream event named metadata: https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355

We rename it to response as its more common for users familiar with the tradition HTTP request/response workflow, with the response event being standard with the Node.js native HTTP module: https://nodejs.org/api/http.html#http_event_response

@jmuk
Copy link
Contributor Author

jmuk commented Nov 8, 2016

I see. It seems gax loses metadata and status event which gRPC supplies. Filed as googleapis/gax-nodejs#67 and I'm on it.

@jmuk
Copy link
Contributor Author

jmuk commented Nov 8, 2016

Could it be status instead of metadata which we want for response?

@stephenplusplus
Copy link
Contributor

Maybe, what is the difference between the status and response objects?

@jmuk
Copy link
Contributor Author

jmuk commented Nov 8, 2016

metadata only contains the part of {metadata: {_internal_repr: { ... }}} while status provides what you wrote -- including code or something. And it seems status comes at the end of the stream while metadata comes earlier.

@stephenplusplus
Copy link
Contributor

@callmehiphop wdyt? I think you were more closely connected with our implementation.

@callmehiphop
Copy link
Contributor

callmehiphop commented Nov 8, 2016

I think something to note is that status and metadata occur at different times. Where metadata happens once the request starts, status doesn't happen until after all results have been processed.

For that reason alone, I think in the veneer layer we typically listen for metadata.

@jmuk
Copy link
Contributor Author

jmuk commented Nov 9, 2016

Ah, okay. So https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355 does take 'metadata' event, and create the response object with "code: 0" (i.e. succeeds). I'll do the same thing.

@jmuk
Copy link
Contributor Author

jmuk commented Nov 9, 2016

Now it's added.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Nov 9, 2016
@stephenplusplus
Copy link
Contributor

I added a commit to use the new streaming method from our API.

@callmehiphop could you take a look and push a commit that gets rid of anything we don't need, re: GrpcService?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0c79f2b on jmuk:speech into 116436f on GoogleCloudPlatform:master.

@stephenplusplus stephenplusplus added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Nov 9, 2016
@callmehiphop
Copy link
Contributor

@stephenplusplus I don't think you can cut out GrpcService unless GAX also supports LRO.

@stephenplusplus
Copy link
Contributor

Okay, thanks for taking a look.

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. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants