From 2fb95f18d8ed13f0a9e0f4a4b368cd4ea9d52e27 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 13:49:30 -0700 Subject: [PATCH] feat: add output_config request field (#801) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add output_config request field Committer: @cherba PiperOrigin-RevId: 397621106 Source-Link: https://github.com/googleapis/googleapis/commit/1872f4583526cd30a6481726d78a31896a58dc80 Source-Link: https://github.com/googleapis/googleapis-gen/commit/fd4bb9f3fcc6b7bf498808c443eae9bf0d4447df Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZmQ0YmI5ZjNmY2M2YjdiZjQ5ODgwOGM0NDNlYWU5YmYwZDQ0NDdkZiJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../google/cloud/speech/v1/cloud_speech.proto | 13 + .../google-cloud-speech/protos/protos.d.ts | 99 ++++++++ packages/google-cloud-speech/protos/protos.js | 232 ++++++++++++++++++ .../google-cloud-speech/protos/protos.json | 22 ++ .../src/v1/speech_client.ts | 2 + 5 files changed, 368 insertions(+) diff --git a/packages/google-cloud-speech/protos/google/cloud/speech/v1/cloud_speech.proto b/packages/google-cloud-speech/protos/google/cloud/speech/v1/cloud_speech.proto index 495cb6e66c3..4651fc9e019 100644 --- a/packages/google-cloud-speech/protos/google/cloud/speech/v1/cloud_speech.proto +++ b/packages/google-cloud-speech/protos/google/cloud/speech/v1/cloud_speech.proto @@ -91,6 +91,19 @@ message LongRunningRecognizeRequest { // Required. The audio data to be recognized. RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Specifies an optional destination for the recognition results. + TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Specifies an optional destination for the recognition results. +message TranscriptOutputConfig { + oneof output_type { + // Specifies a Cloud Storage URI for the recognition results. Must be + // specified in the format: `gs://bucket_name/object_name`, and the bucket + // must already exist. + string gcs_uri = 1; + } } // The top-level message sent by the client for the `StreamingRecognize` method. diff --git a/packages/google-cloud-speech/protos/protos.d.ts b/packages/google-cloud-speech/protos/protos.d.ts index 83eb095b023..6612aee0ec3 100644 --- a/packages/google-cloud-speech/protos/protos.d.ts +++ b/packages/google-cloud-speech/protos/protos.d.ts @@ -217,6 +217,9 @@ export namespace google { /** LongRunningRecognizeRequest audio */ audio?: (google.cloud.speech.v1.IRecognitionAudio|null); + + /** LongRunningRecognizeRequest outputConfig */ + outputConfig?: (google.cloud.speech.v1.ITranscriptOutputConfig|null); } /** Represents a LongRunningRecognizeRequest. */ @@ -234,6 +237,9 @@ export namespace google { /** LongRunningRecognizeRequest audio. */ public audio?: (google.cloud.speech.v1.IRecognitionAudio|null); + /** LongRunningRecognizeRequest outputConfig. */ + public outputConfig?: (google.cloud.speech.v1.ITranscriptOutputConfig|null); + /** * Creates a new LongRunningRecognizeRequest instance using the specified properties. * @param [properties] Properties to set @@ -305,6 +311,99 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a TranscriptOutputConfig. */ + interface ITranscriptOutputConfig { + + /** TranscriptOutputConfig gcsUri */ + gcsUri?: (string|null); + } + + /** Represents a TranscriptOutputConfig. */ + class TranscriptOutputConfig implements ITranscriptOutputConfig { + + /** + * Constructs a new TranscriptOutputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.ITranscriptOutputConfig); + + /** TranscriptOutputConfig gcsUri. */ + public gcsUri?: (string|null); + + /** TranscriptOutputConfig outputType. */ + public outputType?: "gcsUri"; + + /** + * Creates a new TranscriptOutputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns TranscriptOutputConfig instance + */ + public static create(properties?: google.cloud.speech.v1.ITranscriptOutputConfig): google.cloud.speech.v1.TranscriptOutputConfig; + + /** + * Encodes the specified TranscriptOutputConfig message. Does not implicitly {@link google.cloud.speech.v1.TranscriptOutputConfig.verify|verify} messages. + * @param message TranscriptOutputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.ITranscriptOutputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TranscriptOutputConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v1.TranscriptOutputConfig.verify|verify} messages. + * @param message TranscriptOutputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.ITranscriptOutputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TranscriptOutputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TranscriptOutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1.TranscriptOutputConfig; + + /** + * Decodes a TranscriptOutputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TranscriptOutputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1.TranscriptOutputConfig; + + /** + * Verifies a TranscriptOutputConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TranscriptOutputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TranscriptOutputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.TranscriptOutputConfig; + + /** + * Creates a plain object from a TranscriptOutputConfig message. Also converts values to other types if specified. + * @param message TranscriptOutputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.TranscriptOutputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TranscriptOutputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a StreamingRecognizeRequest. */ interface IStreamingRecognizeRequest { diff --git a/packages/google-cloud-speech/protos/protos.js b/packages/google-cloud-speech/protos/protos.js index def17aef72e..1d20fedf4fb 100644 --- a/packages/google-cloud-speech/protos/protos.js +++ b/packages/google-cloud-speech/protos/protos.js @@ -428,6 +428,7 @@ * @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 */ /** @@ -461,6 +462,14 @@ */ 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 @@ -489,6 +498,8 @@ $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; }; @@ -529,6 +540,9 @@ 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; @@ -574,6 +588,11 @@ 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; }; @@ -599,6 +618,11 @@ 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; }; @@ -618,11 +642,14 @@ 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; }; @@ -640,6 +667,211 @@ 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) { + 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(); + switch (tag >>> 3) { + case 1: + message.gcsUri = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TranscriptOutputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.TranscriptOutputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @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.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TranscriptOutputConfig message. + * @function verify + * @memberof google.cloud.speech.v1.TranscriptOutputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TranscriptOutputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsUri != null && message.hasOwnProperty("gcsUri")) { + properties.outputType = 1; + if (!$util.isString(message.gcsUri)) + return "gcsUri: string expected"; + } + return null; + }; + + /** + * Creates a TranscriptOutputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.TranscriptOutputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.TranscriptOutputConfig} TranscriptOutputConfig + */ + TranscriptOutputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.TranscriptOutputConfig) + return object; + var message = new $root.google.cloud.speech.v1.TranscriptOutputConfig(); + if (object.gcsUri != null) + message.gcsUri = String(object.gcsUri); + return message; + }; + + /** + * Creates a plain object from a TranscriptOutputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.TranscriptOutputConfig + * @static + * @param {google.cloud.speech.v1.TranscriptOutputConfig} message TranscriptOutputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TranscriptOutputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsUri != null && message.hasOwnProperty("gcsUri")) { + object.gcsUri = message.gcsUri; + if (options.oneofs) + object.outputType = "gcsUri"; + } + return object; + }; + + /** + * Converts this TranscriptOutputConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.TranscriptOutputConfig + * @instance + * @returns {Object.} JSON object + */ + TranscriptOutputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return TranscriptOutputConfig; + })(); + v1.StreamingRecognizeRequest = (function() { /** diff --git a/packages/google-cloud-speech/protos/protos.json b/packages/google-cloud-speech/protos/protos.json index 62664dec4f3..00257215807 100644 --- a/packages/google-cloud-speech/protos/protos.json +++ b/packages/google-cloud-speech/protos/protos.json @@ -111,6 +111,28 @@ "options": { "(google.api.field_behavior)": "REQUIRED" } + }, + "outputConfig": { + "type": "TranscriptOutputConfig", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "TranscriptOutputConfig": { + "oneofs": { + "outputType": { + "oneof": [ + "gcsUri" + ] + } + }, + "fields": { + "gcsUri": { + "type": "string", + "id": 1 } } }, diff --git a/packages/google-cloud-speech/src/v1/speech_client.ts b/packages/google-cloud-speech/src/v1/speech_client.ts index bda54e32842..1bcdaca5336 100644 --- a/packages/google-cloud-speech/src/v1/speech_client.ts +++ b/packages/google-cloud-speech/src/v1/speech_client.ts @@ -488,6 +488,8 @@ export class SpeechClient { * process the request. * @param {google.cloud.speech.v1.RecognitionAudio} request.audio * Required. The audio data to be recognized. + * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig] + * Optional. Specifies an optional destination for the recognition results. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array.