diff --git a/protos/google/cloud/speech/v1/cloud_speech.proto b/protos/google/cloud/speech/v1/cloud_speech.proto index 4651fc9e..875ea250 100644 --- a/protos/google/cloud/speech/v1/cloud_speech.proto +++ b/protos/google/cloud/speech/v1/cloud_speech.proto @@ -19,6 +19,7 @@ package google.cloud.speech.v1; import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; +import "google/cloud/speech/v1/resource.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/duration.proto"; @@ -181,7 +182,8 @@ message RecognitionConfig { // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech // recognition can be reduced if lossy codecs are used to capture or transmit // audio, particularly if background noise is present. Lossy codecs include - // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`. + // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`, + // and `WEBM_OPUS`. // // The `FLAC` and `WAV` audio file formats include a header that describes the // included audio content. You can request recognition for `WAV` files that @@ -236,6 +238,11 @@ message RecognitionConfig { // is replaced with a single byte containing the block length. Only Speex // wideband is supported. `sample_rate_hertz` must be 16000. SPEEX_WITH_HEADER_BYTE = 7; + + // Opus encoded audio frames in WebM container + // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be + // one of 8000, 12000, 16000, 24000, or 48000. + WEBM_OPUS = 9; } // Encoding of audio data sent in all `RecognitionAudio` messages. @@ -279,6 +286,20 @@ message RecognitionConfig { // of the currently supported language codes. string language_code = 3 [(google.api.field_behavior) = REQUIRED]; + // A list of up to 3 additional + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, + // listing possible alternative languages of the supplied audio. + // See [Language + // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list + // of the currently supported language codes. If alternative languages are + // listed, recognition result will contain recognition in the most likely + // language detected including the main language_code. The recognition result + // will include the language tag of the language detected in the audio. Note: + // This feature is only supported for Voice Command and Voice Search use cases + // and performance may vary for other use cases (e.g., phone call + // transcription). + repeated string alternative_language_codes = 18; + // Maximum number of recognition hypotheses to be returned. // Specifically, the maximum number of `SpeechRecognitionAlternative` messages // within each `SpeechRecognitionResult`. @@ -293,6 +314,13 @@ message RecognitionConfig { // won't be filtered out. bool profanity_filter = 5; + // Speech adaptation configuration improves the accuracy of speech + // recognition. For more information, see the [speech + // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) + // documentation. + // When speech adaptation is set it supersedes the `speech_contexts` field. + SpeechAdaptation adaptation = 20; + // Array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. // A means to provide context to assist the speech recognition. For more // information, see @@ -306,12 +334,33 @@ message RecognitionConfig { // `false`. bool enable_word_time_offsets = 8; + // If `true`, the top result includes a list of words and the + // confidence for those words. If `false`, no word-level confidence + // information is returned. The default is `false`. + bool enable_word_confidence = 15; + // If 'true', adds punctuation to recognition result hypotheses. // This feature is only available in select languages. Setting this for // requests in other languages has no effect at all. // The default 'false' value does not add punctuation to result hypotheses. bool enable_automatic_punctuation = 11; + // The spoken punctuation behavior for the call + // If not set, uses default behavior based on model of choice + // e.g. command_and_search will enable spoken punctuation by default + // If 'true', replaces spoken punctuation with the corresponding symbols in + // the request. For example, "how are you question mark" becomes "how are + // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation + // for support. If 'false', spoken punctuation is not replaced. + google.protobuf.BoolValue enable_spoken_punctuation = 22; + + // The spoken emoji behavior for the call + // If not set, uses default behavior based on model of choice + // If 'true', adds spoken emoji formatting for the request. This will replace + // spoken emojis with the corresponding Unicode symbols in the final + // transcript. If 'false', spoken emojis are not replaced. + google.protobuf.BoolValue enable_spoken_emojis = 23; + // Config to enable speaker diarization and set additional // parameters to make diarization better suited for your application. // Note: When this is enabled, we send all the words from the beginning of the @@ -537,6 +586,16 @@ message SpeechContext { // improves the likelihood of correctly transcribing audio that includes // months. repeated string phrases = 1; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 and 20. We recommend using a binary search approach to + // finding the optimal value for your use case. + float boost = 4; } // Contains audio data in the encoding specified in the `RecognitionConfig`. @@ -587,6 +646,12 @@ message LongRunningRecognizeResponse { // When available, billed audio seconds for the corresponding request. google.protobuf.Duration total_billed_time = 3; + + // Original output config if present in the request. + TranscriptOutputConfig output_config = 6; + + // If the transcript output fails this field contains the relevant error. + google.rpc.Status output_error = 7; } // Describes the progress of a long-running `LongRunningRecognize` call. It is @@ -723,11 +788,10 @@ message StreamingRecognitionResult { // For audio_channel_count = N, its output values can range from '1' to 'N'. int32 channel_tag = 5; - // The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag of - // the language in this result. This language code was detected to have the - // most likelihood of being spoken in the audio. - string language_code = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; } // A speech recognition result corresponding to a portion of the audio. @@ -742,6 +806,15 @@ message SpeechRecognitionResult { // recognized result for the audio from that channel. // For audio_channel_count = N, its output values can range from '1' to 'N'. int32 channel_tag = 2; + + // Time offset of the end of this result relative to the + // beginning of the audio. + google.protobuf.Duration result_end_time = 4; + + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; } // Alternative hypotheses (a.k.a. n-best list). @@ -785,6 +858,15 @@ message WordInfo { // The word corresponding to this set of information. string word = 3; + // The confidence estimate between 0.0 and 1.0. A higher number + // indicates an estimated greater likelihood that the recognized words are + // correct. This field is set only for the top alternative of a non-streaming + // result or, of a streaming result where `is_final=true`. + // This field is not guaranteed to be accurate and users should not rely on it + // to be always provided. + // The default of 0.0 is a sentinel value indicating `confidence` was not set. + float confidence = 4; + // Output only. A distinct integer value is assigned for every speaker within // the audio. This field specifies which one of those speakers was detected to // have spoken this word. Value ranges from '1' to diarization_speaker_count. diff --git a/protos/google/cloud/speech/v1/resource.proto b/protos/google/cloud/speech/v1/resource.proto new file mode 100644 index 00000000..edaeeff2 --- /dev/null +++ b/protos/google/cloud/speech/v1/resource.proto @@ -0,0 +1,140 @@ +// Copyright 2021 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. + +syntax = "proto3"; + +package google.cloud.speech.v1; + +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechResourceProto"; +option java_package = "com.google.cloud.speech.v1"; +option objc_class_prefix = "GCS"; + +// A set of words or phrases that represents a common concept likely to appear +// in your audio, for example a list of passenger ship names. CustomClass items +// can be substituted into placeholders that you set in PhraseSet phrases. +message CustomClass { + option (google.api.resource) = { + type: "speech.googleapis.com/CustomClass" + pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" + }; + + // An item of the class. + message ClassItem { + // The class item's value. + string value = 1; + } + + // The resource name of the custom class. + string name = 1; + + // If this custom class is a resource, the custom_class_id is the resource id + // of the CustomClass. Case sensitive. + string custom_class_id = 2; + + // A collection of class items. + repeated ClassItem items = 3; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. +message PhraseSet { + option (google.api.resource) = { + type: "speech.googleapis.com/PhraseSet" + pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}" + }; + + // A phrases containing words and phrase "hints" so that + // the speech recognition is more likely to recognize them. This can be used + // to improve the accuracy for specific words and phrases, for example, if + // specific commands are typically spoken by the user. This can also be used + // to add additional words to the vocabulary of the recognizer. See + // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). + // + // List items can also include pre-built or custom classes containing groups + // of words that represent common concepts that occur in natural language. For + // example, rather than providing a phrase hint for every month of the + // year (e.g. "i was born in january", "i was born in febuary", ...), use the + // pre-built `$MONTH` class improves the likelihood of correctly transcribing + // audio that includes months (e.g. "i was born in $month"). + // To refer to pre-built classes, use the class' symbol prepended with `$` + // e.g. `$MONTH`. To refer to custom classes that were defined inline in the + // request, set the class's `custom_class_id` to a string unique to all class + // resources and inline classes. Then use the class' id wrapped in $`{...}` + // e.g. "${my-months}". To refer to custom classes resources, use the class' + // id wrapped in `${}` (e.g. `${my-months}`). + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or + // `eu` location value. + message Phrase { + // The phrase itself. + string value = 1; + + // Hint Boost. Overrides the boost set at the phrase set level. + // Positive value will increase the probability that a specific phrase will + // be recognized over other similar sounding phrases. The higher the boost, + // the higher the chance of false positive recognition as well. Negative + // boost will simply be ignored. Though `boost` can accept a wide range of + // positive values, most use cases are best served + // with values between 0 and 20. We recommend using a binary search approach + // to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 2; + } + + // The resource name of the phrase set. + string name = 1; + + // A list of word and phrases. + repeated Phrase phrases = 2; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 (exclusive) and 20. We recommend using a binary search + // approach to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 4; +} + +// Speech adaptation configuration. +message SpeechAdaptation { + // A collection of phrase sets. To specify the hints inline, leave the + // phrase set's `name` blank and fill in the rest of its fields. Any + // phrase set can use any custom class. + repeated PhraseSet phrase_sets = 1; + + // A collection of phrase set resource names to use. + repeated string phrase_set_references = 2 [(google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + }]; + + // A collection of custom classes. To specify the classes inline, leave the + // class' `name` blank and fill in the rest of its fields, giving it a unique + // `custom_class_id`. Refer to the inline defined class in phrase hints by its + // `custom_class_id`. + repeated CustomClass custom_classes = 3; +} diff --git a/protos/protos.d.ts b/protos/protos.d.ts index d5ad85b2..5d6f3e0b 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -623,21 +623,36 @@ export namespace google { /** RecognitionConfig languageCode */ languageCode?: (string|null); + /** RecognitionConfig alternativeLanguageCodes */ + alternativeLanguageCodes?: (string[]|null); + /** RecognitionConfig maxAlternatives */ maxAlternatives?: (number|null); /** RecognitionConfig profanityFilter */ profanityFilter?: (boolean|null); + /** RecognitionConfig adaptation */ + adaptation?: (google.cloud.speech.v1.ISpeechAdaptation|null); + /** RecognitionConfig speechContexts */ speechContexts?: (google.cloud.speech.v1.ISpeechContext[]|null); /** RecognitionConfig enableWordTimeOffsets */ enableWordTimeOffsets?: (boolean|null); + /** RecognitionConfig enableWordConfidence */ + enableWordConfidence?: (boolean|null); + /** RecognitionConfig enableAutomaticPunctuation */ enableAutomaticPunctuation?: (boolean|null); + /** RecognitionConfig enableSpokenPunctuation */ + enableSpokenPunctuation?: (google.protobuf.IBoolValue|null); + + /** RecognitionConfig enableSpokenEmojis */ + enableSpokenEmojis?: (google.protobuf.IBoolValue|null); + /** RecognitionConfig diarizationConfig */ diarizationConfig?: (google.cloud.speech.v1.ISpeakerDiarizationConfig|null); @@ -675,21 +690,36 @@ export namespace google { /** RecognitionConfig languageCode. */ public languageCode: string; + /** RecognitionConfig alternativeLanguageCodes. */ + public alternativeLanguageCodes: string[]; + /** RecognitionConfig maxAlternatives. */ public maxAlternatives: number; /** RecognitionConfig profanityFilter. */ public profanityFilter: boolean; + /** RecognitionConfig adaptation. */ + public adaptation?: (google.cloud.speech.v1.ISpeechAdaptation|null); + /** RecognitionConfig speechContexts. */ public speechContexts: google.cloud.speech.v1.ISpeechContext[]; /** RecognitionConfig enableWordTimeOffsets. */ public enableWordTimeOffsets: boolean; + /** RecognitionConfig enableWordConfidence. */ + public enableWordConfidence: boolean; + /** RecognitionConfig enableAutomaticPunctuation. */ public enableAutomaticPunctuation: boolean; + /** RecognitionConfig enableSpokenPunctuation. */ + public enableSpokenPunctuation?: (google.protobuf.IBoolValue|null); + + /** RecognitionConfig enableSpokenEmojis. */ + public enableSpokenEmojis?: (google.protobuf.IBoolValue|null); + /** RecognitionConfig diarizationConfig. */ public diarizationConfig?: (google.cloud.speech.v1.ISpeakerDiarizationConfig|null); @@ -784,7 +814,8 @@ export namespace google { AMR = 4, AMR_WB = 5, OGG_OPUS = 6, - SPEEX_WITH_HEADER_BYTE = 7 + SPEEX_WITH_HEADER_BYTE = 7, + WEBM_OPUS = 9 } } @@ -1075,6 +1106,9 @@ export namespace google { /** SpeechContext phrases */ phrases?: (string[]|null); + + /** SpeechContext boost */ + boost?: (number|null); } /** Represents a SpeechContext. */ @@ -1089,6 +1123,9 @@ export namespace google { /** SpeechContext phrases. */ public phrases: string[]; + /** SpeechContext boost. */ + public boost: number; + /** * Creates a new SpeechContext instance using the specified properties. * @param [properties] Properties to set @@ -1363,6 +1400,12 @@ export namespace google { /** LongRunningRecognizeResponse totalBilledTime */ totalBilledTime?: (google.protobuf.IDuration|null); + + /** LongRunningRecognizeResponse outputConfig */ + outputConfig?: (google.cloud.speech.v1.ITranscriptOutputConfig|null); + + /** LongRunningRecognizeResponse outputError */ + outputError?: (google.rpc.IStatus|null); } /** Represents a LongRunningRecognizeResponse. */ @@ -1380,6 +1423,12 @@ export namespace google { /** LongRunningRecognizeResponse totalBilledTime. */ public totalBilledTime?: (google.protobuf.IDuration|null); + /** LongRunningRecognizeResponse outputConfig. */ + public outputConfig?: (google.cloud.speech.v1.ITranscriptOutputConfig|null); + + /** LongRunningRecognizeResponse outputError. */ + public outputError?: (google.rpc.IStatus|null); + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -1804,6 +1853,12 @@ export namespace google { /** SpeechRecognitionResult channelTag */ channelTag?: (number|null); + + /** SpeechRecognitionResult resultEndTime */ + resultEndTime?: (google.protobuf.IDuration|null); + + /** SpeechRecognitionResult languageCode */ + languageCode?: (string|null); } /** Represents a SpeechRecognitionResult. */ @@ -1821,6 +1876,12 @@ export namespace google { /** SpeechRecognitionResult channelTag. */ public channelTag: number; + /** SpeechRecognitionResult resultEndTime. */ + public resultEndTime?: (google.protobuf.IDuration|null); + + /** SpeechRecognitionResult languageCode. */ + public languageCode: string; + /** * Creates a new SpeechRecognitionResult instance using the specified properties. * @param [properties] Properties to set @@ -2003,100 +2064,604 @@ export namespace google { /** WordInfo endTime */ endTime?: (google.protobuf.IDuration|null); - /** WordInfo word */ - word?: (string|null); + /** WordInfo word */ + word?: (string|null); + + /** WordInfo confidence */ + confidence?: (number|null); + + /** WordInfo speakerTag */ + speakerTag?: (number|null); + } + + /** Represents a WordInfo. */ + class WordInfo implements IWordInfo { + + /** + * Constructs a new WordInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.IWordInfo); + + /** WordInfo startTime. */ + public startTime?: (google.protobuf.IDuration|null); + + /** WordInfo endTime. */ + public endTime?: (google.protobuf.IDuration|null); + + /** WordInfo word. */ + public word: string; + + /** WordInfo confidence. */ + public confidence: number; + + /** WordInfo speakerTag. */ + public speakerTag: number; + + /** + * Creates a new WordInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns WordInfo instance + */ + public static create(properties?: google.cloud.speech.v1.IWordInfo): google.cloud.speech.v1.WordInfo; + + /** + * Encodes the specified WordInfo message. Does not implicitly {@link google.cloud.speech.v1.WordInfo.verify|verify} messages. + * @param message WordInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.IWordInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WordInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1.WordInfo.verify|verify} messages. + * @param message WordInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.IWordInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WordInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WordInfo + * @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.WordInfo; + + /** + * Decodes a WordInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WordInfo + * @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.WordInfo; + + /** + * Verifies a WordInfo 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 WordInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WordInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.WordInfo; + + /** + * Creates a plain object from a WordInfo message. Also converts values to other types if specified. + * @param message WordInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.WordInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WordInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CustomClass. */ + interface ICustomClass { + + /** CustomClass name */ + name?: (string|null); + + /** CustomClass customClassId */ + customClassId?: (string|null); + + /** CustomClass items */ + items?: (google.cloud.speech.v1.CustomClass.IClassItem[]|null); + } + + /** Represents a CustomClass. */ + class CustomClass implements ICustomClass { + + /** + * Constructs a new CustomClass. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.ICustomClass); + + /** CustomClass name. */ + public name: string; + + /** CustomClass customClassId. */ + public customClassId: string; + + /** CustomClass items. */ + public items: google.cloud.speech.v1.CustomClass.IClassItem[]; + + /** + * Creates a new CustomClass instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomClass instance + */ + public static create(properties?: google.cloud.speech.v1.ICustomClass): google.cloud.speech.v1.CustomClass; + + /** + * Encodes the specified CustomClass message. Does not implicitly {@link google.cloud.speech.v1.CustomClass.verify|verify} messages. + * @param message CustomClass message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.ICustomClass, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomClass message, length delimited. Does not implicitly {@link google.cloud.speech.v1.CustomClass.verify|verify} messages. + * @param message CustomClass message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.ICustomClass, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomClass message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomClass + * @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.CustomClass; + + /** + * Decodes a CustomClass message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomClass + * @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.CustomClass; + + /** + * Verifies a CustomClass 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 CustomClass message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomClass + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.CustomClass; + + /** + * Creates a plain object from a CustomClass message. Also converts values to other types if specified. + * @param message CustomClass + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.CustomClass, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomClass to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace CustomClass { + + /** Properties of a ClassItem. */ + interface IClassItem { + + /** ClassItem value */ + value?: (string|null); + } + + /** Represents a ClassItem. */ + class ClassItem implements IClassItem { + + /** + * Constructs a new ClassItem. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.CustomClass.IClassItem); + + /** ClassItem value. */ + public value: string; + + /** + * Creates a new ClassItem instance using the specified properties. + * @param [properties] Properties to set + * @returns ClassItem instance + */ + public static create(properties?: google.cloud.speech.v1.CustomClass.IClassItem): google.cloud.speech.v1.CustomClass.ClassItem; + + /** + * Encodes the specified ClassItem message. Does not implicitly {@link google.cloud.speech.v1.CustomClass.ClassItem.verify|verify} messages. + * @param message ClassItem message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.CustomClass.IClassItem, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClassItem message, length delimited. Does not implicitly {@link google.cloud.speech.v1.CustomClass.ClassItem.verify|verify} messages. + * @param message ClassItem message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.CustomClass.IClassItem, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClassItem message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClassItem + * @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.CustomClass.ClassItem; + + /** + * Decodes a ClassItem message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClassItem + * @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.CustomClass.ClassItem; + + /** + * Verifies a ClassItem 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 ClassItem message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClassItem + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.CustomClass.ClassItem; + + /** + * Creates a plain object from a ClassItem message. Also converts values to other types if specified. + * @param message ClassItem + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.CustomClass.ClassItem, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClassItem to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a PhraseSet. */ + interface IPhraseSet { + + /** PhraseSet name */ + name?: (string|null); + + /** PhraseSet phrases */ + phrases?: (google.cloud.speech.v1.PhraseSet.IPhrase[]|null); + + /** PhraseSet boost */ + boost?: (number|null); + } + + /** Represents a PhraseSet. */ + class PhraseSet implements IPhraseSet { + + /** + * Constructs a new PhraseSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.IPhraseSet); + + /** PhraseSet name. */ + public name: string; + + /** PhraseSet phrases. */ + public phrases: google.cloud.speech.v1.PhraseSet.IPhrase[]; + + /** PhraseSet boost. */ + public boost: number; + + /** + * Creates a new PhraseSet instance using the specified properties. + * @param [properties] Properties to set + * @returns PhraseSet instance + */ + public static create(properties?: google.cloud.speech.v1.IPhraseSet): google.cloud.speech.v1.PhraseSet; + + /** + * Encodes the specified PhraseSet message. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.verify|verify} messages. + * @param message PhraseSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.IPhraseSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.verify|verify} messages. + * @param message PhraseSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.IPhraseSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PhraseSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PhraseSet + * @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.PhraseSet; + + /** + * Decodes a PhraseSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PhraseSet + * @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.PhraseSet; + + /** + * Verifies a PhraseSet 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 PhraseSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PhraseSet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.PhraseSet; + + /** + * Creates a plain object from a PhraseSet message. Also converts values to other types if specified. + * @param message PhraseSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.PhraseSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PhraseSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace PhraseSet { + + /** Properties of a Phrase. */ + interface IPhrase { + + /** Phrase value */ + value?: (string|null); + + /** Phrase boost */ + boost?: (number|null); + } + + /** Represents a Phrase. */ + class Phrase implements IPhrase { + + /** + * Constructs a new Phrase. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.PhraseSet.IPhrase); + + /** Phrase value. */ + public value: string; + + /** Phrase boost. */ + public boost: number; + + /** + * Creates a new Phrase instance using the specified properties. + * @param [properties] Properties to set + * @returns Phrase instance + */ + public static create(properties?: google.cloud.speech.v1.PhraseSet.IPhrase): google.cloud.speech.v1.PhraseSet.Phrase; + + /** + * Encodes the specified Phrase message. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.Phrase.verify|verify} messages. + * @param message Phrase message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.PhraseSet.IPhrase, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Phrase message, length delimited. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.Phrase.verify|verify} messages. + * @param message Phrase message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.PhraseSet.IPhrase, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Phrase message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Phrase + * @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.PhraseSet.Phrase; + + /** + * Decodes a Phrase message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Phrase + * @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.PhraseSet.Phrase; + + /** + * Verifies a Phrase 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 Phrase message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Phrase + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.PhraseSet.Phrase; + + /** + * Creates a plain object from a Phrase message. Also converts values to other types if specified. + * @param message Phrase + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.PhraseSet.Phrase, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Phrase to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a SpeechAdaptation. */ + interface ISpeechAdaptation { + + /** SpeechAdaptation phraseSets */ + phraseSets?: (google.cloud.speech.v1.IPhraseSet[]|null); + + /** SpeechAdaptation phraseSetReferences */ + phraseSetReferences?: (string[]|null); - /** WordInfo speakerTag */ - speakerTag?: (number|null); + /** SpeechAdaptation customClasses */ + customClasses?: (google.cloud.speech.v1.ICustomClass[]|null); } - /** Represents a WordInfo. */ - class WordInfo implements IWordInfo { + /** Represents a SpeechAdaptation. */ + class SpeechAdaptation implements ISpeechAdaptation { /** - * Constructs a new WordInfo. + * Constructs a new SpeechAdaptation. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.speech.v1.IWordInfo); - - /** WordInfo startTime. */ - public startTime?: (google.protobuf.IDuration|null); + constructor(properties?: google.cloud.speech.v1.ISpeechAdaptation); - /** WordInfo endTime. */ - public endTime?: (google.protobuf.IDuration|null); + /** SpeechAdaptation phraseSets. */ + public phraseSets: google.cloud.speech.v1.IPhraseSet[]; - /** WordInfo word. */ - public word: string; + /** SpeechAdaptation phraseSetReferences. */ + public phraseSetReferences: string[]; - /** WordInfo speakerTag. */ - public speakerTag: number; + /** SpeechAdaptation customClasses. */ + public customClasses: google.cloud.speech.v1.ICustomClass[]; /** - * Creates a new WordInfo instance using the specified properties. + * Creates a new SpeechAdaptation instance using the specified properties. * @param [properties] Properties to set - * @returns WordInfo instance + * @returns SpeechAdaptation instance */ - public static create(properties?: google.cloud.speech.v1.IWordInfo): google.cloud.speech.v1.WordInfo; + public static create(properties?: google.cloud.speech.v1.ISpeechAdaptation): google.cloud.speech.v1.SpeechAdaptation; /** - * Encodes the specified WordInfo message. Does not implicitly {@link google.cloud.speech.v1.WordInfo.verify|verify} messages. - * @param message WordInfo message or plain object to encode + * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.verify|verify} messages. + * @param message SpeechAdaptation message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.speech.v1.IWordInfo, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.speech.v1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified WordInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1.WordInfo.verify|verify} messages. - * @param message WordInfo message or plain object to encode + * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.verify|verify} messages. + * @param message SpeechAdaptation message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.speech.v1.IWordInfo, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.speech.v1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a WordInfo message from the specified reader or buffer. + * Decodes a SpeechAdaptation message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns WordInfo + * @returns SpeechAdaptation * @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.WordInfo; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1.SpeechAdaptation; /** - * Decodes a WordInfo message from the specified reader or buffer, length delimited. + * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns WordInfo + * @returns SpeechAdaptation * @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.WordInfo; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1.SpeechAdaptation; /** - * Verifies a WordInfo message. + * Verifies a SpeechAdaptation 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 WordInfo message from a plain object. Also converts values to their respective internal types. + * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns WordInfo + * @returns SpeechAdaptation */ - public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.WordInfo; + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.SpeechAdaptation; /** - * Creates a plain object from a WordInfo message. Also converts values to other types if specified. - * @param message WordInfo + * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. + * @param message SpeechAdaptation * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.speech.v1.WordInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.speech.v1.SpeechAdaptation, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this WordInfo to JSON. + * Converts this SpeechAdaptation to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -10081,6 +10646,102 @@ export namespace google { } } + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|Long|string|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: (number|Long|string); + + /** Timestamp nanos. */ + public nanos: number; + + /** + * Creates a new Timestamp instance using the specified properties. + * @param [properties] Properties to set + * @returns Timestamp instance + */ + public static create(properties?: google.protobuf.ITimestamp): google.protobuf.Timestamp; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Timestamp + * @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.protobuf.Timestamp; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Timestamp + * @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.protobuf.Timestamp; + + /** + * Verifies a Timestamp 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 Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of an Any. */ interface IAny { @@ -10357,102 +11018,6 @@ export namespace google { public toJSON(): { [k: string]: any }; } - /** Properties of a Timestamp. */ - interface ITimestamp { - - /** Timestamp seconds */ - seconds?: (number|Long|string|null); - - /** Timestamp nanos */ - nanos?: (number|null); - } - - /** Represents a Timestamp. */ - class Timestamp implements ITimestamp { - - /** - * Constructs a new Timestamp. - * @param [properties] Properties to set - */ - constructor(properties?: google.protobuf.ITimestamp); - - /** Timestamp seconds. */ - public seconds: (number|Long|string); - - /** Timestamp nanos. */ - public nanos: number; - - /** - * Creates a new Timestamp instance using the specified properties. - * @param [properties] Properties to set - * @returns Timestamp instance - */ - public static create(properties?: google.protobuf.ITimestamp): google.protobuf.Timestamp; - - /** - * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. - * @param message Timestamp message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. - * @param message Timestamp message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Timestamp message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Timestamp - * @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.protobuf.Timestamp; - - /** - * Decodes a Timestamp message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Timestamp - * @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.protobuf.Timestamp; - - /** - * Verifies a Timestamp 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 Timestamp message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Timestamp - */ - public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; - - /** - * Creates a plain object from a Timestamp message. Also converts values to other types if specified. - * @param message Timestamp - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Timestamp to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - /** Properties of a DoubleValue. */ interface IDoubleValue { diff --git a/protos/protos.js b/protos/protos.js index 61560a92..51f54520 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -1362,11 +1362,16 @@ * @property {number|null} [audioChannelCount] RecognitionConfig audioChannelCount * @property {boolean|null} [enableSeparateRecognitionPerChannel] RecognitionConfig enableSeparateRecognitionPerChannel * @property {string|null} [languageCode] RecognitionConfig languageCode + * @property {Array.|null} [alternativeLanguageCodes] RecognitionConfig alternativeLanguageCodes * @property {number|null} [maxAlternatives] RecognitionConfig maxAlternatives * @property {boolean|null} [profanityFilter] RecognitionConfig profanityFilter + * @property {google.cloud.speech.v1.ISpeechAdaptation|null} [adaptation] RecognitionConfig adaptation * @property {Array.|null} [speechContexts] RecognitionConfig speechContexts * @property {boolean|null} [enableWordTimeOffsets] RecognitionConfig enableWordTimeOffsets + * @property {boolean|null} [enableWordConfidence] RecognitionConfig enableWordConfidence * @property {boolean|null} [enableAutomaticPunctuation] RecognitionConfig enableAutomaticPunctuation + * @property {google.protobuf.IBoolValue|null} [enableSpokenPunctuation] RecognitionConfig enableSpokenPunctuation + * @property {google.protobuf.IBoolValue|null} [enableSpokenEmojis] RecognitionConfig enableSpokenEmojis * @property {google.cloud.speech.v1.ISpeakerDiarizationConfig|null} [diarizationConfig] RecognitionConfig diarizationConfig * @property {google.cloud.speech.v1.IRecognitionMetadata|null} [metadata] RecognitionConfig metadata * @property {string|null} [model] RecognitionConfig model @@ -1382,6 +1387,7 @@ * @param {google.cloud.speech.v1.IRecognitionConfig=} [properties] Properties to set */ function RecognitionConfig(properties) { + this.alternativeLanguageCodes = []; this.speechContexts = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) @@ -1429,6 +1435,14 @@ */ RecognitionConfig.prototype.languageCode = ""; + /** + * RecognitionConfig alternativeLanguageCodes. + * @member {Array.} alternativeLanguageCodes + * @memberof google.cloud.speech.v1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.alternativeLanguageCodes = $util.emptyArray; + /** * RecognitionConfig maxAlternatives. * @member {number} maxAlternatives @@ -1445,6 +1459,14 @@ */ RecognitionConfig.prototype.profanityFilter = false; + /** + * RecognitionConfig adaptation. + * @member {google.cloud.speech.v1.ISpeechAdaptation|null|undefined} adaptation + * @memberof google.cloud.speech.v1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.adaptation = null; + /** * RecognitionConfig speechContexts. * @member {Array.} speechContexts @@ -1461,6 +1483,14 @@ */ RecognitionConfig.prototype.enableWordTimeOffsets = false; + /** + * RecognitionConfig enableWordConfidence. + * @member {boolean} enableWordConfidence + * @memberof google.cloud.speech.v1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.enableWordConfidence = false; + /** * RecognitionConfig enableAutomaticPunctuation. * @member {boolean} enableAutomaticPunctuation @@ -1469,6 +1499,22 @@ */ RecognitionConfig.prototype.enableAutomaticPunctuation = false; + /** + * RecognitionConfig enableSpokenPunctuation. + * @member {google.protobuf.IBoolValue|null|undefined} enableSpokenPunctuation + * @memberof google.cloud.speech.v1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.enableSpokenPunctuation = null; + + /** + * RecognitionConfig enableSpokenEmojis. + * @member {google.protobuf.IBoolValue|null|undefined} enableSpokenEmojis + * @memberof google.cloud.speech.v1.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.enableSpokenEmojis = null; + /** * RecognitionConfig diarizationConfig. * @member {google.cloud.speech.v1.ISpeakerDiarizationConfig|null|undefined} diarizationConfig @@ -1552,8 +1598,19 @@ writer.uint32(/* id 13, wireType 2 =*/106).string(message.model); if (message.useEnhanced != null && Object.hasOwnProperty.call(message, "useEnhanced")) writer.uint32(/* id 14, wireType 0 =*/112).bool(message.useEnhanced); + if (message.enableWordConfidence != null && Object.hasOwnProperty.call(message, "enableWordConfidence")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.enableWordConfidence); + if (message.alternativeLanguageCodes != null && message.alternativeLanguageCodes.length) + for (var i = 0; i < message.alternativeLanguageCodes.length; ++i) + writer.uint32(/* id 18, wireType 2 =*/146).string(message.alternativeLanguageCodes[i]); if (message.diarizationConfig != null && Object.hasOwnProperty.call(message, "diarizationConfig")) $root.google.cloud.speech.v1.SpeakerDiarizationConfig.encode(message.diarizationConfig, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + if (message.adaptation != null && Object.hasOwnProperty.call(message, "adaptation")) + $root.google.cloud.speech.v1.SpeechAdaptation.encode(message.adaptation, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.enableSpokenPunctuation != null && Object.hasOwnProperty.call(message, "enableSpokenPunctuation")) + $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(); return writer; }; @@ -1603,12 +1660,20 @@ case 3: message.languageCode = reader.string(); break; + case 18: + if (!(message.alternativeLanguageCodes && message.alternativeLanguageCodes.length)) + message.alternativeLanguageCodes = []; + message.alternativeLanguageCodes.push(reader.string()); + break; case 4: message.maxAlternatives = reader.int32(); break; case 5: message.profanityFilter = reader.bool(); break; + case 20: + message.adaptation = $root.google.cloud.speech.v1.SpeechAdaptation.decode(reader, reader.uint32()); + break; case 6: if (!(message.speechContexts && message.speechContexts.length)) message.speechContexts = []; @@ -1617,9 +1682,18 @@ case 8: message.enableWordTimeOffsets = reader.bool(); break; + case 15: + message.enableWordConfidence = reader.bool(); + break; case 11: message.enableAutomaticPunctuation = reader.bool(); break; + case 22: + message.enableSpokenPunctuation = $root.google.protobuf.BoolValue.decode(reader, reader.uint32()); + break; + case 23: + message.enableSpokenEmojis = $root.google.protobuf.BoolValue.decode(reader, reader.uint32()); + break; case 19: message.diarizationConfig = $root.google.cloud.speech.v1.SpeakerDiarizationConfig.decode(reader, reader.uint32()); break; @@ -1679,6 +1753,7 @@ case 5: case 6: case 7: + case 9: break; } if (message.sampleRateHertz != null && message.hasOwnProperty("sampleRateHertz")) @@ -1693,12 +1768,24 @@ if (message.languageCode != null && message.hasOwnProperty("languageCode")) if (!$util.isString(message.languageCode)) return "languageCode: string expected"; + if (message.alternativeLanguageCodes != null && message.hasOwnProperty("alternativeLanguageCodes")) { + if (!Array.isArray(message.alternativeLanguageCodes)) + return "alternativeLanguageCodes: array expected"; + for (var i = 0; i < message.alternativeLanguageCodes.length; ++i) + if (!$util.isString(message.alternativeLanguageCodes[i])) + return "alternativeLanguageCodes: string[] expected"; + } if (message.maxAlternatives != null && message.hasOwnProperty("maxAlternatives")) if (!$util.isInteger(message.maxAlternatives)) return "maxAlternatives: integer expected"; if (message.profanityFilter != null && message.hasOwnProperty("profanityFilter")) if (typeof message.profanityFilter !== "boolean") return "profanityFilter: boolean expected"; + if (message.adaptation != null && message.hasOwnProperty("adaptation")) { + var error = $root.google.cloud.speech.v1.SpeechAdaptation.verify(message.adaptation); + if (error) + return "adaptation." + error; + } if (message.speechContexts != null && message.hasOwnProperty("speechContexts")) { if (!Array.isArray(message.speechContexts)) return "speechContexts: array expected"; @@ -1711,9 +1798,22 @@ if (message.enableWordTimeOffsets != null && message.hasOwnProperty("enableWordTimeOffsets")) if (typeof message.enableWordTimeOffsets !== "boolean") return "enableWordTimeOffsets: boolean expected"; + if (message.enableWordConfidence != null && message.hasOwnProperty("enableWordConfidence")) + if (typeof message.enableWordConfidence !== "boolean") + return "enableWordConfidence: boolean expected"; if (message.enableAutomaticPunctuation != null && message.hasOwnProperty("enableAutomaticPunctuation")) if (typeof message.enableAutomaticPunctuation !== "boolean") return "enableAutomaticPunctuation: boolean expected"; + if (message.enableSpokenPunctuation != null && message.hasOwnProperty("enableSpokenPunctuation")) { + var error = $root.google.protobuf.BoolValue.verify(message.enableSpokenPunctuation); + if (error) + return "enableSpokenPunctuation." + error; + } + if (message.enableSpokenEmojis != null && message.hasOwnProperty("enableSpokenEmojis")) { + var error = $root.google.protobuf.BoolValue.verify(message.enableSpokenEmojis); + if (error) + return "enableSpokenEmojis." + error; + } if (message.diarizationConfig != null && message.hasOwnProperty("diarizationConfig")) { var error = $root.google.cloud.speech.v1.SpeakerDiarizationConfig.verify(message.diarizationConfig); if (error) @@ -1778,6 +1878,10 @@ case 7: message.encoding = 7; break; + case "WEBM_OPUS": + case 9: + message.encoding = 9; + break; } if (object.sampleRateHertz != null) message.sampleRateHertz = object.sampleRateHertz | 0; @@ -1787,10 +1891,22 @@ message.enableSeparateRecognitionPerChannel = Boolean(object.enableSeparateRecognitionPerChannel); if (object.languageCode != null) message.languageCode = String(object.languageCode); + if (object.alternativeLanguageCodes) { + if (!Array.isArray(object.alternativeLanguageCodes)) + throw TypeError(".google.cloud.speech.v1.RecognitionConfig.alternativeLanguageCodes: array expected"); + message.alternativeLanguageCodes = []; + for (var i = 0; i < object.alternativeLanguageCodes.length; ++i) + message.alternativeLanguageCodes[i] = String(object.alternativeLanguageCodes[i]); + } if (object.maxAlternatives != null) message.maxAlternatives = object.maxAlternatives | 0; if (object.profanityFilter != null) message.profanityFilter = Boolean(object.profanityFilter); + if (object.adaptation != null) { + if (typeof object.adaptation !== "object") + throw TypeError(".google.cloud.speech.v1.RecognitionConfig.adaptation: object expected"); + message.adaptation = $root.google.cloud.speech.v1.SpeechAdaptation.fromObject(object.adaptation); + } if (object.speechContexts) { if (!Array.isArray(object.speechContexts)) throw TypeError(".google.cloud.speech.v1.RecognitionConfig.speechContexts: array expected"); @@ -1803,8 +1919,20 @@ } if (object.enableWordTimeOffsets != null) message.enableWordTimeOffsets = Boolean(object.enableWordTimeOffsets); + if (object.enableWordConfidence != null) + message.enableWordConfidence = Boolean(object.enableWordConfidence); if (object.enableAutomaticPunctuation != null) message.enableAutomaticPunctuation = Boolean(object.enableAutomaticPunctuation); + if (object.enableSpokenPunctuation != null) { + if (typeof object.enableSpokenPunctuation !== "object") + throw TypeError(".google.cloud.speech.v1.RecognitionConfig.enableSpokenPunctuation: object expected"); + message.enableSpokenPunctuation = $root.google.protobuf.BoolValue.fromObject(object.enableSpokenPunctuation); + } + if (object.enableSpokenEmojis != null) { + if (typeof object.enableSpokenEmojis !== "object") + throw TypeError(".google.cloud.speech.v1.RecognitionConfig.enableSpokenEmojis: object expected"); + message.enableSpokenEmojis = $root.google.protobuf.BoolValue.fromObject(object.enableSpokenEmojis); + } if (object.diarizationConfig != null) { if (typeof object.diarizationConfig !== "object") throw TypeError(".google.cloud.speech.v1.RecognitionConfig.diarizationConfig: object expected"); @@ -1835,8 +1963,10 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.speechContexts = []; + object.alternativeLanguageCodes = []; + } if (options.defaults) { object.encoding = options.enums === String ? "ENCODING_UNSPECIFIED" : 0; object.sampleRateHertz = 0; @@ -1850,7 +1980,11 @@ object.enableSeparateRecognitionPerChannel = false; object.model = ""; object.useEnhanced = false; + object.enableWordConfidence = false; object.diarizationConfig = null; + object.adaptation = null; + object.enableSpokenPunctuation = null; + object.enableSpokenEmojis = null; } if (message.encoding != null && message.hasOwnProperty("encoding")) object.encoding = options.enums === String ? $root.google.cloud.speech.v1.RecognitionConfig.AudioEncoding[message.encoding] : message.encoding; @@ -1881,8 +2015,21 @@ object.model = message.model; if (message.useEnhanced != null && message.hasOwnProperty("useEnhanced")) object.useEnhanced = message.useEnhanced; + if (message.enableWordConfidence != null && message.hasOwnProperty("enableWordConfidence")) + object.enableWordConfidence = message.enableWordConfidence; + if (message.alternativeLanguageCodes && message.alternativeLanguageCodes.length) { + object.alternativeLanguageCodes = []; + for (var j = 0; j < message.alternativeLanguageCodes.length; ++j) + object.alternativeLanguageCodes[j] = message.alternativeLanguageCodes[j]; + } if (message.diarizationConfig != null && message.hasOwnProperty("diarizationConfig")) object.diarizationConfig = $root.google.cloud.speech.v1.SpeakerDiarizationConfig.toObject(message.diarizationConfig, options); + if (message.adaptation != null && message.hasOwnProperty("adaptation")) + object.adaptation = $root.google.cloud.speech.v1.SpeechAdaptation.toObject(message.adaptation, options); + if (message.enableSpokenPunctuation != null && message.hasOwnProperty("enableSpokenPunctuation")) + 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); return object; }; @@ -1909,6 +2056,7 @@ * @property {number} AMR_WB=5 AMR_WB value * @property {number} OGG_OPUS=6 OGG_OPUS value * @property {number} SPEEX_WITH_HEADER_BYTE=7 SPEEX_WITH_HEADER_BYTE value + * @property {number} WEBM_OPUS=9 WEBM_OPUS value */ RecognitionConfig.AudioEncoding = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -1920,6 +2068,7 @@ values[valuesById[5] = "AMR_WB"] = 5; values[valuesById[6] = "OGG_OPUS"] = 6; values[valuesById[7] = "SPEEX_WITH_HEADER_BYTE"] = 7; + values[valuesById[9] = "WEBM_OPUS"] = 9; return values; })(); @@ -2742,6 +2891,7 @@ * @memberof google.cloud.speech.v1 * @interface ISpeechContext * @property {Array.|null} [phrases] SpeechContext phrases + * @property {number|null} [boost] SpeechContext boost */ /** @@ -2768,6 +2918,14 @@ */ SpeechContext.prototype.phrases = $util.emptyArray; + /** + * SpeechContext boost. + * @member {number} boost + * @memberof google.cloud.speech.v1.SpeechContext + * @instance + */ + SpeechContext.prototype.boost = 0; + /** * Creates a new SpeechContext instance using the specified properties. * @function create @@ -2795,6 +2953,8 @@ if (message.phrases != null && message.phrases.length) for (var i = 0; i < message.phrases.length; ++i) writer.uint32(/* id 1, wireType 2 =*/10).string(message.phrases[i]); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.boost); return writer; }; @@ -2834,6 +2994,9 @@ message.phrases = []; message.phrases.push(reader.string()); break; + case 4: + message.boost = reader.float(); + break; default: reader.skipType(tag & 7); break; @@ -2876,6 +3039,9 @@ if (!$util.isString(message.phrases[i])) return "phrases: string[] expected"; } + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; return null; }; @@ -2898,6 +3064,8 @@ for (var i = 0; i < object.phrases.length; ++i) message.phrases[i] = String(object.phrases[i]); } + if (object.boost != null) + message.boost = Number(object.boost); return message; }; @@ -2916,11 +3084,15 @@ var object = {}; if (options.arrays || options.defaults) object.phrases = []; + if (options.defaults) + object.boost = 0; if (message.phrases && message.phrases.length) { object.phrases = []; for (var j = 0; j < message.phrases.length; ++j) object.phrases[j] = message.phrases[j]; } + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; return object; }; @@ -3418,6 +3590,8 @@ * @interface ILongRunningRecognizeResponse * @property {Array.|null} [results] LongRunningRecognizeResponse results * @property {google.protobuf.IDuration|null} [totalBilledTime] LongRunningRecognizeResponse totalBilledTime + * @property {google.cloud.speech.v1.ITranscriptOutputConfig|null} [outputConfig] LongRunningRecognizeResponse outputConfig + * @property {google.rpc.IStatus|null} [outputError] LongRunningRecognizeResponse outputError */ /** @@ -3452,6 +3626,22 @@ */ LongRunningRecognizeResponse.prototype.totalBilledTime = null; + /** + * LongRunningRecognizeResponse outputConfig. + * @member {google.cloud.speech.v1.ITranscriptOutputConfig|null|undefined} outputConfig + * @memberof google.cloud.speech.v1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.outputConfig = null; + + /** + * LongRunningRecognizeResponse outputError. + * @member {google.rpc.IStatus|null|undefined} outputError + * @memberof google.cloud.speech.v1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.outputError = null; + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @function create @@ -3481,6 +3671,10 @@ $root.google.cloud.speech.v1.SpeechRecognitionResult.encode(message.results[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.totalBilledTime != null && Object.hasOwnProperty.call(message, "totalBilledTime")) $root.google.protobuf.Duration.encode(message.totalBilledTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.outputConfig != null && Object.hasOwnProperty.call(message, "outputConfig")) + $root.google.cloud.speech.v1.TranscriptOutputConfig.encode(message.outputConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.outputError != null && Object.hasOwnProperty.call(message, "outputError")) + $root.google.rpc.Status.encode(message.outputError, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); return writer; }; @@ -3523,6 +3717,12 @@ case 3: message.totalBilledTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; + case 6: + message.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.decode(reader, reader.uint32()); + break; + case 7: + message.outputError = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -3572,6 +3772,16 @@ if (error) return "totalBilledTime." + error; } + if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) { + var error = $root.google.cloud.speech.v1.TranscriptOutputConfig.verify(message.outputConfig); + if (error) + return "outputConfig." + error; + } + if (message.outputError != null && message.hasOwnProperty("outputError")) { + var error = $root.google.rpc.Status.verify(message.outputError); + if (error) + return "outputError." + error; + } return null; }; @@ -3602,6 +3812,16 @@ throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeResponse.totalBilledTime: object expected"); message.totalBilledTime = $root.google.protobuf.Duration.fromObject(object.totalBilledTime); } + if (object.outputConfig != null) { + if (typeof object.outputConfig !== "object") + throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeResponse.outputConfig: object expected"); + message.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.fromObject(object.outputConfig); + } + if (object.outputError != null) { + if (typeof object.outputError !== "object") + throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeResponse.outputError: object expected"); + message.outputError = $root.google.rpc.Status.fromObject(object.outputError); + } return message; }; @@ -3620,8 +3840,11 @@ var object = {}; if (options.arrays || options.defaults) object.results = []; - if (options.defaults) + if (options.defaults) { object.totalBilledTime = null; + object.outputConfig = null; + object.outputError = null; + } if (message.results && message.results.length) { object.results = []; for (var j = 0; j < message.results.length; ++j) @@ -3629,6 +3852,10 @@ } if (message.totalBilledTime != null && message.hasOwnProperty("totalBilledTime")) object.totalBilledTime = $root.google.protobuf.Duration.toObject(message.totalBilledTime, options); + if (message.outputConfig != null && message.hasOwnProperty("outputConfig")) + object.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.toObject(message.outputConfig, options); + if (message.outputError != null && message.hasOwnProperty("outputError")) + object.outputError = $root.google.rpc.Status.toObject(message.outputError, options); return object; }; @@ -4556,6 +4783,8 @@ * @interface ISpeechRecognitionResult * @property {Array.|null} [alternatives] SpeechRecognitionResult alternatives * @property {number|null} [channelTag] SpeechRecognitionResult channelTag + * @property {google.protobuf.IDuration|null} [resultEndTime] SpeechRecognitionResult resultEndTime + * @property {string|null} [languageCode] SpeechRecognitionResult languageCode */ /** @@ -4590,6 +4819,22 @@ */ SpeechRecognitionResult.prototype.channelTag = 0; + /** + * SpeechRecognitionResult resultEndTime. + * @member {google.protobuf.IDuration|null|undefined} resultEndTime + * @memberof google.cloud.speech.v1.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.resultEndTime = null; + + /** + * SpeechRecognitionResult languageCode. + * @member {string} languageCode + * @memberof google.cloud.speech.v1.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.languageCode = ""; + /** * Creates a new SpeechRecognitionResult instance using the specified properties. * @function create @@ -4619,6 +4864,10 @@ $root.google.cloud.speech.v1.SpeechRecognitionAlternative.encode(message.alternatives[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.channelTag != null && Object.hasOwnProperty.call(message, "channelTag")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.channelTag); + if (message.resultEndTime != null && Object.hasOwnProperty.call(message, "resultEndTime")) + $root.google.protobuf.Duration.encode(message.resultEndTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.languageCode); return writer; }; @@ -4661,6 +4910,12 @@ case 2: message.channelTag = reader.int32(); break; + case 4: + message.resultEndTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + case 5: + message.languageCode = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -4708,6 +4963,14 @@ if (message.channelTag != null && message.hasOwnProperty("channelTag")) if (!$util.isInteger(message.channelTag)) return "channelTag: integer expected"; + if (message.resultEndTime != null && message.hasOwnProperty("resultEndTime")) { + var error = $root.google.protobuf.Duration.verify(message.resultEndTime); + if (error) + return "resultEndTime." + error; + } + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; return null; }; @@ -4735,6 +4998,13 @@ } if (object.channelTag != null) message.channelTag = object.channelTag | 0; + if (object.resultEndTime != null) { + if (typeof object.resultEndTime !== "object") + throw TypeError(".google.cloud.speech.v1.SpeechRecognitionResult.resultEndTime: object expected"); + message.resultEndTime = $root.google.protobuf.Duration.fromObject(object.resultEndTime); + } + if (object.languageCode != null) + message.languageCode = String(object.languageCode); return message; }; @@ -4753,8 +5023,11 @@ var object = {}; if (options.arrays || options.defaults) object.alternatives = []; - if (options.defaults) + if (options.defaults) { object.channelTag = 0; + object.resultEndTime = null; + object.languageCode = ""; + } if (message.alternatives && message.alternatives.length) { object.alternatives = []; for (var j = 0; j < message.alternatives.length; ++j) @@ -4762,6 +5035,10 @@ } if (message.channelTag != null && message.hasOwnProperty("channelTag")) object.channelTag = message.channelTag; + if (message.resultEndTime != null && message.hasOwnProperty("resultEndTime")) + object.resultEndTime = $root.google.protobuf.Duration.toObject(message.resultEndTime, options); + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; return object; }; @@ -5042,6 +5319,7 @@ * @property {google.protobuf.IDuration|null} [startTime] WordInfo startTime * @property {google.protobuf.IDuration|null} [endTime] WordInfo endTime * @property {string|null} [word] WordInfo word + * @property {number|null} [confidence] WordInfo confidence * @property {number|null} [speakerTag] WordInfo speakerTag */ @@ -5084,6 +5362,14 @@ */ WordInfo.prototype.word = ""; + /** + * WordInfo confidence. + * @member {number} confidence + * @memberof google.cloud.speech.v1.WordInfo + * @instance + */ + WordInfo.prototype.confidence = 0; + /** * WordInfo speakerTag. * @member {number} speakerTag @@ -5122,6 +5408,8 @@ $root.google.protobuf.Duration.encode(message.endTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.word != null && Object.hasOwnProperty.call(message, "word")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.word); + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.confidence); if (message.speakerTag != null && Object.hasOwnProperty.call(message, "speakerTag")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.speakerTag); return writer; @@ -5167,6 +5455,9 @@ case 3: message.word = reader.string(); break; + case 4: + message.confidence = reader.float(); + break; case 5: message.speakerTag = reader.int32(); break; @@ -5218,6 +5509,9 @@ if (message.word != null && message.hasOwnProperty("word")) if (!$util.isString(message.word)) return "word: string expected"; + if (message.confidence != null && message.hasOwnProperty("confidence")) + if (typeof message.confidence !== "number") + return "confidence: number expected"; if (message.speakerTag != null && message.hasOwnProperty("speakerTag")) if (!$util.isInteger(message.speakerTag)) return "speakerTag: integer expected"; @@ -5241,60 +5535,1260 @@ throw TypeError(".google.cloud.speech.v1.WordInfo.startTime: object expected"); message.startTime = $root.google.protobuf.Duration.fromObject(object.startTime); } - if (object.endTime != null) { - if (typeof object.endTime !== "object") - throw TypeError(".google.cloud.speech.v1.WordInfo.endTime: object expected"); - message.endTime = $root.google.protobuf.Duration.fromObject(object.endTime); + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.speech.v1.WordInfo.endTime: object expected"); + message.endTime = $root.google.protobuf.Duration.fromObject(object.endTime); + } + if (object.word != null) + message.word = String(object.word); + if (object.confidence != null) + message.confidence = Number(object.confidence); + if (object.speakerTag != null) + message.speakerTag = object.speakerTag | 0; + return message; + }; + + /** + * Creates a plain object from a WordInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.WordInfo + * @static + * @param {google.cloud.speech.v1.WordInfo} message WordInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WordInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.word = ""; + object.confidence = 0; + object.speakerTag = 0; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Duration.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Duration.toObject(message.endTime, options); + if (message.word != null && message.hasOwnProperty("word")) + object.word = message.word; + if (message.confidence != null && message.hasOwnProperty("confidence")) + object.confidence = options.json && !isFinite(message.confidence) ? String(message.confidence) : message.confidence; + if (message.speakerTag != null && message.hasOwnProperty("speakerTag")) + object.speakerTag = message.speakerTag; + return object; + }; + + /** + * Converts this WordInfo to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.WordInfo + * @instance + * @returns {Object.} JSON object + */ + WordInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WordInfo; + })(); + + v1.CustomClass = (function() { + + /** + * Properties of a CustomClass. + * @memberof google.cloud.speech.v1 + * @interface ICustomClass + * @property {string|null} [name] CustomClass name + * @property {string|null} [customClassId] CustomClass customClassId + * @property {Array.|null} [items] CustomClass items + */ + + /** + * Constructs a new CustomClass. + * @memberof google.cloud.speech.v1 + * @classdesc Represents a CustomClass. + * @implements ICustomClass + * @constructor + * @param {google.cloud.speech.v1.ICustomClass=} [properties] Properties to set + */ + function CustomClass(properties) { + this.items = []; + 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]]; + } + + /** + * CustomClass name. + * @member {string} name + * @memberof google.cloud.speech.v1.CustomClass + * @instance + */ + CustomClass.prototype.name = ""; + + /** + * CustomClass customClassId. + * @member {string} customClassId + * @memberof google.cloud.speech.v1.CustomClass + * @instance + */ + CustomClass.prototype.customClassId = ""; + + /** + * CustomClass items. + * @member {Array.} items + * @memberof google.cloud.speech.v1.CustomClass + * @instance + */ + CustomClass.prototype.items = $util.emptyArray; + + /** + * Creates a new CustomClass instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {google.cloud.speech.v1.ICustomClass=} [properties] Properties to set + * @returns {google.cloud.speech.v1.CustomClass} CustomClass instance + */ + CustomClass.create = function create(properties) { + return new CustomClass(properties); + }; + + /** + * Encodes the specified CustomClass message. Does not implicitly {@link google.cloud.speech.v1.CustomClass.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {google.cloud.speech.v1.ICustomClass} message CustomClass message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomClass.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.customClassId != null && Object.hasOwnProperty.call(message, "customClassId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.customClassId); + if (message.items != null && message.items.length) + for (var i = 0; i < message.items.length; ++i) + $root.google.cloud.speech.v1.CustomClass.ClassItem.encode(message.items[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CustomClass message, length delimited. Does not implicitly {@link google.cloud.speech.v1.CustomClass.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {google.cloud.speech.v1.ICustomClass} message CustomClass message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomClass.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomClass message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.CustomClass + * @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.CustomClass} CustomClass + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomClass.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.CustomClass(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.customClassId = reader.string(); + break; + case 3: + if (!(message.items && message.items.length)) + message.items = []; + message.items.push($root.google.cloud.speech.v1.CustomClass.ClassItem.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomClass message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.CustomClass} CustomClass + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomClass.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomClass message. + * @function verify + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomClass.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + if (!$util.isString(message.customClassId)) + return "customClassId: string expected"; + if (message.items != null && message.hasOwnProperty("items")) { + if (!Array.isArray(message.items)) + return "items: array expected"; + for (var i = 0; i < message.items.length; ++i) { + var error = $root.google.cloud.speech.v1.CustomClass.ClassItem.verify(message.items[i]); + if (error) + return "items." + error; + } + } + return null; + }; + + /** + * Creates a CustomClass message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.CustomClass} CustomClass + */ + CustomClass.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.CustomClass) + return object; + var message = new $root.google.cloud.speech.v1.CustomClass(); + if (object.name != null) + message.name = String(object.name); + if (object.customClassId != null) + message.customClassId = String(object.customClassId); + if (object.items) { + if (!Array.isArray(object.items)) + throw TypeError(".google.cloud.speech.v1.CustomClass.items: array expected"); + message.items = []; + for (var i = 0; i < object.items.length; ++i) { + if (typeof object.items[i] !== "object") + throw TypeError(".google.cloud.speech.v1.CustomClass.items: object expected"); + message.items[i] = $root.google.cloud.speech.v1.CustomClass.ClassItem.fromObject(object.items[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CustomClass message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.CustomClass + * @static + * @param {google.cloud.speech.v1.CustomClass} message CustomClass + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomClass.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.items = []; + if (options.defaults) { + object.name = ""; + object.customClassId = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + object.customClassId = message.customClassId; + if (message.items && message.items.length) { + object.items = []; + for (var j = 0; j < message.items.length; ++j) + object.items[j] = $root.google.cloud.speech.v1.CustomClass.ClassItem.toObject(message.items[j], options); + } + return object; + }; + + /** + * Converts this CustomClass to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.CustomClass + * @instance + * @returns {Object.} JSON object + */ + CustomClass.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + CustomClass.ClassItem = (function() { + + /** + * Properties of a ClassItem. + * @memberof google.cloud.speech.v1.CustomClass + * @interface IClassItem + * @property {string|null} [value] ClassItem value + */ + + /** + * Constructs a new ClassItem. + * @memberof google.cloud.speech.v1.CustomClass + * @classdesc Represents a ClassItem. + * @implements IClassItem + * @constructor + * @param {google.cloud.speech.v1.CustomClass.IClassItem=} [properties] Properties to set + */ + function ClassItem(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]]; + } + + /** + * ClassItem value. + * @member {string} value + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @instance + */ + ClassItem.prototype.value = ""; + + /** + * Creates a new ClassItem instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v1.CustomClass.IClassItem=} [properties] Properties to set + * @returns {google.cloud.speech.v1.CustomClass.ClassItem} ClassItem instance + */ + ClassItem.create = function create(properties) { + return new ClassItem(properties); + }; + + /** + * Encodes the specified ClassItem message. Does not implicitly {@link google.cloud.speech.v1.CustomClass.ClassItem.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v1.CustomClass.IClassItem} message ClassItem message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClassItem.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.value); + return writer; + }; + + /** + * Encodes the specified ClassItem message, length delimited. Does not implicitly {@link google.cloud.speech.v1.CustomClass.ClassItem.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v1.CustomClass.IClassItem} message ClassItem message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClassItem.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClassItem message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @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.CustomClass.ClassItem} ClassItem + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClassItem.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.CustomClass.ClassItem(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClassItem message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.CustomClass.ClassItem} ClassItem + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClassItem.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClassItem message. + * @function verify + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClassItem.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates a ClassItem message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.CustomClass.ClassItem} ClassItem + */ + ClassItem.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.CustomClass.ClassItem) + return object; + var message = new $root.google.cloud.speech.v1.CustomClass.ClassItem(); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a ClassItem message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v1.CustomClass.ClassItem} message ClassItem + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClassItem.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = ""; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this ClassItem to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.CustomClass.ClassItem + * @instance + * @returns {Object.} JSON object + */ + ClassItem.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ClassItem; + })(); + + return CustomClass; + })(); + + v1.PhraseSet = (function() { + + /** + * Properties of a PhraseSet. + * @memberof google.cloud.speech.v1 + * @interface IPhraseSet + * @property {string|null} [name] PhraseSet name + * @property {Array.|null} [phrases] PhraseSet phrases + * @property {number|null} [boost] PhraseSet boost + */ + + /** + * Constructs a new PhraseSet. + * @memberof google.cloud.speech.v1 + * @classdesc Represents a PhraseSet. + * @implements IPhraseSet + * @constructor + * @param {google.cloud.speech.v1.IPhraseSet=} [properties] Properties to set + */ + function PhraseSet(properties) { + this.phrases = []; + 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]]; + } + + /** + * PhraseSet name. + * @member {string} name + * @memberof google.cloud.speech.v1.PhraseSet + * @instance + */ + PhraseSet.prototype.name = ""; + + /** + * PhraseSet phrases. + * @member {Array.} phrases + * @memberof google.cloud.speech.v1.PhraseSet + * @instance + */ + PhraseSet.prototype.phrases = $util.emptyArray; + + /** + * PhraseSet boost. + * @member {number} boost + * @memberof google.cloud.speech.v1.PhraseSet + * @instance + */ + PhraseSet.prototype.boost = 0; + + /** + * Creates a new PhraseSet instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {google.cloud.speech.v1.IPhraseSet=} [properties] Properties to set + * @returns {google.cloud.speech.v1.PhraseSet} PhraseSet instance + */ + PhraseSet.create = function create(properties) { + return new PhraseSet(properties); + }; + + /** + * Encodes the specified PhraseSet message. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {google.cloud.speech.v1.IPhraseSet} message PhraseSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PhraseSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.phrases != null && message.phrases.length) + for (var i = 0; i < message.phrases.length; ++i) + $root.google.cloud.speech.v1.PhraseSet.Phrase.encode(message.phrases[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.boost); + return writer; + }; + + /** + * Encodes the specified PhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {google.cloud.speech.v1.IPhraseSet} message PhraseSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PhraseSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PhraseSet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.PhraseSet + * @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.PhraseSet} PhraseSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PhraseSet.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.PhraseSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + if (!(message.phrases && message.phrases.length)) + message.phrases = []; + message.phrases.push($root.google.cloud.speech.v1.PhraseSet.Phrase.decode(reader, reader.uint32())); + break; + case 4: + message.boost = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PhraseSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.PhraseSet} PhraseSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PhraseSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PhraseSet message. + * @function verify + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PhraseSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.phrases != null && message.hasOwnProperty("phrases")) { + if (!Array.isArray(message.phrases)) + return "phrases: array expected"; + for (var i = 0; i < message.phrases.length; ++i) { + var error = $root.google.cloud.speech.v1.PhraseSet.Phrase.verify(message.phrases[i]); + if (error) + return "phrases." + error; + } + } + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + return null; + }; + + /** + * Creates a PhraseSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.PhraseSet} PhraseSet + */ + PhraseSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.PhraseSet) + return object; + var message = new $root.google.cloud.speech.v1.PhraseSet(); + if (object.name != null) + message.name = String(object.name); + if (object.phrases) { + if (!Array.isArray(object.phrases)) + throw TypeError(".google.cloud.speech.v1.PhraseSet.phrases: array expected"); + message.phrases = []; + for (var i = 0; i < object.phrases.length; ++i) { + if (typeof object.phrases[i] !== "object") + throw TypeError(".google.cloud.speech.v1.PhraseSet.phrases: object expected"); + message.phrases[i] = $root.google.cloud.speech.v1.PhraseSet.Phrase.fromObject(object.phrases[i]); + } + } + if (object.boost != null) + message.boost = Number(object.boost); + return message; + }; + + /** + * Creates a plain object from a PhraseSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.PhraseSet + * @static + * @param {google.cloud.speech.v1.PhraseSet} message PhraseSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PhraseSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.phrases = []; + if (options.defaults) { + object.name = ""; + object.boost = 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.phrases && message.phrases.length) { + object.phrases = []; + for (var j = 0; j < message.phrases.length; ++j) + object.phrases[j] = $root.google.cloud.speech.v1.PhraseSet.Phrase.toObject(message.phrases[j], options); + } + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + return object; + }; + + /** + * Converts this PhraseSet to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.PhraseSet + * @instance + * @returns {Object.} JSON object + */ + PhraseSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + PhraseSet.Phrase = (function() { + + /** + * Properties of a Phrase. + * @memberof google.cloud.speech.v1.PhraseSet + * @interface IPhrase + * @property {string|null} [value] Phrase value + * @property {number|null} [boost] Phrase boost + */ + + /** + * Constructs a new Phrase. + * @memberof google.cloud.speech.v1.PhraseSet + * @classdesc Represents a Phrase. + * @implements IPhrase + * @constructor + * @param {google.cloud.speech.v1.PhraseSet.IPhrase=} [properties] Properties to set + */ + function Phrase(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]]; + } + + /** + * Phrase value. + * @member {string} value + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @instance + */ + Phrase.prototype.value = ""; + + /** + * Phrase boost. + * @member {number} boost + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @instance + */ + Phrase.prototype.boost = 0; + + /** + * Creates a new Phrase instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v1.PhraseSet.IPhrase=} [properties] Properties to set + * @returns {google.cloud.speech.v1.PhraseSet.Phrase} Phrase instance + */ + Phrase.create = function create(properties) { + return new Phrase(properties); + }; + + /** + * Encodes the specified Phrase message. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.Phrase.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v1.PhraseSet.IPhrase} message Phrase message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Phrase.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.value); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.boost); + return writer; + }; + + /** + * Encodes the specified Phrase message, length delimited. Does not implicitly {@link google.cloud.speech.v1.PhraseSet.Phrase.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v1.PhraseSet.IPhrase} message Phrase message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Phrase.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Phrase message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @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.PhraseSet.Phrase} Phrase + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Phrase.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.PhraseSet.Phrase(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.string(); + break; + case 2: + message.boost = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Phrase message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.PhraseSet.Phrase} Phrase + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Phrase.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Phrase message. + * @function verify + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Phrase.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + return null; + }; + + /** + * Creates a Phrase message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.PhraseSet.Phrase} Phrase + */ + Phrase.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.PhraseSet.Phrase) + return object; + var message = new $root.google.cloud.speech.v1.PhraseSet.Phrase(); + if (object.value != null) + message.value = String(object.value); + if (object.boost != null) + message.boost = Number(object.boost); + return message; + }; + + /** + * Creates a plain object from a Phrase message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v1.PhraseSet.Phrase} message Phrase + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Phrase.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.boost = 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + return object; + }; + + /** + * Converts this Phrase to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.PhraseSet.Phrase + * @instance + * @returns {Object.} JSON object + */ + Phrase.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Phrase; + })(); + + return PhraseSet; + })(); + + v1.SpeechAdaptation = (function() { + + /** + * Properties of a SpeechAdaptation. + * @memberof google.cloud.speech.v1 + * @interface ISpeechAdaptation + * @property {Array.|null} [phraseSets] SpeechAdaptation phraseSets + * @property {Array.|null} [phraseSetReferences] SpeechAdaptation phraseSetReferences + * @property {Array.|null} [customClasses] SpeechAdaptation customClasses + */ + + /** + * Constructs a new SpeechAdaptation. + * @memberof google.cloud.speech.v1 + * @classdesc Represents a SpeechAdaptation. + * @implements ISpeechAdaptation + * @constructor + * @param {google.cloud.speech.v1.ISpeechAdaptation=} [properties] Properties to set + */ + function SpeechAdaptation(properties) { + this.phraseSets = []; + this.phraseSetReferences = []; + this.customClasses = []; + 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]]; + } + + /** + * SpeechAdaptation phraseSets. + * @member {Array.} phraseSets + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.phraseSets = $util.emptyArray; + + /** + * SpeechAdaptation phraseSetReferences. + * @member {Array.} phraseSetReferences + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.phraseSetReferences = $util.emptyArray; + + /** + * SpeechAdaptation customClasses. + * @member {Array.} customClasses + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.customClasses = $util.emptyArray; + + /** + * Creates a new SpeechAdaptation instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptation=} [properties] Properties to set + * @returns {google.cloud.speech.v1.SpeechAdaptation} SpeechAdaptation instance + */ + SpeechAdaptation.create = function create(properties) { + return new SpeechAdaptation(properties); + }; + + /** + * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptation} message SpeechAdaptation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSets != null && message.phraseSets.length) + for (var i = 0; i < message.phraseSets.length; ++i) + $root.google.cloud.speech.v1.PhraseSet.encode(message.phraseSets[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.phraseSetReferences != null && message.phraseSetReferences.length) + for (var i = 0; i < message.phraseSetReferences.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.phraseSetReferences[i]); + if (message.customClasses != null && message.customClasses.length) + for (var i = 0; i < message.customClasses.length; ++i) + $root.google.cloud.speech.v1.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptation} message SpeechAdaptation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeechAdaptation message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @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.SpeechAdaptation} SpeechAdaptation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptation.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.SpeechAdaptation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.phraseSets && message.phraseSets.length)) + message.phraseSets = []; + message.phraseSets.push($root.google.cloud.speech.v1.PhraseSet.decode(reader, reader.uint32())); + break; + case 2: + if (!(message.phraseSetReferences && message.phraseSetReferences.length)) + message.phraseSetReferences = []; + message.phraseSetReferences.push(reader.string()); + break; + case 3: + if (!(message.customClasses && message.customClasses.length)) + message.customClasses = []; + message.customClasses.push($root.google.cloud.speech.v1.CustomClass.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.SpeechAdaptation} SpeechAdaptation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechAdaptation message. + * @function verify + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechAdaptation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSets != null && message.hasOwnProperty("phraseSets")) { + if (!Array.isArray(message.phraseSets)) + return "phraseSets: array expected"; + for (var i = 0; i < message.phraseSets.length; ++i) { + var error = $root.google.cloud.speech.v1.PhraseSet.verify(message.phraseSets[i]); + if (error) + return "phraseSets." + error; + } + } + if (message.phraseSetReferences != null && message.hasOwnProperty("phraseSetReferences")) { + if (!Array.isArray(message.phraseSetReferences)) + return "phraseSetReferences: array expected"; + for (var i = 0; i < message.phraseSetReferences.length; ++i) + if (!$util.isString(message.phraseSetReferences[i])) + return "phraseSetReferences: string[] expected"; + } + if (message.customClasses != null && message.hasOwnProperty("customClasses")) { + if (!Array.isArray(message.customClasses)) + return "customClasses: array expected"; + for (var i = 0; i < message.customClasses.length; ++i) { + var error = $root.google.cloud.speech.v1.CustomClass.verify(message.customClasses[i]); + if (error) + return "customClasses." + error; + } + } + return null; + }; + + /** + * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.SpeechAdaptation} SpeechAdaptation + */ + SpeechAdaptation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.SpeechAdaptation) + return object; + var message = new $root.google.cloud.speech.v1.SpeechAdaptation(); + if (object.phraseSets) { + if (!Array.isArray(object.phraseSets)) + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.phraseSets: array expected"); + message.phraseSets = []; + for (var i = 0; i < object.phraseSets.length; ++i) { + if (typeof object.phraseSets[i] !== "object") + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.phraseSets: object expected"); + message.phraseSets[i] = $root.google.cloud.speech.v1.PhraseSet.fromObject(object.phraseSets[i]); + } + } + if (object.phraseSetReferences) { + if (!Array.isArray(object.phraseSetReferences)) + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.phraseSetReferences: array expected"); + message.phraseSetReferences = []; + for (var i = 0; i < object.phraseSetReferences.length; ++i) + message.phraseSetReferences[i] = String(object.phraseSetReferences[i]); + } + if (object.customClasses) { + if (!Array.isArray(object.customClasses)) + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.customClasses: array expected"); + message.customClasses = []; + for (var i = 0; i < object.customClasses.length; ++i) { + if (typeof object.customClasses[i] !== "object") + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.customClasses: object expected"); + message.customClasses[i] = $root.google.cloud.speech.v1.CustomClass.fromObject(object.customClasses[i]); + } } - if (object.word != null) - message.word = String(object.word); - if (object.speakerTag != null) - message.speakerTag = object.speakerTag | 0; return message; }; /** - * Creates a plain object from a WordInfo message. Also converts values to other types if specified. + * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.speech.v1.WordInfo + * @memberof google.cloud.speech.v1.SpeechAdaptation * @static - * @param {google.cloud.speech.v1.WordInfo} message WordInfo + * @param {google.cloud.speech.v1.SpeechAdaptation} message SpeechAdaptation * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - WordInfo.toObject = function toObject(message, options) { + SpeechAdaptation.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.startTime = null; - object.endTime = null; - object.word = ""; - object.speakerTag = 0; + if (options.arrays || options.defaults) { + object.phraseSets = []; + object.phraseSetReferences = []; + object.customClasses = []; + } + if (message.phraseSets && message.phraseSets.length) { + object.phraseSets = []; + for (var j = 0; j < message.phraseSets.length; ++j) + object.phraseSets[j] = $root.google.cloud.speech.v1.PhraseSet.toObject(message.phraseSets[j], options); + } + if (message.phraseSetReferences && message.phraseSetReferences.length) { + object.phraseSetReferences = []; + for (var j = 0; j < message.phraseSetReferences.length; ++j) + object.phraseSetReferences[j] = message.phraseSetReferences[j]; + } + if (message.customClasses && message.customClasses.length) { + object.customClasses = []; + for (var j = 0; j < message.customClasses.length; ++j) + object.customClasses[j] = $root.google.cloud.speech.v1.CustomClass.toObject(message.customClasses[j], options); } - if (message.startTime != null && message.hasOwnProperty("startTime")) - object.startTime = $root.google.protobuf.Duration.toObject(message.startTime, options); - if (message.endTime != null && message.hasOwnProperty("endTime")) - object.endTime = $root.google.protobuf.Duration.toObject(message.endTime, options); - if (message.word != null && message.hasOwnProperty("word")) - object.word = message.word; - if (message.speakerTag != null && message.hasOwnProperty("speakerTag")) - object.speakerTag = message.speakerTag; return object; }; /** - * Converts this WordInfo to JSON. + * Converts this SpeechAdaptation to JSON. * @function toJSON - * @memberof google.cloud.speech.v1.WordInfo + * @memberof google.cloud.speech.v1.SpeechAdaptation * @instance * @returns {Object.} JSON object */ - WordInfo.prototype.toJSON = function toJSON() { + SpeechAdaptation.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return WordInfo; + return SpeechAdaptation; })(); return v1; @@ -25842,10 +27336,234 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return Annotation; - })(); + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + protobuf.Timestamp = (function() { + + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|Long|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(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]]; + } + + /** + * Timestamp seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + /** + * Creates a new Timestamp instance using the specified properties. + * @function create + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + * @returns {google.protobuf.Timestamp} Timestamp instance + */ + Timestamp.create = function create(properties) { + return new Timestamp(properties); + }; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); + if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); + return writer; + }; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.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.protobuf.Timestamp(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64(); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Timestamp message. + * @function verify + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Timestamp.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) + return "seconds: integer|Long expected"; + if (message.nanos != null && message.hasOwnProperty("nanos")) + if (!$util.isInteger(message.nanos)) + return "nanos: integer expected"; + return null; + }; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object; + var message = new $root.google.protobuf.Timestamp(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; - return GeneratedCodeInfo; + return Timestamp; })(); protobuf.Any = (function() { @@ -26451,230 +28169,6 @@ return Empty; })(); - protobuf.Timestamp = (function() { - - /** - * Properties of a Timestamp. - * @memberof google.protobuf - * @interface ITimestamp - * @property {number|Long|null} [seconds] Timestamp seconds - * @property {number|null} [nanos] Timestamp nanos - */ - - /** - * Constructs a new Timestamp. - * @memberof google.protobuf - * @classdesc Represents a Timestamp. - * @implements ITimestamp - * @constructor - * @param {google.protobuf.ITimestamp=} [properties] Properties to set - */ - function Timestamp(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]]; - } - - /** - * Timestamp seconds. - * @member {number|Long} seconds - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Timestamp nanos. - * @member {number} nanos - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.nanos = 0; - - /** - * Creates a new Timestamp instance using the specified properties. - * @function create - * @memberof google.protobuf.Timestamp - * @static - * @param {google.protobuf.ITimestamp=} [properties] Properties to set - * @returns {google.protobuf.Timestamp} Timestamp instance - */ - Timestamp.create = function create(properties) { - return new Timestamp(properties); - }; - - /** - * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Timestamp - * @static - * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Timestamp.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) - writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); - if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); - return writer; - }; - - /** - * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Timestamp - * @static - * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Timestamp.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Timestamp message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Timestamp - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Timestamp} Timestamp - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Timestamp.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.protobuf.Timestamp(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.seconds = reader.int64(); - break; - case 2: - message.nanos = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Timestamp message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Timestamp - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Timestamp} Timestamp - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Timestamp.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Timestamp message. - * @function verify - * @memberof google.protobuf.Timestamp - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Timestamp.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.seconds != null && message.hasOwnProperty("seconds")) - if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) - return "seconds: integer|Long expected"; - if (message.nanos != null && message.hasOwnProperty("nanos")) - if (!$util.isInteger(message.nanos)) - return "nanos: integer expected"; - return null; - }; - - /** - * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Timestamp - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Timestamp} Timestamp - */ - Timestamp.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Timestamp) - return object; - var message = new $root.google.protobuf.Timestamp(); - if (object.seconds != null) - if ($util.Long) - (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; - else if (typeof object.seconds === "string") - message.seconds = parseInt(object.seconds, 10); - else if (typeof object.seconds === "number") - message.seconds = object.seconds; - else if (typeof object.seconds === "object") - message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); - if (object.nanos != null) - message.nanos = object.nanos | 0; - return message; - }; - - /** - * Creates a plain object from a Timestamp message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Timestamp - * @static - * @param {google.protobuf.Timestamp} message Timestamp - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Timestamp.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.seconds = options.longs === String ? "0" : 0; - object.nanos = 0; - } - if (message.seconds != null && message.hasOwnProperty("seconds")) - if (typeof message.seconds === "number") - object.seconds = options.longs === String ? String(message.seconds) : message.seconds; - else - object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; - if (message.nanos != null && message.hasOwnProperty("nanos")) - object.nanos = message.nanos; - return object; - }; - - /** - * Converts this Timestamp to JSON. - * @function toJSON - * @memberof google.protobuf.Timestamp - * @instance - * @returns {Object.} JSON object - */ - Timestamp.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Timestamp; - })(); - protobuf.DoubleValue = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index 54d77e94..1f530447 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -11,7 +11,7 @@ "cc_enable_arenas": true, "go_package": "google.golang.org/genproto/googleapis/cloud/speech/v1;speech", "java_multiple_files": true, - "java_outer_classname": "SpeechProto", + "java_outer_classname": "SpeechResourceProto", "java_package": "com.google.cloud.speech.v1", "objc_class_prefix": "GCS" }, @@ -200,6 +200,11 @@ "(google.api.field_behavior)": "REQUIRED" } }, + "alternativeLanguageCodes": { + "rule": "repeated", + "type": "string", + "id": 18 + }, "maxAlternatives": { "type": "int32", "id": 4 @@ -208,6 +213,10 @@ "type": "bool", "id": 5 }, + "adaptation": { + "type": "SpeechAdaptation", + "id": 20 + }, "speechContexts": { "rule": "repeated", "type": "SpeechContext", @@ -217,10 +226,22 @@ "type": "bool", "id": 8 }, + "enableWordConfidence": { + "type": "bool", + "id": 15 + }, "enableAutomaticPunctuation": { "type": "bool", "id": 11 }, + "enableSpokenPunctuation": { + "type": "google.protobuf.BoolValue", + "id": 22 + }, + "enableSpokenEmojis": { + "type": "google.protobuf.BoolValue", + "id": 23 + }, "diarizationConfig": { "type": "SpeakerDiarizationConfig", "id": 19 @@ -248,7 +269,8 @@ "AMR": 4, "AMR_WB": 5, "OGG_OPUS": 6, - "SPEEX_WITH_HEADER_BYTE": 7 + "SPEEX_WITH_HEADER_BYTE": 7, + "WEBM_OPUS": 9 } } } @@ -360,6 +382,10 @@ "rule": "repeated", "type": "string", "id": 1 + }, + "boost": { + "type": "float", + "id": 4 } } }, @@ -406,6 +432,14 @@ "totalBilledTime": { "type": "google.protobuf.Duration", "id": 3 + }, + "outputConfig": { + "type": "TranscriptOutputConfig", + "id": 6 + }, + "outputError": { + "type": "google.rpc.Status", + "id": 7 } } }, @@ -503,6 +537,17 @@ "channelTag": { "type": "int32", "id": 2 + }, + "resultEndTime": { + "type": "google.protobuf.Duration", + "id": 4 + }, + "languageCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } } } }, @@ -537,6 +582,10 @@ "type": "string", "id": 3 }, + "confidence": { + "type": "float", + "id": 4 + }, "speakerTag": { "type": "int32", "id": 5, @@ -545,6 +594,94 @@ } } } + }, + "CustomClass": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/CustomClass", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/customClasses/{custom_class}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "customClassId": { + "type": "string", + "id": 2 + }, + "items": { + "rule": "repeated", + "type": "ClassItem", + "id": 3 + } + }, + "nested": { + "ClassItem": { + "fields": { + "value": { + "type": "string", + "id": 1 + } + } + } + } + }, + "PhraseSet": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/PhraseSet", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/phraseSets/{phrase_set}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "phrases": { + "rule": "repeated", + "type": "Phrase", + "id": 2 + }, + "boost": { + "type": "float", + "id": 4 + } + }, + "nested": { + "Phrase": { + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "boost": { + "type": "float", + "id": 2 + } + } + } + } + }, + "SpeechAdaptation": { + "fields": { + "phraseSets": { + "rule": "repeated", + "type": "PhraseSet", + "id": 1 + }, + "phraseSetReferences": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + }, + "customClasses": { + "rule": "repeated", + "type": "CustomClass", + "id": 3 + } + } } } }, @@ -2796,6 +2933,18 @@ } } }, + "Timestamp": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, "Any": { "fields": { "type_url": { @@ -2823,18 +2972,6 @@ "Empty": { "fields": {} }, - "Timestamp": { - "fields": { - "seconds": { - "type": "int64", - "id": 1 - }, - "nanos": { - "type": "int32", - "id": 2 - } - } - }, "DoubleValue": { "fields": { "value": { diff --git a/src/v1/speech_client.ts b/src/v1/speech_client.ts index 1604879e..aeb1fedf 100644 --- a/src/v1/speech_client.ts +++ b/src/v1/speech_client.ts @@ -59,6 +59,7 @@ export class SpeechClient { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; operationsClient: gax.OperationsClient; speechStub?: Promise<{[name: string]: Function}>; @@ -157,6 +158,18 @@ export class SpeechClient { // Load the applicable protos. this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + customClassPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/customClasses/{custom_class}' + ), + phraseSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + ), + }; + // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { @@ -578,6 +591,113 @@ export class SpeechClient { protos.google.cloud.speech.v1.LongRunningRecognizeMetadata >; } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified customClass resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} custom_class + * @returns {string} Resource name string. + */ + customClassPath(project: string, location: string, customClass: string) { + return this.pathTemplates.customClassPathTemplate.render({ + project: project, + location: location, + custom_class: customClass, + }); + } + + /** + * Parse the project from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; + } + + /** + * Parse the location from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; + } + + /** + * Parse the custom_class from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the custom_class. + */ + matchCustomClassFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; + } + + /** + * Return a fully-qualified phraseSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} phrase_set + * @returns {string} Resource name string. + */ + phraseSetPath(project: string, location: string, phraseSet: string) { + return this.pathTemplates.phraseSetPathTemplate.render({ + project: project, + location: location, + phrase_set: phraseSet, + }); + } + + /** + * Parse the project from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; + } + + /** + * Parse the location from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; + } + + /** + * Parse the phrase_set from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the phrase_set. + */ + matchPhraseSetFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; + } /** * Terminate the gRPC channel and close the client. diff --git a/src/v1/speech_proto_list.json b/src/v1/speech_proto_list.json index ca50e618..4eaaefab 100644 --- a/src/v1/speech_proto_list.json +++ b/src/v1/speech_proto_list.json @@ -1,3 +1,4 @@ [ - "../../protos/google/cloud/speech/v1/cloud_speech.proto" + "../../protos/google/cloud/speech/v1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1/resource.proto" ] diff --git a/test/gapic_speech_v1.ts b/test/gapic_speech_v1.ts index 67c9b909..80fafbfc 100644 --- a/test/gapic_speech_v1.ts +++ b/test/gapic_speech_v1.ts @@ -512,4 +512,134 @@ describe('v1.SpeechClient', () => { ); }); }); + + describe('Path templates', () => { + describe('customClass', () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('phraseSet', () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); });