From 08ed5b51bda6f158d6c5709a6ca3393aa0c61c3d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 19 Aug 2021 11:18:29 -0700 Subject: [PATCH] feat: Add transcript normalization (#792) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add transcript normalization Committer: @jameszhao PiperOrigin-RevId: 391603958 Source-Link: https://github.com/googleapis/googleapis/commit/76bed90afcd459c0345b1bd0ab3e5cd53260e04d Source-Link: https://github.com/googleapis/googleapis-gen/commit/c7aaaa72a271bfc79f7631cd91bf4a944ffb202f * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../cloud/speech/v1p1beta1/cloud_speech.proto | 6 + .../cloud/speech/v1p1beta1/resource.proto | 25 + protos/protos.d.ts | 201 ++++++++ protos/protos.js | 467 ++++++++++++++++++ protos/protos.json | 31 ++ 5 files changed, 730 insertions(+) diff --git a/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto b/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto index 5a861542..edf60352 100644 --- a/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto +++ b/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto @@ -327,6 +327,12 @@ message RecognitionConfig { // documentation. SpeechAdaptation adaptation = 20; + // Use transcription normalization to automatically replace parts of the + // transcript with phrases of your choosing. For StreamingRecognize, this + // normalization only applies to stable partial transcripts (stability > 0.8) + // and final transcripts. + TranscriptNormalization transcript_normalization = 24; + // Array of [SpeechContext][google.cloud.speech.v1p1beta1.SpeechContext]. // A means to provide context to assist the speech recognition. For more // information, see diff --git a/protos/google/cloud/speech/v1p1beta1/resource.proto b/protos/google/cloud/speech/v1p1beta1/resource.proto index 731349c7..1ff0430d 100644 --- a/protos/google/cloud/speech/v1p1beta1/resource.proto +++ b/protos/google/cloud/speech/v1p1beta1/resource.proto @@ -17,6 +17,7 @@ syntax = "proto3"; package google.cloud.speech.v1p1beta1; import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; option cc_enable_arenas = true; @@ -132,3 +133,27 @@ message SpeechAdaptation { // `custom_class_id`. repeated CustomClass custom_classes = 3; } + +// Transcription normalization configuration. Use transcription normalization +// to automatically replace parts of the transcript with phrases of your +// choosing. For StreamingRecognize, this normalization only applies to stable +// partial transcripts (stability > 0.8) and final transcripts. +message TranscriptNormalization { + // A single replacement configuration. + message Entry { + // What to replace. Max length is 100 characters. + string search = 1; + + // What to replace with. Max length is 100 characters. + string replace = 2; + + // Whether the search is case sensitive. + bool case_sensitive = 3; + } + + // A list of replacement entries. We will perform replacement with one entry + // at a time. For example, the second entry in ["cat" => "dog", "mountain cat" + // => "mountain dog"] will never be applied because we will always process the + // first entry before it. At most 100 entries. + repeated Entry entries = 1; +} diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 9ec2503b..83eb095b 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -2616,6 +2616,9 @@ export namespace google { /** RecognitionConfig adaptation */ adaptation?: (google.cloud.speech.v1p1beta1.ISpeechAdaptation|null); + /** RecognitionConfig transcriptNormalization */ + transcriptNormalization?: (google.cloud.speech.v1p1beta1.ITranscriptNormalization|null); + /** RecognitionConfig speechContexts */ speechContexts?: (google.cloud.speech.v1p1beta1.ISpeechContext[]|null); @@ -2689,6 +2692,9 @@ export namespace google { /** RecognitionConfig adaptation. */ public adaptation?: (google.cloud.speech.v1p1beta1.ISpeechAdaptation|null); + /** RecognitionConfig transcriptNormalization. */ + public transcriptNormalization?: (google.cloud.speech.v1p1beta1.ITranscriptNormalization|null); + /** RecognitionConfig speechContexts. */ public speechContexts: google.cloud.speech.v1p1beta1.ISpeechContext[]; @@ -4667,6 +4673,201 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a TranscriptNormalization. */ + interface ITranscriptNormalization { + + /** TranscriptNormalization entries */ + entries?: (google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry[]|null); + } + + /** Represents a TranscriptNormalization. */ + class TranscriptNormalization implements ITranscriptNormalization { + + /** + * Constructs a new TranscriptNormalization. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.ITranscriptNormalization); + + /** TranscriptNormalization entries. */ + public entries: google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry[]; + + /** + * Creates a new TranscriptNormalization instance using the specified properties. + * @param [properties] Properties to set + * @returns TranscriptNormalization instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.ITranscriptNormalization): google.cloud.speech.v1p1beta1.TranscriptNormalization; + + /** + * Encodes the specified TranscriptNormalization message. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.verify|verify} messages. + * @param message TranscriptNormalization message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.ITranscriptNormalization, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TranscriptNormalization message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.verify|verify} messages. + * @param message TranscriptNormalization message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ITranscriptNormalization, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TranscriptNormalization message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TranscriptNormalization + * @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.v1p1beta1.TranscriptNormalization; + + /** + * Decodes a TranscriptNormalization message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TranscriptNormalization + * @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.v1p1beta1.TranscriptNormalization; + + /** + * Verifies a TranscriptNormalization 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 TranscriptNormalization message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TranscriptNormalization + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.TranscriptNormalization; + + /** + * Creates a plain object from a TranscriptNormalization message. Also converts values to other types if specified. + * @param message TranscriptNormalization + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.TranscriptNormalization, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TranscriptNormalization to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TranscriptNormalization { + + /** Properties of an Entry. */ + interface IEntry { + + /** Entry search */ + search?: (string|null); + + /** Entry replace */ + replace?: (string|null); + + /** Entry caseSensitive */ + caseSensitive?: (boolean|null); + } + + /** Represents an Entry. */ + class Entry implements IEntry { + + /** + * Constructs a new Entry. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry); + + /** Entry search. */ + public search: string; + + /** Entry replace. */ + public replace: string; + + /** Entry caseSensitive. */ + public caseSensitive: boolean; + + /** + * Creates a new Entry instance using the specified properties. + * @param [properties] Properties to set + * @returns Entry instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry): google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry; + + /** + * Encodes the specified Entry message. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.verify|verify} messages. + * @param message Entry message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Entry message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.verify|verify} messages. + * @param message Entry message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Entry message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Entry + * @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.v1p1beta1.TranscriptNormalization.Entry; + + /** + * Decodes an Entry message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Entry + * @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.v1p1beta1.TranscriptNormalization.Entry; + + /** + * Verifies an Entry 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 an Entry message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Entry + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry; + + /** + * Creates a plain object from an Entry message. Also converts values to other types if specified. + * @param message Entry + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Entry to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + /** Represents an Adaptation */ class Adaptation extends $protobuf.rpc.Service { diff --git a/protos/protos.js b/protos/protos.js index 12acf6e4..def17aef 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -6377,6 +6377,7 @@ * @property {number|null} [maxAlternatives] RecognitionConfig maxAlternatives * @property {boolean|null} [profanityFilter] RecognitionConfig profanityFilter * @property {google.cloud.speech.v1p1beta1.ISpeechAdaptation|null} [adaptation] RecognitionConfig adaptation + * @property {google.cloud.speech.v1p1beta1.ITranscriptNormalization|null} [transcriptNormalization] RecognitionConfig transcriptNormalization * @property {Array.|null} [speechContexts] RecognitionConfig speechContexts * @property {boolean|null} [enableWordTimeOffsets] RecognitionConfig enableWordTimeOffsets * @property {boolean|null} [enableWordConfidence] RecognitionConfig enableWordConfidence @@ -6480,6 +6481,14 @@ */ RecognitionConfig.prototype.adaptation = null; + /** + * RecognitionConfig transcriptNormalization. + * @member {google.cloud.speech.v1p1beta1.ITranscriptNormalization|null|undefined} transcriptNormalization + * @memberof google.cloud.speech.v1p1beta1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.transcriptNormalization = null; + /** * RecognitionConfig speechContexts. * @member {Array.} speechContexts @@ -6644,6 +6653,8 @@ $root.google.protobuf.BoolValue.encode(message.enableSpokenPunctuation, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.enableSpokenEmojis != null && Object.hasOwnProperty.call(message, "enableSpokenEmojis")) $root.google.protobuf.BoolValue.encode(message.enableSpokenEmojis, writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + if (message.transcriptNormalization != null && Object.hasOwnProperty.call(message, "transcriptNormalization")) + $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.encode(message.transcriptNormalization, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); return writer; }; @@ -6707,6 +6718,9 @@ case 20: message.adaptation = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.decode(reader, reader.uint32()); break; + case 24: + message.transcriptNormalization = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.decode(reader, reader.uint32()); + break; case 6: if (!(message.speechContexts && message.speechContexts.length)) message.speechContexts = []; @@ -6826,6 +6840,11 @@ if (error) return "adaptation." + error; } + if (message.transcriptNormalization != null && message.hasOwnProperty("transcriptNormalization")) { + var error = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.verify(message.transcriptNormalization); + if (error) + return "transcriptNormalization." + error; + } if (message.speechContexts != null && message.hasOwnProperty("speechContexts")) { if (!Array.isArray(message.speechContexts)) return "speechContexts: array expected"; @@ -6957,6 +6976,11 @@ throw TypeError(".google.cloud.speech.v1p1beta1.RecognitionConfig.adaptation: object expected"); message.adaptation = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.fromObject(object.adaptation); } + if (object.transcriptNormalization != null) { + if (typeof object.transcriptNormalization !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.RecognitionConfig.transcriptNormalization: object expected"); + message.transcriptNormalization = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.fromObject(object.transcriptNormalization); + } if (object.speechContexts) { if (!Array.isArray(object.speechContexts)) throw TypeError(".google.cloud.speech.v1p1beta1.RecognitionConfig.speechContexts: array expected"); @@ -7041,6 +7065,7 @@ object.adaptation = null; object.enableSpokenPunctuation = null; object.enableSpokenEmojis = null; + object.transcriptNormalization = null; } if (message.encoding != null && message.hasOwnProperty("encoding")) object.encoding = options.enums === String ? $root.google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding[message.encoding] : message.encoding; @@ -7090,6 +7115,8 @@ object.enableSpokenPunctuation = $root.google.protobuf.BoolValue.toObject(message.enableSpokenPunctuation, options); if (message.enableSpokenEmojis != null && message.hasOwnProperty("enableSpokenEmojis")) object.enableSpokenEmojis = $root.google.protobuf.BoolValue.toObject(message.enableSpokenEmojis, options); + if (message.transcriptNormalization != null && message.hasOwnProperty("transcriptNormalization")) + object.transcriptNormalization = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.toObject(message.transcriptNormalization, options); return object; }; @@ -11889,6 +11916,446 @@ return SpeechAdaptation; })(); + v1p1beta1.TranscriptNormalization = (function() { + + /** + * Properties of a TranscriptNormalization. + * @memberof google.cloud.speech.v1p1beta1 + * @interface ITranscriptNormalization + * @property {Array.|null} [entries] TranscriptNormalization entries + */ + + /** + * Constructs a new TranscriptNormalization. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a TranscriptNormalization. + * @implements ITranscriptNormalization + * @constructor + * @param {google.cloud.speech.v1p1beta1.ITranscriptNormalization=} [properties] Properties to set + */ + function TranscriptNormalization(properties) { + this.entries = []; + 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]]; + } + + /** + * TranscriptNormalization entries. + * @member {Array.} entries + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @instance + */ + TranscriptNormalization.prototype.entries = $util.emptyArray; + + /** + * Creates a new TranscriptNormalization instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {google.cloud.speech.v1p1beta1.ITranscriptNormalization=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization} TranscriptNormalization instance + */ + TranscriptNormalization.create = function create(properties) { + return new TranscriptNormalization(properties); + }; + + /** + * Encodes the specified TranscriptNormalization message. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {google.cloud.speech.v1p1beta1.ITranscriptNormalization} message TranscriptNormalization message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranscriptNormalization.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.entries != null && message.entries.length) + for (var i = 0; i < message.entries.length; ++i) + $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.encode(message.entries[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TranscriptNormalization message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {google.cloud.speech.v1p1beta1.ITranscriptNormalization} message TranscriptNormalization message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TranscriptNormalization.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TranscriptNormalization message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization} TranscriptNormalization + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranscriptNormalization.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.v1p1beta1.TranscriptNormalization(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.entries && message.entries.length)) + message.entries = []; + message.entries.push($root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TranscriptNormalization message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization} TranscriptNormalization + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TranscriptNormalization.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TranscriptNormalization message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TranscriptNormalization.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.entries != null && message.hasOwnProperty("entries")) { + if (!Array.isArray(message.entries)) + return "entries: array expected"; + for (var i = 0; i < message.entries.length; ++i) { + var error = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.verify(message.entries[i]); + if (error) + return "entries." + error; + } + } + return null; + }; + + /** + * Creates a TranscriptNormalization message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization} TranscriptNormalization + */ + TranscriptNormalization.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.TranscriptNormalization) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.TranscriptNormalization(); + if (object.entries) { + if (!Array.isArray(object.entries)) + throw TypeError(".google.cloud.speech.v1p1beta1.TranscriptNormalization.entries: array expected"); + message.entries = []; + for (var i = 0; i < object.entries.length; ++i) { + if (typeof object.entries[i] !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.TranscriptNormalization.entries: object expected"); + message.entries[i] = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.fromObject(object.entries[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a TranscriptNormalization message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @static + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization} message TranscriptNormalization + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TranscriptNormalization.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.entries = []; + if (message.entries && message.entries.length) { + object.entries = []; + for (var j = 0; j < message.entries.length; ++j) + object.entries[j] = $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.toObject(message.entries[j], options); + } + return object; + }; + + /** + * Converts this TranscriptNormalization to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @instance + * @returns {Object.} JSON object + */ + TranscriptNormalization.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + TranscriptNormalization.Entry = (function() { + + /** + * Properties of an Entry. + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @interface IEntry + * @property {string|null} [search] Entry search + * @property {string|null} [replace] Entry replace + * @property {boolean|null} [caseSensitive] Entry caseSensitive + */ + + /** + * Constructs a new Entry. + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization + * @classdesc Represents an Entry. + * @implements IEntry + * @constructor + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry=} [properties] Properties to set + */ + function Entry(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]]; + } + + /** + * Entry search. + * @member {string} search + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @instance + */ + Entry.prototype.search = ""; + + /** + * Entry replace. + * @member {string} replace + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @instance + */ + Entry.prototype.replace = ""; + + /** + * Entry caseSensitive. + * @member {boolean} caseSensitive + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @instance + */ + Entry.prototype.caseSensitive = false; + + /** + * Creates a new Entry instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry} Entry instance + */ + Entry.create = function create(properties) { + return new Entry(properties); + }; + + /** + * Encodes the specified Entry message. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry} message Entry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entry.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.search != null && Object.hasOwnProperty.call(message, "search")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.search); + if (message.replace != null && Object.hasOwnProperty.call(message, "replace")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.replace); + if (message.caseSensitive != null && Object.hasOwnProperty.call(message, "caseSensitive")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.caseSensitive); + return writer; + }; + + /** + * Encodes the specified Entry message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization.IEntry} message Entry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entry.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Entry message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry} Entry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entry.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.v1p1beta1.TranscriptNormalization.Entry(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.search = reader.string(); + break; + case 2: + message.replace = reader.string(); + break; + case 3: + message.caseSensitive = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Entry message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry} Entry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entry.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Entry message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Entry.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.search != null && message.hasOwnProperty("search")) + if (!$util.isString(message.search)) + return "search: string expected"; + if (message.replace != null && message.hasOwnProperty("replace")) + if (!$util.isString(message.replace)) + return "replace: string expected"; + if (message.caseSensitive != null && message.hasOwnProperty("caseSensitive")) + if (typeof message.caseSensitive !== "boolean") + return "caseSensitive: boolean expected"; + return null; + }; + + /** + * Creates an Entry message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry} Entry + */ + Entry.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry(); + if (object.search != null) + message.search = String(object.search); + if (object.replace != null) + message.replace = String(object.replace); + if (object.caseSensitive != null) + message.caseSensitive = Boolean(object.caseSensitive); + return message; + }; + + /** + * Creates a plain object from an Entry message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @static + * @param {google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry} message Entry + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Entry.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.search = ""; + object.replace = ""; + object.caseSensitive = false; + } + if (message.search != null && message.hasOwnProperty("search")) + object.search = message.search; + if (message.replace != null && message.hasOwnProperty("replace")) + object.replace = message.replace; + if (message.caseSensitive != null && message.hasOwnProperty("caseSensitive")) + object.caseSensitive = message.caseSensitive; + return object; + }; + + /** + * Converts this Entry to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.TranscriptNormalization.Entry + * @instance + * @returns {Object.} JSON object + */ + Entry.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Entry; + })(); + + return TranscriptNormalization; + })(); + v1p1beta1.Adaptation = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index 09c87990..62664dec 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -737,6 +737,10 @@ "type": "SpeechAdaptation", "id": 20 }, + "transcriptNormalization": { + "type": "TranscriptNormalization", + "id": 24 + }, "speechContexts": { "rule": "repeated", "type": "SpeechContext", @@ -1228,6 +1232,33 @@ } } }, + "TranscriptNormalization": { + "fields": { + "entries": { + "rule": "repeated", + "type": "Entry", + "id": 1 + } + }, + "nested": { + "Entry": { + "fields": { + "search": { + "type": "string", + "id": 1 + }, + "replace": { + "type": "string", + "id": 2 + }, + "caseSensitive": { + "type": "bool", + "id": 3 + } + } + } + } + }, "Adaptation": { "options": { "(google.api.default_host)": "speech.googleapis.com",