// AsyncRecognize perform asynchronous speech-recognition: receive results via the // google.longrunning.Operations interface. Returns either an // `Operation.error` or an `Operation.response` which contains // an `AsyncRecognizeResponse` message. func (c *Client) AsyncRecognize(ctx context.Context, req *speechpb.AsyncRecognizeRequest) (*AsyncRecognizeResponseOperation, error) { md, _ := metadata.FromContext(ctx) ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata)) var resp *longrunningpb.Operation err := gax.Invoke(ctx, func(ctx context.Context) error { var err error resp, err = c.client.AsyncRecognize(ctx, req) return err }, c.CallOptions.AsyncRecognize...) if err != nil { return nil, err } return &AsyncRecognizeResponseOperation{ lro: longrunning.InternalNewOperation(c.Connection(), resp), }, nil }
// AsyncRecognizeResponseOperation returns a new AsyncRecognizeResponseOperation from a given name. // The name must be that of a previously created AsyncRecognizeResponseOperation, possibly from a different process. func (c *Client) AsyncRecognizeResponseOperation(name string) *AsyncRecognizeResponseOperation { return &AsyncRecognizeResponseOperation{ lro: longrunning.InternalNewOperation(c.Connection(), &longrunningpb.Operation{Name: name}), } }