UNPKG

@google-cloud/speech

Version:
822 lines (751 loc) 4.37 MB
// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ (function(global, factory) { /* global define, require, module */ /* AMD */ if (typeof define === 'function' && define.amd) define(["protobufjs/minimal"], factory); /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal); })(this, function($protobuf) { "use strict"; // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots._google_cloud_speech_protos || ($protobuf.roots._google_cloud_speech_protos = {}); $root.google = (function() { /** * Namespace google. * @exports google * @namespace */ var google = {}; google.cloud = (function() { /** * Namespace cloud. * @memberof google * @namespace */ var cloud = {}; cloud.speech = (function() { /** * Namespace speech. * @memberof google.cloud * @namespace */ var speech = {}; speech.v1 = (function() { /** * Namespace v1. * @memberof google.cloud.speech * @namespace */ var v1 = {}; v1.Speech = (function() { /** * Constructs a new Speech service. * @memberof google.cloud.speech.v1 * @classdesc Represents a Speech * @extends $protobuf.rpc.Service * @constructor * @param {$protobuf.RPCImpl} rpcImpl RPC implementation * @param {boolean} [requestDelimited=false] Whether requests are length-delimited * @param {boolean} [responseDelimited=false] Whether responses are length-delimited */ function Speech(rpcImpl, requestDelimited, responseDelimited) { $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); } (Speech.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Speech; /** * Creates new Speech service using the specified rpc implementation. * @function create * @memberof google.cloud.speech.v1.Speech * @static * @param {$protobuf.RPCImpl} rpcImpl RPC implementation * @param {boolean} [requestDelimited=false] Whether requests are length-delimited * @param {boolean} [responseDelimited=false] Whether responses are length-delimited * @returns {Speech} RPC service. Useful where requests and/or responses are streamed. */ Speech.create = function create(rpcImpl, requestDelimited, responseDelimited) { return new this(rpcImpl, requestDelimited, responseDelimited); }; /** * Callback as used by {@link google.cloud.speech.v1.Speech|recognize}. * @memberof google.cloud.speech.v1.Speech * @typedef RecognizeCallback * @type {function} * @param {Error|null} error Error, if any * @param {google.cloud.speech.v1.RecognizeResponse} [response] RecognizeResponse */ /** * Calls Recognize. * @function recognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.IRecognizeRequest} request RecognizeRequest message or plain object * @param {google.cloud.speech.v1.Speech.RecognizeCallback} callback Node-style callback called with the error, if any, and RecognizeResponse * @returns {undefined} * @variation 1 */ Object.defineProperty(Speech.prototype.recognize = function recognize(request, callback) { return this.rpcCall(recognize, $root.google.cloud.speech.v1.RecognizeRequest, $root.google.cloud.speech.v1.RecognizeResponse, request, callback); }, "name", { value: "Recognize" }); /** * Calls Recognize. * @function recognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.IRecognizeRequest} request RecognizeRequest message or plain object * @returns {Promise<google.cloud.speech.v1.RecognizeResponse>} Promise * @variation 2 */ /** * Callback as used by {@link google.cloud.speech.v1.Speech|longRunningRecognize}. * @memberof google.cloud.speech.v1.Speech * @typedef LongRunningRecognizeCallback * @type {function} * @param {Error|null} error Error, if any * @param {google.longrunning.Operation} [response] Operation */ /** * Calls LongRunningRecognize. * @function longRunningRecognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest} request LongRunningRecognizeRequest message or plain object * @param {google.cloud.speech.v1.Speech.LongRunningRecognizeCallback} callback Node-style callback called with the error, if any, and Operation * @returns {undefined} * @variation 1 */ Object.defineProperty(Speech.prototype.longRunningRecognize = function longRunningRecognize(request, callback) { return this.rpcCall(longRunningRecognize, $root.google.cloud.speech.v1.LongRunningRecognizeRequest, $root.google.longrunning.Operation, request, callback); }, "name", { value: "LongRunningRecognize" }); /** * Calls LongRunningRecognize. * @function longRunningRecognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest} request LongRunningRecognizeRequest message or plain object * @returns {Promise<google.longrunning.Operation>} Promise * @variation 2 */ /** * Callback as used by {@link google.cloud.speech.v1.Speech|streamingRecognize}. * @memberof google.cloud.speech.v1.Speech * @typedef StreamingRecognizeCallback * @type {function} * @param {Error|null} error Error, if any * @param {google.cloud.speech.v1.StreamingRecognizeResponse} [response] StreamingRecognizeResponse */ /** * Calls StreamingRecognize. * @function streamingRecognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.IStreamingRecognizeRequest} request StreamingRecognizeRequest message or plain object * @param {google.cloud.speech.v1.Speech.StreamingRecognizeCallback} callback Node-style callback called with the error, if any, and StreamingRecognizeResponse * @returns {undefined} * @variation 1 */ Object.defineProperty(Speech.prototype.streamingRecognize = function streamingRecognize(request, callback) { return this.rpcCall(streamingRecognize, $root.google.cloud.speech.v1.StreamingRecognizeRequest, $root.google.cloud.speech.v1.StreamingRecognizeResponse, request, callback); }, "name", { value: "StreamingRecognize" }); /** * Calls StreamingRecognize. * @function streamingRecognize * @memberof google.cloud.speech.v1.Speech * @instance * @param {google.cloud.speech.v1.IStreamingRecognizeRequest} request StreamingRecognizeRequest message or plain object * @returns {Promise<google.cloud.speech.v1.StreamingRecognizeResponse>} Promise * @variation 2 */ return Speech; })(); v1.RecognizeRequest = (function() { /** * Properties of a RecognizeRequest. * @memberof google.cloud.speech.v1 * @interface IRecognizeRequest * @property {google.cloud.speech.v1.IRecognitionConfig|null} [config] RecognizeRequest config * @property {google.cloud.speech.v1.IRecognitionAudio|null} [audio] RecognizeRequest audio */ /** * Constructs a new RecognizeRequest. * @memberof google.cloud.speech.v1 * @classdesc Represents a RecognizeRequest. * @implements IRecognizeRequest * @constructor * @param {google.cloud.speech.v1.IRecognizeRequest=} [properties] Properties to set */ function RecognizeRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * RecognizeRequest config. * @member {google.cloud.speech.v1.IRecognitionConfig|null|undefined} config * @memberof google.cloud.speech.v1.RecognizeRequest * @instance */ RecognizeRequest.prototype.config = null; /** * RecognizeRequest audio. * @member {google.cloud.speech.v1.IRecognitionAudio|null|undefined} audio * @memberof google.cloud.speech.v1.RecognizeRequest * @instance */ RecognizeRequest.prototype.audio = null; /** * Creates a new RecognizeRequest instance using the specified properties. * @function create * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {google.cloud.speech.v1.IRecognizeRequest=} [properties] Properties to set * @returns {google.cloud.speech.v1.RecognizeRequest} RecognizeRequest instance */ RecognizeRequest.create = function create(properties) { return new RecognizeRequest(properties); }; /** * Encodes the specified RecognizeRequest message. Does not implicitly {@link google.cloud.speech.v1.RecognizeRequest.verify|verify} messages. * @function encode * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {google.cloud.speech.v1.IRecognizeRequest} message RecognizeRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ RecognizeRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.config != null && Object.hasOwnProperty.call(message, "config")) $root.google.cloud.speech.v1.RecognitionConfig.encode(message.config, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.audio != null && Object.hasOwnProperty.call(message, "audio")) $root.google.cloud.speech.v1.RecognitionAudio.encode(message.audio, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; /** * Encodes the specified RecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1.RecognizeRequest.verify|verify} messages. * @function encodeDelimited * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {google.cloud.speech.v1.IRecognizeRequest} message RecognizeRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ RecognizeRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a RecognizeRequest message from the specified reader or buffer. * @function decode * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.cloud.speech.v1.RecognizeRequest} RecognizeRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ RecognizeRequest.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1.RecognizeRequest(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.config = $root.google.cloud.speech.v1.RecognitionConfig.decode(reader, reader.uint32()); break; } case 2: { message.audio = $root.google.cloud.speech.v1.RecognitionAudio.decode(reader, reader.uint32()); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a RecognizeRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.cloud.speech.v1.RecognizeRequest} RecognizeRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ RecognizeRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a RecognizeRequest message. * @function verify * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ RecognizeRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.config != null && message.hasOwnProperty("config")) { var error = $root.google.cloud.speech.v1.RecognitionConfig.verify(message.config); if (error) return "config." + error; } if (message.audio != null && message.hasOwnProperty("audio")) { var error = $root.google.cloud.speech.v1.RecognitionAudio.verify(message.audio); if (error) return "audio." + error; } return null; }; /** * Creates a RecognizeRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {Object.<string,*>} object Plain object * @returns {google.cloud.speech.v1.RecognizeRequest} RecognizeRequest */ RecognizeRequest.fromObject = function fromObject(object) { if (object instanceof $root.google.cloud.speech.v1.RecognizeRequest) return object; var message = new $root.google.cloud.speech.v1.RecognizeRequest(); if (object.config != null) { if (typeof object.config !== "object") throw TypeError(".google.cloud.speech.v1.RecognizeRequest.config: object expected"); message.config = $root.google.cloud.speech.v1.RecognitionConfig.fromObject(object.config); } if (object.audio != null) { if (typeof object.audio !== "object") throw TypeError(".google.cloud.speech.v1.RecognizeRequest.audio: object expected"); message.audio = $root.google.cloud.speech.v1.RecognitionAudio.fromObject(object.audio); } return message; }; /** * Creates a plain object from a RecognizeRequest message. Also converts values to other types if specified. * @function toObject * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {google.cloud.speech.v1.RecognizeRequest} message RecognizeRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ RecognizeRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.config = null; object.audio = null; } if (message.config != null && message.hasOwnProperty("config")) object.config = $root.google.cloud.speech.v1.RecognitionConfig.toObject(message.config, options); if (message.audio != null && message.hasOwnProperty("audio")) object.audio = $root.google.cloud.speech.v1.RecognitionAudio.toObject(message.audio, options); return object; }; /** * Converts this RecognizeRequest to JSON. * @function toJSON * @memberof google.cloud.speech.v1.RecognizeRequest * @instance * @returns {Object.<string,*>} JSON object */ RecognizeRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for RecognizeRequest * @function getTypeUrl * @memberof google.cloud.speech.v1.RecognizeRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ RecognizeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/google.cloud.speech.v1.RecognizeRequest"; }; return RecognizeRequest; })(); v1.LongRunningRecognizeRequest = (function() { /** * Properties of a LongRunningRecognizeRequest. * @memberof google.cloud.speech.v1 * @interface ILongRunningRecognizeRequest * @property {google.cloud.speech.v1.IRecognitionConfig|null} [config] LongRunningRecognizeRequest config * @property {google.cloud.speech.v1.IRecognitionAudio|null} [audio] LongRunningRecognizeRequest audio * @property {google.cloud.speech.v1.ITranscriptOutputConfig|null} [outputConfig] LongRunningRecognizeRequest outputConfig */ /** * Constructs a new LongRunningRecognizeRequest. * @memberof google.cloud.speech.v1 * @classdesc Represents a LongRunningRecognizeRequest. * @implements ILongRunningRecognizeRequest * @constructor * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest=} [properties] Properties to set */ function LongRunningRecognizeRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * LongRunningRecognizeRequest config. * @member {google.cloud.speech.v1.IRecognitionConfig|null|undefined} config * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @instance */ LongRunningRecognizeRequest.prototype.config = null; /** * LongRunningRecognizeRequest audio. * @member {google.cloud.speech.v1.IRecognitionAudio|null|undefined} audio * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @instance */ LongRunningRecognizeRequest.prototype.audio = null; /** * LongRunningRecognizeRequest outputConfig. * @member {google.cloud.speech.v1.ITranscriptOutputConfig|null|undefined} outputConfig * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @instance */ LongRunningRecognizeRequest.prototype.outputConfig = null; /** * Creates a new LongRunningRecognizeRequest instance using the specified properties. * @function create * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest=} [properties] Properties to set * @returns {google.cloud.speech.v1.LongRunningRecognizeRequest} LongRunningRecognizeRequest instance */ LongRunningRecognizeRequest.create = function create(properties) { return new LongRunningRecognizeRequest(properties); }; /** * Encodes the specified LongRunningRecognizeRequest message. Does not implicitly {@link google.cloud.speech.v1.LongRunningRecognizeRequest.verify|verify} messages. * @function encode * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest} message LongRunningRecognizeRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ LongRunningRecognizeRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.config != null && Object.hasOwnProperty.call(message, "config")) $root.google.cloud.speech.v1.RecognitionConfig.encode(message.config, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.audio != null && Object.hasOwnProperty.call(message, "audio")) $root.google.cloud.speech.v1.RecognitionAudio.encode(message.audio, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.outputConfig != null && Object.hasOwnProperty.call(message, "outputConfig")) $root.google.cloud.speech.v1.TranscriptOutputConfig.encode(message.outputConfig, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** * Encodes the specified LongRunningRecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1.LongRunningRecognizeRequest.verify|verify} messages. * @function encodeDelimited * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {google.cloud.speech.v1.ILongRunningRecognizeRequest} message LongRunningRecognizeRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ LongRunningRecognizeRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a LongRunningRecognizeRequest message from the specified reader or buffer. * @function decode * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.cloud.speech.v1.LongRunningRecognizeRequest} LongRunningRecognizeRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ LongRunningRecognizeRequest.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1.LongRunningRecognizeRequest(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.config = $root.google.cloud.speech.v1.RecognitionConfig.decode(reader, reader.uint32()); break; } case 2: { message.audio = $root.google.cloud.speech.v1.RecognitionAudio.decode(reader, reader.uint32()); break; } case 4: { message.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.decode(reader, reader.uint32()); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a LongRunningRecognizeRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.cloud.speech.v1.LongRunningRecognizeRequest} LongRunningRecognizeRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ LongRunningRecognizeRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a LongRunningRecognizeRequest message. * @function verify * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ LongRunningRecognizeRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.config != null && message.hasOwnProperty("config")) { var error = $root.google.cloud.speech.v1.RecognitionConfig.verify(message.config); if (error) return "config." + error; } if (message.audio != null && message.hasOwnProperty("audio")) { var error = $root.google.cloud.speech.v1.RecognitionAudio.verify(message.audio); if (error) return "audio." + error; } if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) { var error = $root.google.cloud.speech.v1.TranscriptOutputConfig.verify(message.outputConfig); if (error) return "outputConfig." + error; } return null; }; /** * Creates a LongRunningRecognizeRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {Object.<string,*>} object Plain object * @returns {google.cloud.speech.v1.LongRunningRecognizeRequest} LongRunningRecognizeRequest */ LongRunningRecognizeRequest.fromObject = function fromObject(object) { if (object instanceof $root.google.cloud.speech.v1.LongRunningRecognizeRequest) return object; var message = new $root.google.cloud.speech.v1.LongRunningRecognizeRequest(); if (object.config != null) { if (typeof object.config !== "object") throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeRequest.config: object expected"); message.config = $root.google.cloud.speech.v1.RecognitionConfig.fromObject(object.config); } if (object.audio != null) { if (typeof object.audio !== "object") throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeRequest.audio: object expected"); message.audio = $root.google.cloud.speech.v1.RecognitionAudio.fromObject(object.audio); } if (object.outputConfig != null) { if (typeof object.outputConfig !== "object") throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeRequest.outputConfig: object expected"); message.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.fromObject(object.outputConfig); } return message; }; /** * Creates a plain object from a LongRunningRecognizeRequest message. Also converts values to other types if specified. * @function toObject * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {google.cloud.speech.v1.LongRunningRecognizeRequest} message LongRunningRecognizeRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ LongRunningRecognizeRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.config = null; object.audio = null; object.outputConfig = null; } if (message.config != null && message.hasOwnProperty("config")) object.config = $root.google.cloud.speech.v1.RecognitionConfig.toObject(message.config, options); if (message.audio != null && message.hasOwnProperty("audio")) object.audio = $root.google.cloud.speech.v1.RecognitionAudio.toObject(message.audio, options); if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) object.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.toObject(message.outputConfig, options); return object; }; /** * Converts this LongRunningRecognizeRequest to JSON. * @function toJSON * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @instance * @returns {Object.<string,*>} JSON object */ LongRunningRecognizeRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for LongRunningRecognizeRequest * @function getTypeUrl * @memberof google.cloud.speech.v1.LongRunningRecognizeRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ LongRunningRecognizeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/google.cloud.speech.v1.LongRunningRecognizeRequest"; }; return LongRunningRecognizeRequest; })(); v1.TranscriptOutputConfig = (function() { /** * Properties of a TranscriptOutputConfig. * @memberof google.cloud.speech.v1 * @interface ITranscriptOutputConfig * @property {string|null} [gcsUri] TranscriptOutputConfig gcsUri */ /** * Constructs a new TranscriptOutputConfig. * @memberof google.cloud.speech.v1 * @classdesc Represents a TranscriptOutputConfig. * @implements ITranscriptOutputConfig * @constructor * @param {google.cloud.speech.v1.ITranscriptOutputConfig=} [properties] Properties to set */ function TranscriptOutputConfig(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * TranscriptOutputConfig gcsUri. * @member {string|null|undefined} gcsUri * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @instance */ TranscriptOutputConfig.prototype.gcsUri = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; /** * TranscriptOutputConfig outputType. * @member {"gcsUri"|undefined} outputType * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @instance */ Object.defineProperty(TranscriptOutputConfig.prototype, "outputType", { get: $util.oneOfGetter($oneOfFields = ["gcsUri"]), set: $util.oneOfSetter($oneOfFields) }); /** * Creates a new TranscriptOutputConfig instance using the specified properties. * @function create * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @static * @param {google.cloud.speech.v1.ITranscriptOutputConfig=} [properties] Properties to set * @returns {google.cloud.speech.v1.TranscriptOutputConfig} TranscriptOutputConfig instance */ TranscriptOutputConfig.create = function create(properties) { return new TranscriptOutputConfig(properties); }; /** * Encodes the specified TranscriptOutputConfig message. Does not implicitly {@link google.cloud.speech.v1.TranscriptOutputConfig.verify|verify} messages. * @function encode * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @static * @param {google.cloud.speech.v1.ITranscriptOutputConfig} message TranscriptOutputConfig message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ TranscriptOutputConfig.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.gcsUri != null && Object.hasOwnProperty.call(message, "gcsUri")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsUri); return writer; }; /** * Encodes the specified TranscriptOutputConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v1.TranscriptOutputConfig.verify|verify} messages. * @function encodeDelimited * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @static * @param {google.cloud.speech.v1.ITranscriptOutputConfig} message TranscriptOutputConfig message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ TranscriptOutputConfig.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a TranscriptOutputConfig message from the specified reader or buffer. * @function decode * @memberof google.cloud.speech.v1.TranscriptOutputConfig * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.cloud.speech.v1.TranscriptOutputConfig} TranscriptOutputConfig * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ TranscriptOutputConfig.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1.TranscriptOutputConfig(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.gcsUri = reader.string(); break; } default: reader.skipType(tag &