@@ -37,6 +37,9 @@ var DEFAULT_SERVICE_PORT = 443;
37
37
38
38
var CODE_GEN_NAME_VERSION = 'gapic/0.1.0' ;
39
39
40
+ var STREAM_DESCRIPTORS = {
41
+ streamingRecognize : new gax . StreamDescriptor ( gax . StreamType . BIDI_STREAMING )
42
+ } ;
40
43
41
44
/**
42
45
* The scopes needed to make gRPC calls to all of the methods defined in
@@ -80,8 +83,6 @@ function SpeechApi(gaxGrpc, grpcClients, opts) {
80
83
'google.cloud.speech.v1beta1.Speech' ,
81
84
configData ,
82
85
clientConfig ,
83
- null ,
84
- null ,
85
86
{ 'x-goog-api-client' : googleApiClient } ) ;
86
87
87
88
var speechStub = gaxGrpc . createStub (
@@ -91,14 +92,16 @@ function SpeechApi(gaxGrpc, grpcClients, opts) {
91
92
{ sslCreds : sslCreds } ) ;
92
93
var speechStubMethods = [
93
94
'syncRecognize' ,
94
- 'asyncRecognize'
95
+ 'asyncRecognize' ,
96
+ 'streamingRecognize'
95
97
] ;
96
98
speechStubMethods . forEach ( function ( methodName ) {
97
99
this [ '_' + methodName ] = gax . createApiCall (
98
100
speechStub . then ( function ( speechStub ) {
99
101
return speechStub [ methodName ] . bind ( speechStub ) ;
100
102
} ) ,
101
- defaults [ methodName ] ) ;
103
+ defaults [ methodName ] ,
104
+ STREAM_DESCRIPTORS [ methodName ] ) ;
102
105
} . bind ( this ) ) ;
103
106
}
104
107
@@ -208,6 +211,35 @@ SpeechApi.prototype.asyncRecognize = function(request, options, callback) {
208
211
return this . _asyncRecognize ( request , options , callback ) ;
209
212
} ;
210
213
214
+ /**
215
+ * Perform bidirectional streaming speech-recognition: receive results while
216
+ * sending audio. This method is only available via the gRPC API (not REST).
217
+ *
218
+ * @param {Object= } options
219
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
220
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
221
+ * @returns {Stream }
222
+ * An object stream which is both readable and writable. It accepts objects
223
+ * representing [StreamingRecognizeRequest]{@link StreamingRecognizeRequest} for write() method, and
224
+ * will emit objects representing [StreamingRecognizeResponse]{@link StreamingRecognizeResponse} on 'data' event asynchronously.
225
+ *
226
+ * @example
227
+ *
228
+ * var api = speechV1beta1.speechApi();
229
+ * var stream = api.streamingRecognize().on('data', function(response) {
230
+ * // doThingsWith(response);
231
+ * });
232
+ * var request = {};
233
+ * // Write request objects.
234
+ * stream.write(request);
235
+ */
236
+ SpeechApi . prototype . streamingRecognize = function ( options ) {
237
+ if ( options === undefined ) {
238
+ options = { } ;
239
+ }
240
+ return this . _streamingRecognize ( options ) ;
241
+ } ;
242
+
211
243
function SpeechApiBuilder ( gaxGrpc ) {
212
244
if ( ! ( this instanceof SpeechApiBuilder ) ) {
213
245
return new SpeechApiBuilder ( gaxGrpc ) ;
0 commit comments