Socket
Socket
Sign inDemoInstall

@google-cloud/speech

Package Overview
Dependencies
255
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

7

package.json
{
"name": "@google-cloud/speech",
"version": "0.2.0",
"version": "0.3.0",
"author": "Google Inc.",

@@ -57,7 +57,6 @@ "description": "Google Cloud Speech Client Library for Node.js",

"dependencies": {
"@google-cloud/common": "^0.6.0",
"arguejs": "^0.2.3",
"@google-cloud/common": "^0.7.0",
"events-intercept": "^2.0.0",
"extend": "^3.0.0",
"google-gax": "^0.6.0",
"google-gax": "^0.7.0",
"google-proto-files": "^0.8.0",

@@ -64,0 +63,0 @@ "is": "^3.1.0",

@@ -61,2 +61,15 @@ # @google-cloud/speech

});
// Promises are also supported by omitting callbacks.
speech.recognize('./audio.raw', {
encoding: 'LINEAR16',
sampleRate: 16000
}).then(function(data) {
var transcript = data[0];
});
// It's also possible to integrate with third-party Promise libraries.
var speech = require('@google-cloud/speech')({
promise: require('bluebird')
});
```

@@ -63,0 +76,0 @@

@@ -37,2 +37,3 @@ /*!

var util = require('util');
var v1beta1 = require('./v1beta1');

@@ -69,2 +70,6 @@ /**

this.api = {
Speech: v1beta1(options).speechApi(options)
};
var config = {

@@ -632,2 +637,10 @@ baseUrl: 'speech.googleapis.com',

* });
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* speech.recognize('./bridge.raw', config).then(function(data) {
* var results = data[0];
* var apiResponse = data[1];
* });
*/

@@ -637,7 +650,2 @@ Speech.prototype.recognize = function(file, config, callback) {

var protoOpts = {
service: 'Speech',
method: 'syncRecognize'
};
config = extend({}, config);

@@ -658,17 +666,12 @@

var reqOpts = {
audio: foundFile,
config: config
};
self.request(protoOpts, reqOpts, function(err, apiResponse) {
self.api.Speech.syncRecognize(config, foundFile, function(err, resp) {
if (err) {
callback(err, null, apiResponse);
callback(err, null, resp);
return;
}
var response = new self.protos.Speech.SyncRecognizeResponse(apiResponse);
var response = new self.protos.Speech.SyncRecognizeResponse(resp);
var results = Speech.formatResults_(response.results, verboseMode);
callback(null, results, apiResponse);
callback(null, results, resp);
});

@@ -777,2 +780,10 @@ });

* });
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* speech.startRecognition('./bridge.raw', config).then(function(data) {
* var operation = data[0];
* var apiResponse = data[1];
* });
*/

@@ -782,7 +793,2 @@ Speech.prototype.startRecognition = function(file, config, callback) {

var protoOpts = {
service: 'Speech',
method: 'asyncRecognize'
};
config = extend({}, config);

@@ -803,15 +809,10 @@

var reqOpts = {
audio: foundFile,
config: config
};
self.request(protoOpts, reqOpts, function(err, apiResponse) {
self.api.Speech.asyncRecognize(config, foundFile, function(err, resp) {
if (err) {
callback(err, null, apiResponse);
callback(err, null, resp);
return;
}
var operation = self.operation(apiResponse.name);
operation.metadata = apiResponse;
var operation = self.operation(resp.name);
operation.metadata = resp;

@@ -832,3 +833,3 @@ // Intercept the "complete" event to decode and format the results of the

callback(null, operation, apiResponse);
callback(null, operation, resp);
});

@@ -838,3 +839,12 @@ });

/*! Developer Documentation
*
* All async methods (except for streams) will return a Promise in the event
* that a callback is omitted.
*/
common.util.promisifyAll(Speech, {
exclude: ['operation']
});
module.exports = Speech;
module.exports.v1beta1 = require('./v1beta1');
module.exports.v1beta1 = v1beta1;

@@ -30,3 +30,2 @@ /*

var arguejs = require('arguejs');
var configData = require('./speech_client_config');

@@ -42,3 +41,2 @@ var extend = require('extend');

var DEFAULT_TIMEOUT = 30;

@@ -74,3 +72,2 @@ /**

var clientConfig = opts.clientConfig || {};
var timeout = opts.timeout || DEFAULT_TIMEOUT;
var appName = opts.appName || 'gax';

@@ -89,3 +86,2 @@ var appVersion = opts.appVersion || gax.version;

clientConfig,
timeout,
null,

@@ -128,5 +124,5 @@ null,

* This object should have the same structure as [RecognitionAudio]{@link RecognitionAudio}
* @param {gax.CallOptions=} options
* Overrides the default settings for this call, e.g, timeout,
* retries, etc.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call, e.g, timeout,
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
* @param {function(?Error, ?Object)=} callback

@@ -152,14 +148,19 @@ * The function which will be called with the result of the API call.

*/
SpeechApi.prototype.syncRecognize = function syncRecognize() {
var args = arguejs({
config: Object,
audio: Object,
options: [gax.CallOptions],
callback: [Function]
}, arguments);
SpeechApi.prototype.syncRecognize = function syncRecognize(
config,
audio,
options,
callback) {
if (options instanceof Function && callback === undefined) {
callback = options;
options = {};
}
if (options === undefined) {
options = {};
}
var req = {
config: args.config,
audio: args.audio
config: config,
audio: audio
};
return this._syncRecognize(req, args.options, args.callback);
return this._syncRecognize(req, options, callback);
};

@@ -169,4 +170,5 @@

* Perform asynchronous speech-recognition: receive results via the
* google.longrunning.Operations interface. `Operation.response` returns
* `AsyncRecognizeResponse`.
* google.longrunning.Operations interface. Returns either an
* `Operation.error` or an `Operation.response` which contains
* an `AsyncRecognizeResponse` message.
*

@@ -182,5 +184,5 @@ * @param {Object} config

* This object should have the same structure as [RecognitionAudio]{@link RecognitionAudio}
* @param {gax.CallOptions=} options
* Overrides the default settings for this call, e.g, timeout,
* retries, etc.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call, e.g, timeout,
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
* @param {function(?Error, ?Object)=} callback

@@ -206,14 +208,19 @@ * The function which will be called with the result of the API call.

*/
SpeechApi.prototype.asyncRecognize = function asyncRecognize() {
var args = arguejs({
config: Object,
audio: Object,
options: [gax.CallOptions],
callback: [Function]
}, arguments);
SpeechApi.prototype.asyncRecognize = function asyncRecognize(
config,
audio,
options,
callback) {
if (options instanceof Function && callback === undefined) {
callback = options;
options = {};
}
if (options === undefined) {
options = {};
}
var req = {
config: args.config,
audio: args.audio
config: config,
audio: audio
};
return this._asyncRecognize(req, args.options, args.callback);
return this._asyncRecognize(req, options, callback);
};

@@ -249,4 +256,2 @@

* {@link gax.constructSettings} for the format.
* @param {number=} opts.timeout
* The default timeout, in seconds, for calls made through this client.
* @param {number=} opts.appName

@@ -253,0 +258,0 @@ * The codename of the calling service.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc