diff --git a/packages/google-cloud-speech/protos/google/cloud/speech/v2/cloud_speech.proto b/packages/google-cloud-speech/protos/google/cloud/speech/v2/cloud_speech.proto new file mode 100644 index 00000000000..a3512e316c4 --- /dev/null +++ b/packages/google-cloud-speech/protos/google/cloud/speech/v2/cloud_speech.proto @@ -0,0 +1,1965 @@ +// Copyright 2022 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.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v2;speech"; +option java_multiple_files = true; +option java_outer_classname = "CloudSpeechProto"; +option java_package = "com.google.cloud.speech.v2"; +option (google.api.resource_definition) = { + type: "cloudkms.googleapis.com/CryptoKey" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" +}; +option (google.api.resource_definition) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" +}; + +// Enables speech transcription and resource management. +service Speech { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Recognizer][google.cloud.speech.v2.Recognizer]. + rpc CreateRecognizer(CreateRecognizerRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/recognizers" + body: "recognizer" + }; + option (google.api.method_signature) = "parent,recognizer,recognizer_id"; + option (google.longrunning.operation_info) = { + response_type: "Recognizer" + metadata_type: "OperationMetadata" + }; + } + + // Lists Recognizers. + rpc ListRecognizers(ListRecognizersRequest) + returns (ListRecognizersResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/recognizers" + }; + option (google.api.method_signature) = "parent"; + } + + // Returns the requested + // [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with + // [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested recognizer doesn't + // exist. + rpc GetRecognizer(GetRecognizerRequest) returns (Recognizer) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/recognizers/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [Recognizer][google.cloud.speech.v2.Recognizer]. + rpc UpdateRecognizer(UpdateRecognizerRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{recognizer.name=projects/*/locations/*/recognizers/*}" + body: "recognizer" + }; + option (google.api.method_signature) = "recognizer,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Recognizer" + metadata_type: "OperationMetadata" + }; + } + + // Deletes the [Recognizer][google.cloud.speech.v2.Recognizer]. + rpc DeleteRecognizer(DeleteRecognizerRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/recognizers/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Recognizer" + metadata_type: "OperationMetadata" + }; + } + + // Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer]. + rpc UndeleteRecognizer(UndeleteRecognizerRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/recognizers/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Recognizer" + metadata_type: "OperationMetadata" + }; + } + + // Performs synchronous Speech recognition: receive results after all audio + // has been sent and processed. + rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { + option (google.api.http) = { + post: "/v2/{recognizer=projects/*/locations/*/recognizers/*}:recognize" + body: "*" + }; + option (google.api.method_signature) = + "recognizer,config,config_mask,content"; + option (google.api.method_signature) = "recognizer,config,config_mask,uri"; + } + + // Performs bidirectional streaming speech recognition: receive results while + // sending audio. This method is only available via the gRPC API (not REST). + rpc StreamingRecognize(stream StreamingRecognizeRequest) + returns (stream StreamingRecognizeResponse) {} + + // Performs batch asynchronous speech recognition: send a request with N + // audio files and receive a long running operation that can be polled to see + // when the transcriptions are finished. + rpc BatchRecognize(BatchRecognizeRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{recognizer=projects/*/locations/*/recognizers/*}:batchRecognize" + body: "*" + }; + option (google.api.method_signature) = + "recognizer,config,config_mask,files"; + option (google.longrunning.operation_info) = { + response_type: "BatchRecognizeResponse" + metadata_type: "OperationMetadata" + }; + } + + // Returns the requested [Config][google.cloud.speech.v2.Config]. + rpc GetConfig(GetConfigRequest) returns (Config) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/config}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [Config][google.cloud.speech.v2.Config]. + rpc UpdateConfig(UpdateConfigRequest) returns (Config) { + option (google.api.http) = { + patch: "/v2/{config.name=projects/*/locations/*/config}" + body: "config" + }; + option (google.api.method_signature) = "config,update_mask"; + } + + // Creates a [CustomClass][google.cloud.speech.v2.CustomClass]. + rpc CreateCustomClass(CreateCustomClassRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/customClasses" + body: "custom_class" + }; + option (google.api.method_signature) = + "parent,custom_class,custom_class_id"; + option (google.longrunning.operation_info) = { + response_type: "CustomClass" + metadata_type: "OperationMetadata" + }; + } + + // Lists CustomClasses. + rpc ListCustomClasses(ListCustomClassesRequest) + returns (ListCustomClassesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/customClasses" + }; + option (google.api.method_signature) = "parent"; + } + + // Returns the requested + // [CustomClass][google.cloud.speech.v2.CustomClass]. + rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [CustomClass][google.cloud.speech.v2.CustomClass]. + rpc UpdateCustomClass(UpdateCustomClassRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{custom_class.name=projects/*/locations/*/customClasses/*}" + body: "custom_class" + }; + option (google.api.method_signature) = "custom_class,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "CustomClass" + metadata_type: "OperationMetadata" + }; + } + + // Deletes the [CustomClass][google.cloud.speech.v2.CustomClass]. + rpc DeleteCustomClass(DeleteCustomClassRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "CustomClass" + metadata_type: "OperationMetadata" + }; + } + + // Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass]. + rpc UndeleteCustomClass(UndeleteCustomClassRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/customClasses/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "CustomClass" + metadata_type: "OperationMetadata" + }; + } + + // Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet]. + rpc CreatePhraseSet(CreatePhraseSetRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/phraseSets" + body: "phrase_set" + }; + option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; + option (google.longrunning.operation_info) = { + response_type: "PhraseSet" + metadata_type: "OperationMetadata" + }; + } + + // Lists PhraseSets. + rpc ListPhraseSets(ListPhraseSetsRequest) returns (ListPhraseSetsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/phraseSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Returns the requested + // [PhraseSet][google.cloud.speech.v2.PhraseSet]. + rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + rpc UpdatePhraseSet(UpdatePhraseSetRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{phrase_set.name=projects/*/locations/*/phraseSets/*}" + body: "phrase_set" + }; + option (google.api.method_signature) = "phrase_set,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "PhraseSet" + metadata_type: "OperationMetadata" + }; + } + + // Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + rpc DeletePhraseSet(DeletePhraseSetRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "PhraseSet" + metadata_type: "OperationMetadata" + }; + } + + // Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + rpc UndeletePhraseSet(UndeletePhraseSetRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/phraseSets/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "PhraseSet" + metadata_type: "OperationMetadata" + }; + } +} + +// Request message for the +// [CreateRecognizer][google.cloud.speech.v2.Speech.CreateRecognizer] method. +message CreateRecognizerRequest { + // Required. The Recognizer to create. + Recognizer recognizer = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set, validate the request and preview the Recognizer, but do not + // actually create it. + bool validate_only = 2; + + // The ID to use for the Recognizer, which will become the final component of + // the Recognizer's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-/. + string recognizer_id = 3; + + // Required. The project and location where this Recognizer will be created. + // The expected format is `projects/{project}/locations/{location}`. + string parent = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/Recognizer" + } + ]; +} + +// Represents the metadata of a long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation was last updated. + google.protobuf.Timestamp update_time = 2; + + // The resource path for the target of the operation. + string resource = 3; + + // The method that triggered the operation. + string method = 4; + + // The [KMS key + // name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which + // the content of the Operation is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 6 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // The [KMS key version + // name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) + // with which content of the Operation is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`. + string kms_key_version_name = 7 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + }]; + + // The request that spawned the Operation. + oneof request { + // The BatchRecognizeRequest that spawned the Operation. + BatchRecognizeRequest batch_recognize_request = 8; + + // The CreateRecognizerRequest that spawned the Operation. + CreateRecognizerRequest create_recognizer_request = 9; + + // The UpdateRecognizerRequest that spawned the Operation. + UpdateRecognizerRequest update_recognizer_request = 10; + + // The DeleteRecognizerRequest that spawned the Operation. + DeleteRecognizerRequest delete_recognizer_request = 11; + + // The UndeleteRecognizerRequest that spawned the Operation. + UndeleteRecognizerRequest undelete_recognizer_request = 12; + + // The CreateCustomClassRequest that spawned the Operation. + CreateCustomClassRequest create_custom_class_request = 13; + + // The UpdateCustomClassRequest that spawned the Operation. + UpdateCustomClassRequest update_custom_class_request = 14; + + // The DeleteCustomClassRequest that spawned the Operation. + DeleteCustomClassRequest delete_custom_class_request = 15; + + // The UndeleteCustomClassRequest that spawned the Operation. + UndeleteCustomClassRequest undelete_custom_class_request = 16; + + // The CreatePhraseSetRequest that spawned the Operation. + CreatePhraseSetRequest create_phrase_set_request = 17; + + // The UpdatePhraseSetRequest that spawned the Operation. + UpdatePhraseSetRequest update_phrase_set_request = 18; + + // The DeletePhraseSetRequest that spawned the Operation. + DeletePhraseSetRequest delete_phrase_set_request = 19; + + // The UndeletePhraseSetRequest that spawned the Operation. + UndeletePhraseSetRequest undelete_phrase_set_request = 20; + + // The UpdateConfigRequest that spawned the Operation. + UpdateConfigRequest update_config_request = 21; + } + + // The percent progress of the Operation. Values can range from 0-100. If the + // value is 100, then the operation is finished. + int32 progress_percent = 22; + + // Specific metadata per RPC + oneof metadata { + // Metadata specific to the BatchRecognize method. + BatchRecognizeMetadata batch_recognize_metadata = 23; + } +} + +// Request message for the +// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] method. +message ListRecognizersRequest { + // Required. The project and location of Recognizers to list. The expected + // format is `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of Recognizers to return. The service may return fewer + // than this value. If unspecified, at most 20 Recognizers will be returned. + // The maximum value is 20; values above 20 will be coerced to 20. + int32 page_size = 2; + + // A page token, received from a previous + // [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] must match + // the call that provided the page token. + string page_token = 3; + + // Whether, or not, to show resources that have been deleted. + bool show_deleted = 4; +} + +// Response message for the +// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] method. +message ListRecognizersResponse { + // The list of requested Recognizers. + repeated Recognizer recognizers = 1; + + // A token, which can be sent as + // [page_token][google.cloud.speech.v2.ListRecognizersRequest.page_token] to + // retrieve the next page. If this field is omitted, there are no subsequent + // pages. This token expires after 72 hours. + string next_page_token = 2; +} + +// Request message for the +// [GetRecognizer][google.cloud.speech.v2.Speech.GetRecognizer] method. +message GetRecognizerRequest { + // Required. The name of the Recognizer to retrieve. The expected format is + // `projects/{project}/locations/{location}/recognizers/{recognizer}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; +} + +// Request message for the +// [UpdateRecognizer][google.cloud.speech.v2.Speech.UpdateRecognizer] method. +message UpdateRecognizerRequest { + // Required. The Recognizer to update. + // + // The Recognizer's `name` field is used to identify the Recognizer to update. + // Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. + Recognizer recognizer = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to update. If empty, all non-default valued fields are + // considered for update. Use `*` to update the entire Recognizer resource. + google.protobuf.FieldMask update_mask = 2; + + // If set, validate the request and preview the updated Recognizer, but do not + // actually update it. + bool validate_only = 4; +} + +// Request message for the +// [DeleteRecognizer][google.cloud.speech.v2.Speech.DeleteRecognizer] method. +message DeleteRecognizerRequest { + // Required. The name of the Recognizer to delete. + // Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; + + // If set, validate the request and preview the deleted Recognizer, but do not + // actually delete it. + bool validate_only = 2; + + // If set to true, and the Recognizer is not found, the request will succeed + // and be a no-op (no Operation is recorded in this case). + bool allow_missing = 4; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 3; +} + +// Request message for the +// [UndeleteRecognizer][google.cloud.speech.v2.Speech.UndeleteRecognizer] +// method. +message UndeleteRecognizerRequest { + // Required. The name of the Recognizer to undelete. + // Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; + + // If set, validate the request and preview the undeleted Recognizer, but do + // not actually undelete it. + bool validate_only = 3; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 4; +} + +// A Recognizer message. Stores recognition configuration and metadata. +message Recognizer { + option (google.api.resource) = { + type: "speech.googleapis.com/Recognizer" + pattern: "projects/{project}/locations/{location}/recognizers/{recognizer}" + style: DECLARATIVE_FRIENDLY + }; + + // Set of states that define the lifecycle of a Recognizer. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // The Recognizer is active and ready for use. + ACTIVE = 2; + + // This Recognizer has been deleted. + DELETED = 4; + } + + // Output only. The resource name of the Recognizer. + // Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. System-assigned unique identifier for the Recognizer. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // User-settable, human-readable name for the Recognizer. Must be 63 + // characters or less. + string display_name = 3; + + // Required. Which model to use for recognition requests. Select the model + // best suited to your domain to get best results. + // + // Supported models: + // + // - `latest_long` + // + // Best for long form content like media or conversation. + // + // - `latest_short` + // + // Best for short form content like commands or single shot directed speech. + // When using this model, the service will stop transcribing audio after the + // first utterance is detected and completed. + // + // When using this model, + // [SEPARATE_RECOGNITION_PER_CHANNEL][google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode.SEPARATE_RECOGNITION_PER_CHANNEL] + // is not supported; multi-channel audio is accepted, but only the first + // channel will be processed and transcribed. + string model = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The language of the supplied audio as a + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. + // + // Supported languages: + // + // - `en-US` + // + // - `en-GB` + // + // - `fr-FR` + // + // If additional languages are provided, recognition result will contain + // recognition in the most likely language detected. The recognition result + // will include the language tag of the language detected in the audio. + // When you create or update a Recognizer, these values are + // stored in normalized BCP-47 form. For example, "en-us" is stored as + // "en-US". + repeated string language_codes = 17 [(google.api.field_behavior) = REQUIRED]; + + // Default configuration to use for requests with this Recognizer. + // This can be overwritten by inline configuration in the + // [RecognizeRequest.config][google.cloud.speech.v2.RecognizeRequest.config] + // field. + RecognitionConfig default_recognition_config = 6; + + // Allows users to store small amounts of arbitrary data. + // Both the key and the value must be 63 characters or less each. + // At most 100 annotations. + map annotations = 7; + + // Output only. The Recognizer lifecycle state. + State state = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The most recent time this Recognizer was modified. + google.protobuf.Timestamp update_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Recognizer was requested for deletion. + google.protobuf.Timestamp delete_time = 11 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Recognizer will be purged. + google.protobuf.Timestamp expire_time = 14 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. This checksum is computed by the server based on the value of + // other fields. This may be sent on update, undelete, and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether or not this Recognizer is in the process of being + // updated. + bool reconciling = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The [KMS key + // name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which + // the Recognizer is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 15 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; + + // Output only. The [KMS key version + // name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) + // with which the Recognizer is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`. + string kms_key_version_name = 16 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + } + ]; +} + +// Automatically detected decoding parameters. +// Supported for the following encodings: +// * WAV_LINEAR16: 16-bit signed little-endian PCM samples in a WAV container. +// * WAV_MULAW: 8-bit companded mulaw samples in a WAV container. +// * WAV_ALAW: 8-bit companded alaw samples in a WAV container. +// * RFC4867_5_AMR: AMR frames with an rfc4867.5 header. +// * RFC4867_5_AMRWB: AMR-WB frames with an rfc4867.5 header. +// * FLAC: FLAC frames in the "native FLAC" container format. +// * MP3: MPEG audio frames with optional (ignored) ID3 metadata. +// * OGG_OPUS: Opus audio frames in an Ogg container. +// * WEBM_OPUS: Opus audio frames in a WebM container. +message AutoDetectDecodingConfig {} + +// Explicitly specified decoding parameters. +message ExplicitDecodingConfig { + // Supported audio data encodings. + enum AudioEncoding { + // Default value. This value is unused. + AUDIO_ENCODING_UNSPECIFIED = 0; + + // Headerless 16-bit signed little-endian PCM samples. + LINEAR16 = 1; + + // Headerless 8-bit companded mulaw samples. + MULAW = 2; + + // Headerless 8-bit companded alaw samples. + ALAW = 3; + } + + // Required. Encoding of the audio data sent for recognition. + AudioEncoding encoding = 1 [(google.api.field_behavior) = REQUIRED]; + + // Sample rate in Hertz of the audio data sent for recognition. Valid + // values are: 8000-48000. 16000 is optimal. For best results, set the + // sampling rate of the audio source to 16000 Hz. If that's not possible, use + // the native sample rate of the audio source (instead of re-sampling). + // Supported for the following encodings: + // * LINEAR16: Headerless 16-bit signed little-endian PCM samples. + // * MULAW: Headerless 8-bit companded mulaw samples. + // * ALAW: Headerless 8-bit companded alaw samples. + int32 sample_rate_hertz = 2; + + // Number of channels present in the audio data sent for recognition. + // Supported for the following encodings: + // * LINEAR16: Headerless 16-bit signed little-endian PCM samples. + // * MULAW: Headerless 8-bit companded mulaw samples. + // * ALAW: Headerless 8-bit companded alaw samples. + int32 audio_channel_count = 3; +} + +// Configuration to enable speaker diarization. +message SpeakerDiarizationConfig { + // Required. Minimum number of speakers in the conversation. This range gives + // you more flexibility by allowing the system to automatically determine the + // correct number of speakers. If not set, the default value is 2. + // + // To fix the number of speakers detected in the audio, set + // `min_speaker_count` = `max_speaker_count`. + int32 min_speaker_count = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Maximum number of speakers in the conversation. Valid values are: + // 1-6. Must be >= `min_speaker_count`. This range gives you more flexibility + // by allowing the system to automatically determine the correct number of + // speakers. + int32 max_speaker_count = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Available recognition features. +message RecognitionFeatures { + // Options for how to recognize multi-channel audio. + enum MultiChannelMode { + // Default value for the multi-channel mode. If the audio contains + // multiple channels, only the first channel will be transcribed; other + // channels will be ignored. + MULTI_CHANNEL_MODE_UNSPECIFIED = 0; + + // If selected, each channel in the provided audio is transcribed + // independently. This cannot be selected if the selected + // [model][google.cloud.speech.v2.Recognizer.model] is `latest_short`. + SEPARATE_RECOGNITION_PER_CHANNEL = 1; + } + + // If set to `true`, the server will attempt to filter out profanities, + // replacing all but the initial character in each filtered word with + // asterisks, for instance, "f***". If set to `false` or omitted, profanities + // won't be filtered out. + bool profanity_filter = 1; + + // If `true`, the top result includes a list of words and the start and end + // time offsets (timestamps) for those words. If `false`, no word-level time + // offset information is returned. The default is `false`. + bool enable_word_time_offsets = 2; + + // 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 = 3; + + // If `true`, adds punctuation to recognition result hypotheses. This feature + // is only available in select languages. The default `false` value does not + // add punctuation to result hypotheses. + bool enable_automatic_punctuation = 4; + + // The spoken punctuation behavior for the call. 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. + bool enable_spoken_punctuation = 14; + + // The spoken emoji behavior for the call. 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. + bool enable_spoken_emojis = 15; + + // Mode for recognizing multi-channel audio. + MultiChannelMode multi_channel_mode = 17; + + // Configuration to enable speaker diarization and set additional + // parameters to make diarization better suited for your application. + // When this is enabled, we send all the words from the beginning of the + // audio for the top alternative in every consecutive STREAMING responses. + // This is done in order to improve our speaker tags as our models learn to + // identify the speakers in the conversation over time. + // For non-streaming requests, the diarization results will be provided only + // in the top alternative of the FINAL SpeechRecognitionResult. + SpeakerDiarizationConfig diarization_config = 9; + + // Maximum number of recognition hypotheses to be returned. + // The server may return fewer than `max_alternatives`. + // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of + // one. If omitted, will return a maximum of one. + int32 max_alternatives = 16; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. Phrase sets can be specified as an inline resource, or a +// reference to an existing phrase set resource. +message SpeechAdaptation { + // A biasing phrase set, which can be either a string referencing the name of + // an existing phrase set resource, or an inline definition of a phrase set. + message AdaptationPhraseSet { + oneof value { + // The name of an existing phrase set resource. The user must have read + // access to the resource and it must not be deleted. + string phrase_set = 1 [(google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + }]; + + // An inline defined phrase set. + PhraseSet inline_phrase_set = 2; + } + } + + // A list of inline or referenced phrase sets. + repeated AdaptationPhraseSet phrase_sets = 1; + + // A list of inline custom classes. Existing custom class resources can be + // referenced directly in a phrase set. + repeated CustomClass custom_classes = 2; +} + +// Provides information to the Recognizer that specifies how to process the +// recognition request. +message RecognitionConfig { + // Decoding parameters for audio being sent for recognition. + oneof decoding_config { + // Automatically detect decoding parameters. + // Preferred for supported formats. + AutoDetectDecodingConfig auto_decoding_config = 7; + + // Explicitly specified decoding parameters. + // Required if using headerless PCM audio (linear16, mulaw, alaw). + ExplicitDecodingConfig explicit_decoding_config = 8; + } + + // Speech recognition features to enable. + RecognitionFeatures features = 2; + + // Speech adaptation context that weights recognizer predictions for specific + // words and phrases. + SpeechAdaptation adaptation = 6; +} + +// Request message for the +// [Recognize][google.cloud.speech.v2.Speech.Recognize] method. Either +// `content` or `uri` must be supplied. Supplying both or neither returns +// [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See [content +// limits](https://cloud.google.com/speech-to-text/quotas#content). +message RecognizeRequest { + // Required. The name of the Recognizer to use during recognition. The + // expected format is + // `projects/{project}/locations/{location}/recognizers/{recognizer}`. + string recognizer = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; + + // Features and audio metadata to use for the Automatic Speech Recognition. + // This field in combination with the + // [config_mask][google.cloud.speech.v2.RecognizeRequest.config_mask] field + // can be used to override parts of the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the Recognizer resource. + RecognitionConfig config = 1; + + // The list of fields in + // [config][google.cloud.speech.v2.RecognizeRequest.config] that override the + // values in the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the recognizer during this recognition request. If no mask is provided, + // all non-default valued fields in + // [config][google.cloud.speech.v2.RecognizeRequest.config] override the + // values in the recognizer for this recognition request. If a mask is + // provided, only the fields listed in the mask override the config in the + // recognizer for this recognition request. If a wildcard (`*`) is provided, + // [config][google.cloud.speech.v2.RecognizeRequest.config] completely + // overrides and replaces the config in the recognizer for this recognition + // request. + google.protobuf.FieldMask config_mask = 8; + + // The audio source, which is either inline content or a Google Cloud + // Storage URI. + oneof audio_source { + // The audio data bytes encoded as specified in + // [RecognitionConfig][google.cloud.speech.v2.RecognitionConfig]. As + // with all bytes fields, proto buffers use a pure binary representation, + // whereas JSON representations use base64. + bytes content = 5; + + // URI that points to a file that contains audio data bytes as specified in + // [RecognitionConfig][google.cloud.speech.v2.RecognitionConfig]. The file + // must not be compressed (for example, gzip). Currently, only Google Cloud + // Storage URIs are supported, which must be specified in the following + // format: `gs://bucket_name/object_name` (other URI formats return + // [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more + // information, see [Request + // URIs](https://cloud.google.com/storage/docs/reference-uris). + string uri = 6; + } +} + +// Metadata about the recognition request and response. +message RecognitionResponseMetadata { + // When available, billed audio seconds for the corresponding request. + google.protobuf.Duration total_billed_duration = 6; +} + +// Alternative hypotheses (a.k.a. n-best list). +message SpeechRecognitionAlternative { + // Transcript text representing the words that the user spoke. + string transcript = 1; + + // 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][google.cloud.speech.v2.StreamingRecognitionResult.is_final] is + // set to `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 = 2; + + // A list of word-specific information for each recognized word. + // When + // [enable_speaker_diarization][google.cloud.speech.v2.SpeakerDiarizationConfig.enable_speaker_diarization] + // is true, you will see all the words from the beginning of the audio. + repeated WordInfo words = 3; +} + +// Word-specific information for recognized words. +message WordInfo { + // Time offset relative to the beginning of the audio, + // and corresponding to the start of the spoken word. + // This field is only set if + // [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets] + // is `true` and only in the top hypothesis. This is an experimental feature + // and the accuracy of the time offset can vary. + google.protobuf.Duration start_offset = 1; + + // Time offset relative to the beginning of the audio, + // and corresponding to the end of the spoken word. + // This field is only set if + // [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets] + // is `true` and only in the top hypothesis. This is an experimental feature + // and the accuracy of the time offset can vary. + google.protobuf.Duration end_offset = 2; + + // 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][google.cloud.speech.v2.StreamingRecognitionResult.is_final] is + // set to `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; + + // A distinct label is assigned for every speaker within the audio. This field + // specifies which one of those speakers was detected to have spoken this + // word. `speaker_label` is set if + // [enable_speaker_diarization][google.cloud.speech.v2.SpeakerDiarizationConfig.enable_speaker_diarization] + // is `true` and only in the top alternative. + string speaker_label = 6; +} + +// A speech recognition result corresponding to a portion of the audio. +message SpeechRecognitionResult { + // May contain one or more recognition hypotheses. These alternatives are + // ordered in terms of accuracy, with the top (first) alternative being the + // most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // For multi-channel audio, this is the channel number corresponding to the + // 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_offset = 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]; +} + +// Response message for the +// [Recognize][google.cloud.speech.v2.Speech.Recognize] method. +message RecognizeResponse { + // Sequential list of transcription results corresponding to sequential + // portions of audio. + repeated SpeechRecognitionResult results = 3; + + // Metadata about the recognition. + RecognitionResponseMetadata metadata = 2; +} + +// Available recognition features specific to streaming recognition requests. +message StreamingRecognitionFeatures { + // Events that a timeout can be set on for voice activity. + message VoiceActivityTimeout { + // Duration to timeout the stream if no speech begins. If this is set and + // no speech is detected in this duration at the start of the stream, the + // server will close the stream. + google.protobuf.Duration speech_start_timeout = 1; + + // Duration to timeout the stream after speech ends. If this is set and no + // speech is detected in this duration after speech was detected, the server + // will close the stream. + google.protobuf.Duration speech_end_timeout = 2; + } + + // If `true`, responses with voice activity speech events will be returned as + // they are detected. + bool enable_voice_activity_events = 1; + + // Whether or not to stream interim results to the client. If set to true, + // interim results will be streamed to the client. Otherwise, only the final + // response will be streamed back. + bool interim_results = 2; + + // If set, the server will automatically close the stream after the specified + // duration has elapsed after the last VOICE_ACTIVITY speech event has been + // sent. The field `voice_activity_events` must also be set to true. + VoiceActivityTimeout voice_activity_timeout = 3; +} + +// Provides configuration information for the StreamingRecognize request. +message StreamingRecognitionConfig { + // Required. Features and audio metadata to use for the Automatic Speech + // Recognition. This field in combination with the + // [config_mask][google.cloud.speech.v2.StreamingRecognitionConfig.config_mask] + // field can be used to override parts of the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the Recognizer resource. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields in + // [config][google.cloud.speech.v2.StreamingRecognitionConfig.config] that + // override the values in the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the recognizer during this recognition request. If no mask is provided, + // all non-default valued fields in + // [config][google.cloud.speech.v2.StreamingRecognitionConfig.config] override + // the values in the recognizer for this recognition request. If a mask is + // provided, only the fields listed in the mask override the config in the + // recognizer for this recognition request. If a wildcard (`*`) is provided, + // [config][google.cloud.speech.v2.StreamingRecognitionConfig.config] + // completely overrides and replaces the config in the recognizer for this + // recognition request. + google.protobuf.FieldMask config_mask = 3; + + // Speech recognition features to enable specific to streaming audio + // recognition requests. + StreamingRecognitionFeatures streaming_features = 2; +} + +// Request message for the +// [StreamingRecognize][google.cloud.speech.v2.Speech.StreamingRecognize] +// method. Multiple +// [StreamingRecognizeRequest][google.cloud.speech.v2.StreamingRecognizeRequest] +// messages are sent. The first message must contain a +// [recognizer][google.cloud.speech.v2.StreamingRecognizeRequest.recognizer] and +// optionally a +// [streaming_config][google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config] +// message and must not contain +// [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio]. All +// subsequent messages must contain +// [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio] and must not +// contain a +// [streaming_config][google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config] +// message. +message StreamingRecognizeRequest { + // Required. Streaming recognition should start with an initial request having + // a `recognizer`. Subsequent requests carry the audio data to be recognized. + // + // The initial request with configuration can be omitted if the Recognizer + // being used has a + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]. + string recognizer = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; + + oneof streaming_request { + // StreamingRecognitionConfig to be used in this recognition attempt. + // If provided, it will override the default RecognitionConfig stored in the + // Recognizer. + StreamingRecognitionConfig streaming_config = 6; + + // Inline audio bytes to be Recognized. + bytes audio = 5; + } +} + +// Request message for the +// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize] +// method. +message BatchRecognizeRequest { + // Required. Resource name of the recognizer to be used for ASR. + string recognizer = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/Recognizer" + } + ]; + + // Features and audio metadata to use for the Automatic Speech Recognition. + // This field in combination with the + // [config_mask][google.cloud.speech.v2.BatchRecognizeRequest.config_mask] + // field can be used to override parts of the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the Recognizer resource. + RecognitionConfig config = 4; + + // The list of fields in + // [config][google.cloud.speech.v2.BatchRecognizeRequest.config] that override + // the values in the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the recognizer during this recognition request. If no mask is provided, + // all given fields in + // [config][google.cloud.speech.v2.BatchRecognizeRequest.config] override the + // values in the recognizer for this recognition request. If a mask is + // provided, only the fields listed in the mask override the config in the + // recognizer for this recognition request. If a wildcard (`*`) is provided, + // [config][google.cloud.speech.v2.BatchRecognizeRequest.config] completely + // overrides and replaces the config in the recognizer for this recognition + // request. + google.protobuf.FieldMask config_mask = 5; + + // Audio files with file metadata for ASR. + repeated BatchRecognizeFileMetadata files = 3; +} + +// Response message for +// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize] that is +// packaged into a longrunning [Operation][google.longrunning.Operation]. +message BatchRecognizeResponse { + // Map from filename to the final result for that file. + map results = 1; +} + +// Final results for a single file. +message BatchRecognizeFileResult { + // The GCS URI to which recognition results were written. + string uri = 1; + + // Error if one was encountered. + google.rpc.Status error = 2; +} + +// Metadata about transcription for a single file (for example, progress +// percent). +message BatchRecognizeTranscriptionMetadata { + // How much of the file has been transcribed so far. + int32 progress_percent = 1; + + // Error if one was encountered. + google.rpc.Status error = 2; + + // The GCS URI to which recognition results will be written. + string uri = 3; +} + +// Operation metadata for +// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize]. +message BatchRecognizeMetadata { + // Map from provided filename to the transcription metadata for that file. + map transcription_metadata = 1; +} + +// Metadata about a single file in a batch for BatchRecognize. +message BatchRecognizeFileMetadata { + // The audio source, which is a Google Cloud Storage URI. + oneof audio_source { + // Cloud Storage URI for the audio file. + string uri = 1; + } + + // Features and audio metadata to use for the Automatic Speech Recognition. + // This field in combination with the + // [config_mask][google.cloud.speech.v2.BatchRecognizeFileMetadata.config_mask] + // field can be used to override parts of the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the Recognizer resource as well as the + // [config][google.cloud.speech.v2.BatchRecognizeRequest.config] at the + // request level. + RecognitionConfig config = 4; + + // The list of fields in + // [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config] that + // override the values in the + // [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config] + // of the recognizer during this recognition request. If no mask is provided, + // all non-default valued fields in + // [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config] override + // the values in the recognizer for this recognition request. If a mask is + // provided, only the fields listed in the mask override the config in the + // recognizer for this recognition request. If a wildcard (`*`) is provided, + // [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config] + // completely overrides and replaces the config in the recognizer for this + // recognition request. + google.protobuf.FieldMask config_mask = 5; +} + +// A streaming speech recognition result corresponding to a portion of the audio +// that is currently being processed. +message StreamingRecognitionResult { + // May contain one or more recognition hypotheses. These alternatives are + // ordered in terms of accuracy, with the top (first) alternative being the + // most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // If `false`, this + // [StreamingRecognitionResult][google.cloud.speech.v2.StreamingRecognitionResult] + // represents an interim result that may change. If `true`, this is the final + // time the speech service will return this particular + // [StreamingRecognitionResult][google.cloud.speech.v2.StreamingRecognitionResult], + // the recognizer will not return any further hypotheses for this portion of + // the transcript and corresponding audio. + bool is_final = 2; + + // An estimate of the likelihood that the recognizer will not change its guess + // about this interim result. Values range from 0.0 (completely unstable) + // to 1.0 (completely stable). This field is only provided for interim results + // ([is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`false`). + // The default of 0.0 is a sentinel value indicating `stability` was not set. + float stability = 3; + + // Time offset of the end of this result relative to the beginning of the + // audio. + google.protobuf.Duration result_end_offset = 4; + + // For multi-channel audio, this is the channel number corresponding to the + // 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 = 5; + + // 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]; +} + +// `StreamingRecognizeResponse` is the only message returned to the client by +// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse` +// messages are streamed back to the client. If there is no recognizable +// audio then no messages are streamed back to the client. +// +// Here are some examples of `StreamingRecognizeResponse`s that might +// be returned while processing audio: +// +// 1. results { alternatives { transcript: "tube" } stability: 0.01 } +// +// 2. results { alternatives { transcript: "to be a" } stability: 0.01 } +// +// 3. results { alternatives { transcript: "to be" } stability: 0.9 } +// results { alternatives { transcript: " or not to be" } stability: 0.01 } +// +// 4. results { alternatives { transcript: "to be or not to be" +// confidence: 0.92 } +// alternatives { transcript: "to bee or not to bee" } +// is_final: true } +// +// 5. results { alternatives { transcript: " that's" } stability: 0.01 } +// +// 6. results { alternatives { transcript: " that is" } stability: 0.9 } +// results { alternatives { transcript: " the question" } stability: 0.01 } +// +// 7. results { alternatives { transcript: " that is the question" +// confidence: 0.98 } +// alternatives { transcript: " that was the question" } +// is_final: true } +// +// Notes: +// +// - Only two of the above responses #4 and #7 contain final results; they are +// indicated by `is_final: true`. Concatenating these together generates the +// full transcript: "to be or not to be that is the question". +// +// - The others contain interim `results`. #3 and #6 contain two interim +// `results`: the first portion has a high stability and is less likely to +// change; the second portion has a low stability and is very likely to +// change. A UI designer might choose to show only high stability `results`. +// +// - The specific `stability` and `confidence` values shown above are only for +// illustrative purposes. Actual values may vary. +// +// - In each response, only one of these fields will be set: +// `error`, +// `speech_event_type`, or +// one or more (repeated) `results`. +message StreamingRecognizeResponse { + // Indicates the type of speech event. + enum SpeechEventType { + // No speech event specified. + SPEECH_EVENT_TYPE_UNSPECIFIED = 0; + + // This event indicates that the server has detected the end of the user's + // speech utterance and expects no additional speech. Therefore, the server + // will not process additional audio and will close the gRPC bidirectional + // stream. This event is only sent if there was a force cutoff due to + // silence being detected early. This event is only available through the + // `latest_short` [model][google.cloud.speech.v2.Recognizer.model]. + END_OF_SINGLE_UTTERANCE = 1; + + // This event indicates that the server has detected the beginning of human + // voice activity in the stream. This event can be returned multiple times + // if speech starts and stops repeatedly throughout the stream. This event + // is only sent if `voice_activity_events` is set to true. + SPEECH_ACTIVITY_BEGIN = 2; + + // This event indicates that the server has detected the end of human voice + // activity in the stream. This event can be returned multiple times if + // speech starts and stops repeatedly throughout the stream. This event is + // only sent if `voice_activity_events` is set to true. + SPEECH_ACTIVITY_END = 3; + } + + // This repeated list contains zero or more results that + // correspond to consecutive portions of the audio currently being processed. + // It contains zero or one + // [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`true` + // result (the newly settled portion), followed by zero or more + // [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`false` + // results (the interim results). + repeated StreamingRecognitionResult results = 6; + + // Indicates the type of speech event. + SpeechEventType speech_event_type = 3; + + // Time offset between the beginning of the audio and event emission. + google.protobuf.Duration speech_event_offset = 7; + + // Metadata about the recognition. + RecognitionResponseMetadata metadata = 5; +} + +// Message representing the config for the Speech-to-Text API. This includes an +// optional [KMS key](https://cloud.google.com/kms/docs/resource-hierarchy#keys) +// with which incoming data will be encrypted. +message Config { + option (google.api.resource) = { + type: "speech.googleapis.com/Config" + pattern: "projects/{project}/locations/{location}/config" + }; + + // Output only. The name of the config resource. There is exactly one config + // resource per project per location. The expected format is + // `projects/{project}/locations/{location}/config`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. An optional [KMS key + // name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) that if + // present, will be used to encrypt Speech-to-Text resources at-rest. Updating + // this key will not encrypt existing resources using this key; only new + // resources will be encrypted using this key. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 2 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; + + // Output only. The most recent time this resource was modified. + google.protobuf.Timestamp update_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request message for the +// [GetConfig][google.cloud.speech.v2.Speech.GetConfig] method. +message GetConfigRequest { + // Required. The name of the config to retrieve. There is exactly one config + // resource per project per location. The expected format is + // `projects/{project}/locations/{location}/config`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "speech.googleapis.com/Config" } + ]; +} + +// Request message for the +// [UpdateConfig][google.cloud.speech.v2.Speech.UpdateConfig] method. +message UpdateConfigRequest { + // Required. The config to update. + // + // The config's `name` field is used to identify the config to be updated. + // The expected format is `projects/{project}/locations/{location}/config`. + Config config = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// CustomClass for biasing in speech recognition. Used to define a set of words +// or phrases that represents a common concept or theme likely to appear in your +// audio, for example a list of passenger ship names. +message CustomClass { + option (google.api.resource) = { + type: "speech.googleapis.com/CustomClass" + pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" + style: DECLARATIVE_FRIENDLY + }; + + // An item of the class. + message ClassItem { + // The class item's value. + string value = 1; + } + + // Set of states that define the lifecycle of a CustomClass. + enum State { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 2; + + // This CustomClass has been deleted. + DELETED = 4; + } + + // Output only. The resource name of the CustomClass. + // Format: + // `projects/{project}/locations/{location}/customClasses/{custom_class}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. System-assigned unique identifier for the CustomClass. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // User-settable, human-readable name for the CustomClass. Must be 63 + // characters or less. + string display_name = 4; + + // A collection of class items. + repeated ClassItem items = 5; + + // Output only. The CustomClass lifecycle state. + State state = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The most recent time this resource was modified. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource was requested for deletion. + google.protobuf.Timestamp delete_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource will be purged. + google.protobuf.Timestamp expire_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Allows users to store small amounts of arbitrary data. + // Both the key and the value must be 63 characters or less each. + // At most 100 annotations. + map annotations = 10; + + // Output only. This checksum is computed by the server based on the value of + // other fields. This may be sent on update, undelete, and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether or not this CustomClass is in the process of being + // updated. + bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The [KMS key + // name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which + // the CustomClass is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 13 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; + + // Output only. The [KMS key version + // name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) + // with which the CustomClass is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`. + string kms_key_version_name = 14 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + } + ]; +} + +// PhraseSet for biasing in speech recognition. A PhraseSet is used to provide +// "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}" + style: DECLARATIVE_FRIENDLY + }; + + // A Phrase contains 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. + // + // List items can also include CustomClass references containing groups of + // words that represent common concepts that occur in natural language. + 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 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. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 2; + } + + // Set of states that define the lifecycle of a PhraseSet. + enum State { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 2; + + // This PhraseSet has been deleted. + DELETED = 4; + } + + // Output only. The resource name of the PhraseSet. + // Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. System-assigned unique identifier for the PhraseSet. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // A list of word and phrases. + repeated Phrase phrases = 3; + + // 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. + // Valid `boost` values are between 0 (exclusive) and 20. We recommend using a + // binary search approach to finding the optimal value for your use case. + float boost = 4; + + // User-settable, human-readable name for the PhraseSet. Must be 63 + // characters or less. + string display_name = 5; + + // Output only. The PhraseSet lifecycle state. + State state = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The most recent time this resource was modified. + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource was requested for deletion. + google.protobuf.Timestamp delete_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource will be purged. + google.protobuf.Timestamp expire_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Allows users to store small amounts of arbitrary data. + // Both the key and the value must be 63 characters or less each. + // At most 100 annotations. + map annotations = 10; + + // Output only. This checksum is computed by the server based on the value of + // other fields. This may be sent on update, undelete, and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether or not this PhraseSet is in the process of being + // updated. + bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The [KMS key + // name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which + // the PhraseSet is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 13 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; + + // Output only. The [KMS key version + // name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) + // with which the PhraseSet is encrypted. The expected format is + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`. + string kms_key_version_name = 14 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + } + ]; +} + +// Request message for the +// [CreateCustomClass][google.cloud.speech.v2.Speech.CreateCustomClass] method. +message CreateCustomClassRequest { + // Required. The CustomClass to create. + CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set, validate the request and preview the CustomClass, but do not + // actually create it. + bool validate_only = 2; + + // The ID to use for the CustomClass, which will become the final component of + // the CustomClass's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-/. + string custom_class_id = 3; + + // Required. The project and location where this CustomClass will be created. + // The expected format is `projects/{project}/locations/{location}`. + string parent = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; +} + +// Request message for the +// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] method. +message ListCustomClassesRequest { + // Required. The project and location of CustomClass resources to list. The + // expected format is `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Number of results per requests. A valid page_size ranges from 0 to 20 + // inclusive. If the page_size is zero or unspecified, a page size of 5 will + // be chosen. If the page size exceeds 20, it will be coerced down to 20. Note + // that a call might return fewer results than the requested page size. + int32 page_size = 2; + + // A page token, received from a previous + // [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] must + // match the call that provided the page token. + string page_token = 3; + + // Whether, or not, to show resources that have been deleted. + bool show_deleted = 4; +} + +// Response message for the +// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] method. +message ListCustomClassesResponse { + // The list of requested CustomClasses. + repeated CustomClass custom_classes = 1; + + // A token, which can be sent as + // [page_token][google.cloud.speech.v2.ListCustomClassesRequest.page_token] to + // retrieve the next page. If this field is omitted, there are no subsequent + // pages. This token expires after 72 hours. + string next_page_token = 2; +} + +// Request message for the +// [GetCustomClass][google.cloud.speech.v2.Speech.GetCustomClass] method. +message GetCustomClassRequest { + // Required. The name of the CustomClass to retrieve. The expected format is + // `projects/{project}/locations/{location}/customClasses/{custom_class}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} + +// Request message for the +// [UpdateCustomClass][google.cloud.speech.v2.Speech.UpdateCustomClass] method. +message UpdateCustomClassRequest { + // Required. The CustomClass to update. + // + // The CustomClass's `name` field is used to identify the CustomClass to + // update. Format: + // `projects/{project}/locations/{location}/customClasses/{custom_class}`. + CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. If empty, all fields are considered for + // update. + google.protobuf.FieldMask update_mask = 2; + + // If set, validate the request and preview the updated CustomClass, but do + // not actually update it. + bool validate_only = 4; +} + +// Request message for the +// [DeleteCustomClass][google.cloud.speech.v2.Speech.DeleteCustomClass] method. +message DeleteCustomClassRequest { + // Required. The name of the CustomClass to delete. + // Format: + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; + + // If set, validate the request and preview the deleted CustomClass, but do + // not actually delete it. + bool validate_only = 2; + + // If set to true, and the CustomClass is not found, the request will succeed + // and be a no-op (no Operation is recorded in this case). + bool allow_missing = 4; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 3; +} + +// Request message for the +// [UndeleteCustomClass][google.cloud.speech.v2.Speech.UndeleteCustomClass] +// method. +message UndeleteCustomClassRequest { + // Required. The name of the CustomClass to undelete. + // Format: + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; + + // If set, validate the request and preview the undeleted CustomClass, but do + // not actually undelete it. + bool validate_only = 3; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 4; +} + +// Request message for the +// [CreatePhraseSet][google.cloud.speech.v2.Speech.CreatePhraseSet] method. +message CreatePhraseSetRequest { + // Required. The PhraseSet to create. + PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set, validate the request and preview the PhraseSet, but do not + // actually create it. + bool validate_only = 2; + + // The ID to use for the PhraseSet, which will become the final component of + // the PhraseSet's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-/. + string phrase_set_id = 3; + + // Required. The project and location where this PhraseSet will be created. + // The expected format is `projects/{project}/locations/{location}`. + string parent = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Request message for the +// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] method. +message ListPhraseSetsRequest { + // Required. The project and location of PhraseSet resources to list. The + // expected format is `projects/{project}/locations/{location}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of PhraseSets to return. The service may return fewer + // than this value. If unspecified, at most 20 PhraseSets will be returned. + // The maximum value is 20; values above 20 will be coerced to 20. + int32 page_size = 2; + + // A page token, received from a previous + // [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] must match + // the call that provided the page token. + string page_token = 3; + + // Whether, or not, to show resources that have been deleted. + bool show_deleted = 4; +} + +// Response message for the +// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] method. +message ListPhraseSetsResponse { + // The list of requested PhraseSets. + repeated PhraseSet phrase_sets = 1; + + // A token, which can be sent as + // [page_token][google.cloud.speech.v2.ListPhraseSetsRequest.page_token] to + // retrieve the next page. If this field is omitted, there are no subsequent + // pages. This token expires after 72 hours. + string next_page_token = 2; +} + +// Request message for the +// [GetPhraseSet][google.cloud.speech.v2.Speech.GetPhraseSet] method. +message GetPhraseSetRequest { + // Required. The name of the PhraseSet to retrieve. The expected format is + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Request message for the +// [UpdatePhraseSet][google.cloud.speech.v2.Speech.UpdatePhraseSet] method. +message UpdatePhraseSetRequest { + // Required. The PhraseSet to update. + // + // The PhraseSet's `name` field is used to identify the PhraseSet to update. + // Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to update. If empty, all non-default valued fields are + // considered for update. Use `*` to update the entire PhraseSet resource. + google.protobuf.FieldMask update_mask = 2; + + // If set, validate the request and preview the updated PhraseSet, but do not + // actually update it. + bool validate_only = 4; +} + +// Request message for the +// [DeletePhraseSet][google.cloud.speech.v2.Speech.DeletePhraseSet] method. +message DeletePhraseSetRequest { + // Required. The name of the PhraseSet to delete. + // Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; + + // If set, validate the request and preview the deleted PhraseSet, but do not + // actually delete it. + bool validate_only = 2; + + // If set to true, and the PhraseSet is not found, the request will succeed + // and be a no-op (no Operation is recorded in this case). + bool allow_missing = 4; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 3; +} + +// Request message for the +// [UndeletePhraseSet][google.cloud.speech.v2.Speech.UndeletePhraseSet] +// method. +message UndeletePhraseSetRequest { + // Required. The name of the PhraseSet to undelete. + // Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; + + // If set, validate the request and preview the undeleted PhraseSet, but do + // not actually undelete it. + bool validate_only = 3; + + // This checksum is computed by the server based on the value of other + // fields. This may be sent on update, undelete, and delete requests to ensure + // the client has an up-to-date value before proceeding. + string etag = 4; +} diff --git a/packages/google-cloud-speech/protos/protos.d.ts b/packages/google-cloud-speech/protos/protos.d.ts index d732893bbab..4f17faf4508 100644 --- a/packages/google-cloud-speech/protos/protos.d.ts +++ b/packages/google-cloud-speech/protos/protos.d.ts @@ -8814,6 +8814,6906 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } } + + /** Namespace v2. */ + namespace v2 { + + /** Represents a Speech */ + class Speech extends $protobuf.rpc.Service { + + /** + * Constructs a new Speech service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Speech service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Speech; + + /** + * Calls CreateRecognizer. + * @param request CreateRecognizerRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createRecognizer(request: google.cloud.speech.v2.ICreateRecognizerRequest, callback: google.cloud.speech.v2.Speech.CreateRecognizerCallback): void; + + /** + * Calls CreateRecognizer. + * @param request CreateRecognizerRequest message or plain object + * @returns Promise + */ + public createRecognizer(request: google.cloud.speech.v2.ICreateRecognizerRequest): Promise; + + /** + * Calls ListRecognizers. + * @param request ListRecognizersRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListRecognizersResponse + */ + public listRecognizers(request: google.cloud.speech.v2.IListRecognizersRequest, callback: google.cloud.speech.v2.Speech.ListRecognizersCallback): void; + + /** + * Calls ListRecognizers. + * @param request ListRecognizersRequest message or plain object + * @returns Promise + */ + public listRecognizers(request: google.cloud.speech.v2.IListRecognizersRequest): Promise; + + /** + * Calls GetRecognizer. + * @param request GetRecognizerRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Recognizer + */ + public getRecognizer(request: google.cloud.speech.v2.IGetRecognizerRequest, callback: google.cloud.speech.v2.Speech.GetRecognizerCallback): void; + + /** + * Calls GetRecognizer. + * @param request GetRecognizerRequest message or plain object + * @returns Promise + */ + public getRecognizer(request: google.cloud.speech.v2.IGetRecognizerRequest): Promise; + + /** + * Calls UpdateRecognizer. + * @param request UpdateRecognizerRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updateRecognizer(request: google.cloud.speech.v2.IUpdateRecognizerRequest, callback: google.cloud.speech.v2.Speech.UpdateRecognizerCallback): void; + + /** + * Calls UpdateRecognizer. + * @param request UpdateRecognizerRequest message or plain object + * @returns Promise + */ + public updateRecognizer(request: google.cloud.speech.v2.IUpdateRecognizerRequest): Promise; + + /** + * Calls DeleteRecognizer. + * @param request DeleteRecognizerRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deleteRecognizer(request: google.cloud.speech.v2.IDeleteRecognizerRequest, callback: google.cloud.speech.v2.Speech.DeleteRecognizerCallback): void; + + /** + * Calls DeleteRecognizer. + * @param request DeleteRecognizerRequest message or plain object + * @returns Promise + */ + public deleteRecognizer(request: google.cloud.speech.v2.IDeleteRecognizerRequest): Promise; + + /** + * Calls UndeleteRecognizer. + * @param request UndeleteRecognizerRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public undeleteRecognizer(request: google.cloud.speech.v2.IUndeleteRecognizerRequest, callback: google.cloud.speech.v2.Speech.UndeleteRecognizerCallback): void; + + /** + * Calls UndeleteRecognizer. + * @param request UndeleteRecognizerRequest message or plain object + * @returns Promise + */ + public undeleteRecognizer(request: google.cloud.speech.v2.IUndeleteRecognizerRequest): Promise; + + /** + * Calls Recognize. + * @param request RecognizeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RecognizeResponse + */ + public recognize(request: google.cloud.speech.v2.IRecognizeRequest, callback: google.cloud.speech.v2.Speech.RecognizeCallback): void; + + /** + * Calls Recognize. + * @param request RecognizeRequest message or plain object + * @returns Promise + */ + public recognize(request: google.cloud.speech.v2.IRecognizeRequest): Promise; + + /** + * Calls StreamingRecognize. + * @param request StreamingRecognizeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamingRecognizeResponse + */ + public streamingRecognize(request: google.cloud.speech.v2.IStreamingRecognizeRequest, callback: google.cloud.speech.v2.Speech.StreamingRecognizeCallback): void; + + /** + * Calls StreamingRecognize. + * @param request StreamingRecognizeRequest message or plain object + * @returns Promise + */ + public streamingRecognize(request: google.cloud.speech.v2.IStreamingRecognizeRequest): Promise; + + /** + * Calls BatchRecognize. + * @param request BatchRecognizeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public batchRecognize(request: google.cloud.speech.v2.IBatchRecognizeRequest, callback: google.cloud.speech.v2.Speech.BatchRecognizeCallback): void; + + /** + * Calls BatchRecognize. + * @param request BatchRecognizeRequest message or plain object + * @returns Promise + */ + public batchRecognize(request: google.cloud.speech.v2.IBatchRecognizeRequest): Promise; + + /** + * Calls GetConfig. + * @param request GetConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Config + */ + public getConfig(request: google.cloud.speech.v2.IGetConfigRequest, callback: google.cloud.speech.v2.Speech.GetConfigCallback): void; + + /** + * Calls GetConfig. + * @param request GetConfigRequest message or plain object + * @returns Promise + */ + public getConfig(request: google.cloud.speech.v2.IGetConfigRequest): Promise; + + /** + * Calls UpdateConfig. + * @param request UpdateConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Config + */ + public updateConfig(request: google.cloud.speech.v2.IUpdateConfigRequest, callback: google.cloud.speech.v2.Speech.UpdateConfigCallback): void; + + /** + * Calls UpdateConfig. + * @param request UpdateConfigRequest message or plain object + * @returns Promise + */ + public updateConfig(request: google.cloud.speech.v2.IUpdateConfigRequest): Promise; + + /** + * Calls CreateCustomClass. + * @param request CreateCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createCustomClass(request: google.cloud.speech.v2.ICreateCustomClassRequest, callback: google.cloud.speech.v2.Speech.CreateCustomClassCallback): void; + + /** + * Calls CreateCustomClass. + * @param request CreateCustomClassRequest message or plain object + * @returns Promise + */ + public createCustomClass(request: google.cloud.speech.v2.ICreateCustomClassRequest): Promise; + + /** + * Calls ListCustomClasses. + * @param request ListCustomClassesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCustomClassesResponse + */ + public listCustomClasses(request: google.cloud.speech.v2.IListCustomClassesRequest, callback: google.cloud.speech.v2.Speech.ListCustomClassesCallback): void; + + /** + * Calls ListCustomClasses. + * @param request ListCustomClassesRequest message or plain object + * @returns Promise + */ + public listCustomClasses(request: google.cloud.speech.v2.IListCustomClassesRequest): Promise; + + /** + * Calls GetCustomClass. + * @param request GetCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CustomClass + */ + public getCustomClass(request: google.cloud.speech.v2.IGetCustomClassRequest, callback: google.cloud.speech.v2.Speech.GetCustomClassCallback): void; + + /** + * Calls GetCustomClass. + * @param request GetCustomClassRequest message or plain object + * @returns Promise + */ + public getCustomClass(request: google.cloud.speech.v2.IGetCustomClassRequest): Promise; + + /** + * Calls UpdateCustomClass. + * @param request UpdateCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updateCustomClass(request: google.cloud.speech.v2.IUpdateCustomClassRequest, callback: google.cloud.speech.v2.Speech.UpdateCustomClassCallback): void; + + /** + * Calls UpdateCustomClass. + * @param request UpdateCustomClassRequest message or plain object + * @returns Promise + */ + public updateCustomClass(request: google.cloud.speech.v2.IUpdateCustomClassRequest): Promise; + + /** + * Calls DeleteCustomClass. + * @param request DeleteCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deleteCustomClass(request: google.cloud.speech.v2.IDeleteCustomClassRequest, callback: google.cloud.speech.v2.Speech.DeleteCustomClassCallback): void; + + /** + * Calls DeleteCustomClass. + * @param request DeleteCustomClassRequest message or plain object + * @returns Promise + */ + public deleteCustomClass(request: google.cloud.speech.v2.IDeleteCustomClassRequest): Promise; + + /** + * Calls UndeleteCustomClass. + * @param request UndeleteCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public undeleteCustomClass(request: google.cloud.speech.v2.IUndeleteCustomClassRequest, callback: google.cloud.speech.v2.Speech.UndeleteCustomClassCallback): void; + + /** + * Calls UndeleteCustomClass. + * @param request UndeleteCustomClassRequest message or plain object + * @returns Promise + */ + public undeleteCustomClass(request: google.cloud.speech.v2.IUndeleteCustomClassRequest): Promise; + + /** + * Calls CreatePhraseSet. + * @param request CreatePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createPhraseSet(request: google.cloud.speech.v2.ICreatePhraseSetRequest, callback: google.cloud.speech.v2.Speech.CreatePhraseSetCallback): void; + + /** + * Calls CreatePhraseSet. + * @param request CreatePhraseSetRequest message or plain object + * @returns Promise + */ + public createPhraseSet(request: google.cloud.speech.v2.ICreatePhraseSetRequest): Promise; + + /** + * Calls ListPhraseSets. + * @param request ListPhraseSetsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListPhraseSetsResponse + */ + public listPhraseSets(request: google.cloud.speech.v2.IListPhraseSetsRequest, callback: google.cloud.speech.v2.Speech.ListPhraseSetsCallback): void; + + /** + * Calls ListPhraseSets. + * @param request ListPhraseSetsRequest message or plain object + * @returns Promise + */ + public listPhraseSets(request: google.cloud.speech.v2.IListPhraseSetsRequest): Promise; + + /** + * Calls GetPhraseSet. + * @param request GetPhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PhraseSet + */ + public getPhraseSet(request: google.cloud.speech.v2.IGetPhraseSetRequest, callback: google.cloud.speech.v2.Speech.GetPhraseSetCallback): void; + + /** + * Calls GetPhraseSet. + * @param request GetPhraseSetRequest message or plain object + * @returns Promise + */ + public getPhraseSet(request: google.cloud.speech.v2.IGetPhraseSetRequest): Promise; + + /** + * Calls UpdatePhraseSet. + * @param request UpdatePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updatePhraseSet(request: google.cloud.speech.v2.IUpdatePhraseSetRequest, callback: google.cloud.speech.v2.Speech.UpdatePhraseSetCallback): void; + + /** + * Calls UpdatePhraseSet. + * @param request UpdatePhraseSetRequest message or plain object + * @returns Promise + */ + public updatePhraseSet(request: google.cloud.speech.v2.IUpdatePhraseSetRequest): Promise; + + /** + * Calls DeletePhraseSet. + * @param request DeletePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deletePhraseSet(request: google.cloud.speech.v2.IDeletePhraseSetRequest, callback: google.cloud.speech.v2.Speech.DeletePhraseSetCallback): void; + + /** + * Calls DeletePhraseSet. + * @param request DeletePhraseSetRequest message or plain object + * @returns Promise + */ + public deletePhraseSet(request: google.cloud.speech.v2.IDeletePhraseSetRequest): Promise; + + /** + * Calls UndeletePhraseSet. + * @param request UndeletePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public undeletePhraseSet(request: google.cloud.speech.v2.IUndeletePhraseSetRequest, callback: google.cloud.speech.v2.Speech.UndeletePhraseSetCallback): void; + + /** + * Calls UndeletePhraseSet. + * @param request UndeletePhraseSetRequest message or plain object + * @returns Promise + */ + public undeletePhraseSet(request: google.cloud.speech.v2.IUndeletePhraseSetRequest): Promise; + } + + namespace Speech { + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createRecognizer}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateRecognizerCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listRecognizers}. + * @param error Error, if any + * @param [response] ListRecognizersResponse + */ + type ListRecognizersCallback = (error: (Error|null), response?: google.cloud.speech.v2.ListRecognizersResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getRecognizer}. + * @param error Error, if any + * @param [response] Recognizer + */ + type GetRecognizerCallback = (error: (Error|null), response?: google.cloud.speech.v2.Recognizer) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateRecognizer}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdateRecognizerCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deleteRecognizer}. + * @param error Error, if any + * @param [response] Operation + */ + type DeleteRecognizerCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeleteRecognizer}. + * @param error Error, if any + * @param [response] Operation + */ + type UndeleteRecognizerCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|recognize}. + * @param error Error, if any + * @param [response] RecognizeResponse + */ + type RecognizeCallback = (error: (Error|null), response?: google.cloud.speech.v2.RecognizeResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|streamingRecognize}. + * @param error Error, if any + * @param [response] StreamingRecognizeResponse + */ + type StreamingRecognizeCallback = (error: (Error|null), response?: google.cloud.speech.v2.StreamingRecognizeResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|batchRecognize}. + * @param error Error, if any + * @param [response] Operation + */ + type BatchRecognizeCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getConfig}. + * @param error Error, if any + * @param [response] Config + */ + type GetConfigCallback = (error: (Error|null), response?: google.cloud.speech.v2.Config) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateConfig}. + * @param error Error, if any + * @param [response] Config + */ + type UpdateConfigCallback = (error: (Error|null), response?: google.cloud.speech.v2.Config) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createCustomClass}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateCustomClassCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listCustomClasses}. + * @param error Error, if any + * @param [response] ListCustomClassesResponse + */ + type ListCustomClassesCallback = (error: (Error|null), response?: google.cloud.speech.v2.ListCustomClassesResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getCustomClass}. + * @param error Error, if any + * @param [response] CustomClass + */ + type GetCustomClassCallback = (error: (Error|null), response?: google.cloud.speech.v2.CustomClass) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateCustomClass}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdateCustomClassCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deleteCustomClass}. + * @param error Error, if any + * @param [response] Operation + */ + type DeleteCustomClassCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeleteCustomClass}. + * @param error Error, if any + * @param [response] Operation + */ + type UndeleteCustomClassCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createPhraseSet}. + * @param error Error, if any + * @param [response] Operation + */ + type CreatePhraseSetCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listPhraseSets}. + * @param error Error, if any + * @param [response] ListPhraseSetsResponse + */ + type ListPhraseSetsCallback = (error: (Error|null), response?: google.cloud.speech.v2.ListPhraseSetsResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getPhraseSet}. + * @param error Error, if any + * @param [response] PhraseSet + */ + type GetPhraseSetCallback = (error: (Error|null), response?: google.cloud.speech.v2.PhraseSet) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updatePhraseSet}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdatePhraseSetCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deletePhraseSet}. + * @param error Error, if any + * @param [response] Operation + */ + type DeletePhraseSetCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeletePhraseSet}. + * @param error Error, if any + * @param [response] Operation + */ + type UndeletePhraseSetCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateRecognizerRequest. */ + interface ICreateRecognizerRequest { + + /** CreateRecognizerRequest recognizer */ + recognizer?: (google.cloud.speech.v2.IRecognizer|null); + + /** CreateRecognizerRequest validateOnly */ + validateOnly?: (boolean|null); + + /** CreateRecognizerRequest recognizerId */ + recognizerId?: (string|null); + + /** CreateRecognizerRequest parent */ + parent?: (string|null); + } + + /** Represents a CreateRecognizerRequest. */ + class CreateRecognizerRequest implements ICreateRecognizerRequest { + + /** + * Constructs a new CreateRecognizerRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ICreateRecognizerRequest); + + /** CreateRecognizerRequest recognizer. */ + public recognizer?: (google.cloud.speech.v2.IRecognizer|null); + + /** CreateRecognizerRequest validateOnly. */ + public validateOnly: boolean; + + /** CreateRecognizerRequest recognizerId. */ + public recognizerId: string; + + /** CreateRecognizerRequest parent. */ + public parent: string; + + /** + * Creates a new CreateRecognizerRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateRecognizerRequest instance + */ + public static create(properties?: google.cloud.speech.v2.ICreateRecognizerRequest): google.cloud.speech.v2.CreateRecognizerRequest; + + /** + * Encodes the specified CreateRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.CreateRecognizerRequest.verify|verify} messages. + * @param message CreateRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ICreateRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreateRecognizerRequest.verify|verify} messages. + * @param message CreateRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ICreateRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateRecognizerRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateRecognizerRequest + * @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.v2.CreateRecognizerRequest; + + /** + * Decodes a CreateRecognizerRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateRecognizerRequest + * @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.v2.CreateRecognizerRequest; + + /** + * Verifies a CreateRecognizerRequest 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 CreateRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateRecognizerRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.CreateRecognizerRequest; + + /** + * Creates a plain object from a CreateRecognizerRequest message. Also converts values to other types if specified. + * @param message CreateRecognizerRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.CreateRecognizerRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateRecognizerRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateRecognizerRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OperationMetadata. */ + interface IOperationMetadata { + + /** OperationMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** OperationMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** OperationMetadata resource */ + resource?: (string|null); + + /** OperationMetadata method */ + method?: (string|null); + + /** OperationMetadata kmsKeyName */ + kmsKeyName?: (string|null); + + /** OperationMetadata kmsKeyVersionName */ + kmsKeyVersionName?: (string|null); + + /** OperationMetadata batchRecognizeRequest */ + batchRecognizeRequest?: (google.cloud.speech.v2.IBatchRecognizeRequest|null); + + /** OperationMetadata createRecognizerRequest */ + createRecognizerRequest?: (google.cloud.speech.v2.ICreateRecognizerRequest|null); + + /** OperationMetadata updateRecognizerRequest */ + updateRecognizerRequest?: (google.cloud.speech.v2.IUpdateRecognizerRequest|null); + + /** OperationMetadata deleteRecognizerRequest */ + deleteRecognizerRequest?: (google.cloud.speech.v2.IDeleteRecognizerRequest|null); + + /** OperationMetadata undeleteRecognizerRequest */ + undeleteRecognizerRequest?: (google.cloud.speech.v2.IUndeleteRecognizerRequest|null); + + /** OperationMetadata createCustomClassRequest */ + createCustomClassRequest?: (google.cloud.speech.v2.ICreateCustomClassRequest|null); + + /** OperationMetadata updateCustomClassRequest */ + updateCustomClassRequest?: (google.cloud.speech.v2.IUpdateCustomClassRequest|null); + + /** OperationMetadata deleteCustomClassRequest */ + deleteCustomClassRequest?: (google.cloud.speech.v2.IDeleteCustomClassRequest|null); + + /** OperationMetadata undeleteCustomClassRequest */ + undeleteCustomClassRequest?: (google.cloud.speech.v2.IUndeleteCustomClassRequest|null); + + /** OperationMetadata createPhraseSetRequest */ + createPhraseSetRequest?: (google.cloud.speech.v2.ICreatePhraseSetRequest|null); + + /** OperationMetadata updatePhraseSetRequest */ + updatePhraseSetRequest?: (google.cloud.speech.v2.IUpdatePhraseSetRequest|null); + + /** OperationMetadata deletePhraseSetRequest */ + deletePhraseSetRequest?: (google.cloud.speech.v2.IDeletePhraseSetRequest|null); + + /** OperationMetadata undeletePhraseSetRequest */ + undeletePhraseSetRequest?: (google.cloud.speech.v2.IUndeletePhraseSetRequest|null); + + /** OperationMetadata updateConfigRequest */ + updateConfigRequest?: (google.cloud.speech.v2.IUpdateConfigRequest|null); + + /** OperationMetadata progressPercent */ + progressPercent?: (number|null); + + /** OperationMetadata batchRecognizeMetadata */ + batchRecognizeMetadata?: (google.cloud.speech.v2.IBatchRecognizeMetadata|null); + } + + /** Represents an OperationMetadata. */ + class OperationMetadata implements IOperationMetadata { + + /** + * Constructs a new OperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IOperationMetadata); + + /** OperationMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** OperationMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** OperationMetadata resource. */ + public resource: string; + + /** OperationMetadata method. */ + public method: string; + + /** OperationMetadata kmsKeyName. */ + public kmsKeyName: string; + + /** OperationMetadata kmsKeyVersionName. */ + public kmsKeyVersionName: string; + + /** OperationMetadata batchRecognizeRequest. */ + public batchRecognizeRequest?: (google.cloud.speech.v2.IBatchRecognizeRequest|null); + + /** OperationMetadata createRecognizerRequest. */ + public createRecognizerRequest?: (google.cloud.speech.v2.ICreateRecognizerRequest|null); + + /** OperationMetadata updateRecognizerRequest. */ + public updateRecognizerRequest?: (google.cloud.speech.v2.IUpdateRecognizerRequest|null); + + /** OperationMetadata deleteRecognizerRequest. */ + public deleteRecognizerRequest?: (google.cloud.speech.v2.IDeleteRecognizerRequest|null); + + /** OperationMetadata undeleteRecognizerRequest. */ + public undeleteRecognizerRequest?: (google.cloud.speech.v2.IUndeleteRecognizerRequest|null); + + /** OperationMetadata createCustomClassRequest. */ + public createCustomClassRequest?: (google.cloud.speech.v2.ICreateCustomClassRequest|null); + + /** OperationMetadata updateCustomClassRequest. */ + public updateCustomClassRequest?: (google.cloud.speech.v2.IUpdateCustomClassRequest|null); + + /** OperationMetadata deleteCustomClassRequest. */ + public deleteCustomClassRequest?: (google.cloud.speech.v2.IDeleteCustomClassRequest|null); + + /** OperationMetadata undeleteCustomClassRequest. */ + public undeleteCustomClassRequest?: (google.cloud.speech.v2.IUndeleteCustomClassRequest|null); + + /** OperationMetadata createPhraseSetRequest. */ + public createPhraseSetRequest?: (google.cloud.speech.v2.ICreatePhraseSetRequest|null); + + /** OperationMetadata updatePhraseSetRequest. */ + public updatePhraseSetRequest?: (google.cloud.speech.v2.IUpdatePhraseSetRequest|null); + + /** OperationMetadata deletePhraseSetRequest. */ + public deletePhraseSetRequest?: (google.cloud.speech.v2.IDeletePhraseSetRequest|null); + + /** OperationMetadata undeletePhraseSetRequest. */ + public undeletePhraseSetRequest?: (google.cloud.speech.v2.IUndeletePhraseSetRequest|null); + + /** OperationMetadata updateConfigRequest. */ + public updateConfigRequest?: (google.cloud.speech.v2.IUpdateConfigRequest|null); + + /** OperationMetadata progressPercent. */ + public progressPercent: number; + + /** OperationMetadata batchRecognizeMetadata. */ + public batchRecognizeMetadata?: (google.cloud.speech.v2.IBatchRecognizeMetadata|null); + + /** OperationMetadata request. */ + public request?: ("batchRecognizeRequest"|"createRecognizerRequest"|"updateRecognizerRequest"|"deleteRecognizerRequest"|"undeleteRecognizerRequest"|"createCustomClassRequest"|"updateCustomClassRequest"|"deleteCustomClassRequest"|"undeleteCustomClassRequest"|"createPhraseSetRequest"|"updatePhraseSetRequest"|"deletePhraseSetRequest"|"undeletePhraseSetRequest"|"updateConfigRequest"); + + /** OperationMetadata metadata. */ + public metadata?: "batchRecognizeMetadata"; + + /** + * Creates a new OperationMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns OperationMetadata instance + */ + public static create(properties?: google.cloud.speech.v2.IOperationMetadata): google.cloud.speech.v2.OperationMetadata; + + /** + * Encodes the specified OperationMetadata message. Does not implicitly {@link google.cloud.speech.v2.OperationMetadata.verify|verify} messages. + * @param message OperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OperationMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.OperationMetadata.verify|verify} messages. + * @param message OperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OperationMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OperationMetadata + * @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.v2.OperationMetadata; + + /** + * Decodes an OperationMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OperationMetadata + * @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.v2.OperationMetadata; + + /** + * Verifies an OperationMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.OperationMetadata; + + /** + * Creates a plain object from an OperationMetadata message. Also converts values to other types if specified. + * @param message OperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.OperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OperationMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListRecognizersRequest. */ + interface IListRecognizersRequest { + + /** ListRecognizersRequest parent */ + parent?: (string|null); + + /** ListRecognizersRequest pageSize */ + pageSize?: (number|null); + + /** ListRecognizersRequest pageToken */ + pageToken?: (string|null); + + /** ListRecognizersRequest showDeleted */ + showDeleted?: (boolean|null); + } + + /** Represents a ListRecognizersRequest. */ + class ListRecognizersRequest implements IListRecognizersRequest { + + /** + * Constructs a new ListRecognizersRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListRecognizersRequest); + + /** ListRecognizersRequest parent. */ + public parent: string; + + /** ListRecognizersRequest pageSize. */ + public pageSize: number; + + /** ListRecognizersRequest pageToken. */ + public pageToken: string; + + /** ListRecognizersRequest showDeleted. */ + public showDeleted: boolean; + + /** + * Creates a new ListRecognizersRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListRecognizersRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IListRecognizersRequest): google.cloud.speech.v2.ListRecognizersRequest; + + /** + * Encodes the specified ListRecognizersRequest message. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersRequest.verify|verify} messages. + * @param message ListRecognizersRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListRecognizersRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListRecognizersRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersRequest.verify|verify} messages. + * @param message ListRecognizersRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListRecognizersRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListRecognizersRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListRecognizersRequest + * @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.v2.ListRecognizersRequest; + + /** + * Decodes a ListRecognizersRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListRecognizersRequest + * @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.v2.ListRecognizersRequest; + + /** + * Verifies a ListRecognizersRequest 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 ListRecognizersRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListRecognizersRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListRecognizersRequest; + + /** + * Creates a plain object from a ListRecognizersRequest message. Also converts values to other types if specified. + * @param message ListRecognizersRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListRecognizersRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListRecognizersRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListRecognizersRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListRecognizersResponse. */ + interface IListRecognizersResponse { + + /** ListRecognizersResponse recognizers */ + recognizers?: (google.cloud.speech.v2.IRecognizer[]|null); + + /** ListRecognizersResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListRecognizersResponse. */ + class ListRecognizersResponse implements IListRecognizersResponse { + + /** + * Constructs a new ListRecognizersResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListRecognizersResponse); + + /** ListRecognizersResponse recognizers. */ + public recognizers: google.cloud.speech.v2.IRecognizer[]; + + /** ListRecognizersResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListRecognizersResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListRecognizersResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IListRecognizersResponse): google.cloud.speech.v2.ListRecognizersResponse; + + /** + * Encodes the specified ListRecognizersResponse message. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersResponse.verify|verify} messages. + * @param message ListRecognizersResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListRecognizersResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListRecognizersResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersResponse.verify|verify} messages. + * @param message ListRecognizersResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListRecognizersResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListRecognizersResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListRecognizersResponse + * @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.v2.ListRecognizersResponse; + + /** + * Decodes a ListRecognizersResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListRecognizersResponse + * @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.v2.ListRecognizersResponse; + + /** + * Verifies a ListRecognizersResponse 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 ListRecognizersResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListRecognizersResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListRecognizersResponse; + + /** + * Creates a plain object from a ListRecognizersResponse message. Also converts values to other types if specified. + * @param message ListRecognizersResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListRecognizersResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListRecognizersResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListRecognizersResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetRecognizerRequest. */ + interface IGetRecognizerRequest { + + /** GetRecognizerRequest name */ + name?: (string|null); + } + + /** Represents a GetRecognizerRequest. */ + class GetRecognizerRequest implements IGetRecognizerRequest { + + /** + * Constructs a new GetRecognizerRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IGetRecognizerRequest); + + /** GetRecognizerRequest name. */ + public name: string; + + /** + * Creates a new GetRecognizerRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetRecognizerRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IGetRecognizerRequest): google.cloud.speech.v2.GetRecognizerRequest; + + /** + * Encodes the specified GetRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.GetRecognizerRequest.verify|verify} messages. + * @param message GetRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IGetRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetRecognizerRequest.verify|verify} messages. + * @param message GetRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IGetRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetRecognizerRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetRecognizerRequest + * @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.v2.GetRecognizerRequest; + + /** + * Decodes a GetRecognizerRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetRecognizerRequest + * @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.v2.GetRecognizerRequest; + + /** + * Verifies a GetRecognizerRequest 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 GetRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetRecognizerRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.GetRecognizerRequest; + + /** + * Creates a plain object from a GetRecognizerRequest message. Also converts values to other types if specified. + * @param message GetRecognizerRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.GetRecognizerRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetRecognizerRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetRecognizerRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateRecognizerRequest. */ + interface IUpdateRecognizerRequest { + + /** UpdateRecognizerRequest recognizer */ + recognizer?: (google.cloud.speech.v2.IRecognizer|null); + + /** UpdateRecognizerRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateRecognizerRequest validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents an UpdateRecognizerRequest. */ + class UpdateRecognizerRequest implements IUpdateRecognizerRequest { + + /** + * Constructs a new UpdateRecognizerRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUpdateRecognizerRequest); + + /** UpdateRecognizerRequest recognizer. */ + public recognizer?: (google.cloud.speech.v2.IRecognizer|null); + + /** UpdateRecognizerRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateRecognizerRequest validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new UpdateRecognizerRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateRecognizerRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUpdateRecognizerRequest): google.cloud.speech.v2.UpdateRecognizerRequest; + + /** + * Encodes the specified UpdateRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateRecognizerRequest.verify|verify} messages. + * @param message UpdateRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUpdateRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateRecognizerRequest.verify|verify} messages. + * @param message UpdateRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUpdateRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateRecognizerRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateRecognizerRequest + * @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.v2.UpdateRecognizerRequest; + + /** + * Decodes an UpdateRecognizerRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateRecognizerRequest + * @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.v2.UpdateRecognizerRequest; + + /** + * Verifies an UpdateRecognizerRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateRecognizerRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UpdateRecognizerRequest; + + /** + * Creates a plain object from an UpdateRecognizerRequest message. Also converts values to other types if specified. + * @param message UpdateRecognizerRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UpdateRecognizerRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateRecognizerRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateRecognizerRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteRecognizerRequest. */ + interface IDeleteRecognizerRequest { + + /** DeleteRecognizerRequest name */ + name?: (string|null); + + /** DeleteRecognizerRequest validateOnly */ + validateOnly?: (boolean|null); + + /** DeleteRecognizerRequest allowMissing */ + allowMissing?: (boolean|null); + + /** DeleteRecognizerRequest etag */ + etag?: (string|null); + } + + /** Represents a DeleteRecognizerRequest. */ + class DeleteRecognizerRequest implements IDeleteRecognizerRequest { + + /** + * Constructs a new DeleteRecognizerRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IDeleteRecognizerRequest); + + /** DeleteRecognizerRequest name. */ + public name: string; + + /** DeleteRecognizerRequest validateOnly. */ + public validateOnly: boolean; + + /** DeleteRecognizerRequest allowMissing. */ + public allowMissing: boolean; + + /** DeleteRecognizerRequest etag. */ + public etag: string; + + /** + * Creates a new DeleteRecognizerRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteRecognizerRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IDeleteRecognizerRequest): google.cloud.speech.v2.DeleteRecognizerRequest; + + /** + * Encodes the specified DeleteRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.DeleteRecognizerRequest.verify|verify} messages. + * @param message DeleteRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IDeleteRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeleteRecognizerRequest.verify|verify} messages. + * @param message DeleteRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IDeleteRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteRecognizerRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteRecognizerRequest + * @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.v2.DeleteRecognizerRequest; + + /** + * Decodes a DeleteRecognizerRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteRecognizerRequest + * @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.v2.DeleteRecognizerRequest; + + /** + * Verifies a DeleteRecognizerRequest 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 DeleteRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteRecognizerRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.DeleteRecognizerRequest; + + /** + * Creates a plain object from a DeleteRecognizerRequest message. Also converts values to other types if specified. + * @param message DeleteRecognizerRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.DeleteRecognizerRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteRecognizerRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteRecognizerRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UndeleteRecognizerRequest. */ + interface IUndeleteRecognizerRequest { + + /** UndeleteRecognizerRequest name */ + name?: (string|null); + + /** UndeleteRecognizerRequest validateOnly */ + validateOnly?: (boolean|null); + + /** UndeleteRecognizerRequest etag */ + etag?: (string|null); + } + + /** Represents an UndeleteRecognizerRequest. */ + class UndeleteRecognizerRequest implements IUndeleteRecognizerRequest { + + /** + * Constructs a new UndeleteRecognizerRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUndeleteRecognizerRequest); + + /** UndeleteRecognizerRequest name. */ + public name: string; + + /** UndeleteRecognizerRequest validateOnly. */ + public validateOnly: boolean; + + /** UndeleteRecognizerRequest etag. */ + public etag: string; + + /** + * Creates a new UndeleteRecognizerRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UndeleteRecognizerRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUndeleteRecognizerRequest): google.cloud.speech.v2.UndeleteRecognizerRequest; + + /** + * Encodes the specified UndeleteRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeleteRecognizerRequest.verify|verify} messages. + * @param message UndeleteRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUndeleteRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UndeleteRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeleteRecognizerRequest.verify|verify} messages. + * @param message UndeleteRecognizerRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUndeleteRecognizerRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UndeleteRecognizerRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UndeleteRecognizerRequest + * @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.v2.UndeleteRecognizerRequest; + + /** + * Decodes an UndeleteRecognizerRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UndeleteRecognizerRequest + * @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.v2.UndeleteRecognizerRequest; + + /** + * Verifies an UndeleteRecognizerRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UndeleteRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UndeleteRecognizerRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UndeleteRecognizerRequest; + + /** + * Creates a plain object from an UndeleteRecognizerRequest message. Also converts values to other types if specified. + * @param message UndeleteRecognizerRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UndeleteRecognizerRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UndeleteRecognizerRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UndeleteRecognizerRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Recognizer. */ + interface IRecognizer { + + /** Recognizer name */ + name?: (string|null); + + /** Recognizer uid */ + uid?: (string|null); + + /** Recognizer displayName */ + displayName?: (string|null); + + /** Recognizer model */ + model?: (string|null); + + /** Recognizer languageCodes */ + languageCodes?: (string[]|null); + + /** Recognizer defaultRecognitionConfig */ + defaultRecognitionConfig?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** Recognizer annotations */ + annotations?: ({ [k: string]: string }|null); + + /** Recognizer state */ + state?: (google.cloud.speech.v2.Recognizer.State|keyof typeof google.cloud.speech.v2.Recognizer.State|null); + + /** Recognizer createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer deleteTime */ + deleteTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer etag */ + etag?: (string|null); + + /** Recognizer reconciling */ + reconciling?: (boolean|null); + + /** Recognizer kmsKeyName */ + kmsKeyName?: (string|null); + + /** Recognizer kmsKeyVersionName */ + kmsKeyVersionName?: (string|null); + } + + /** Represents a Recognizer. */ + class Recognizer implements IRecognizer { + + /** + * Constructs a new Recognizer. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognizer); + + /** Recognizer name. */ + public name: string; + + /** Recognizer uid. */ + public uid: string; + + /** Recognizer displayName. */ + public displayName: string; + + /** Recognizer model. */ + public model: string; + + /** Recognizer languageCodes. */ + public languageCodes: string[]; + + /** Recognizer defaultRecognitionConfig. */ + public defaultRecognitionConfig?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** Recognizer annotations. */ + public annotations: { [k: string]: string }; + + /** Recognizer state. */ + public state: (google.cloud.speech.v2.Recognizer.State|keyof typeof google.cloud.speech.v2.Recognizer.State); + + /** Recognizer createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer deleteTime. */ + public deleteTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** Recognizer etag. */ + public etag: string; + + /** Recognizer reconciling. */ + public reconciling: boolean; + + /** Recognizer kmsKeyName. */ + public kmsKeyName: string; + + /** Recognizer kmsKeyVersionName. */ + public kmsKeyVersionName: string; + + /** + * Creates a new Recognizer instance using the specified properties. + * @param [properties] Properties to set + * @returns Recognizer instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognizer): google.cloud.speech.v2.Recognizer; + + /** + * Encodes the specified Recognizer message. Does not implicitly {@link google.cloud.speech.v2.Recognizer.verify|verify} messages. + * @param message Recognizer message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognizer, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Recognizer message, length delimited. Does not implicitly {@link google.cloud.speech.v2.Recognizer.verify|verify} messages. + * @param message Recognizer message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognizer, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Recognizer message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Recognizer + * @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.v2.Recognizer; + + /** + * Decodes a Recognizer message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Recognizer + * @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.v2.Recognizer; + + /** + * Verifies a Recognizer 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 Recognizer message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Recognizer + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.Recognizer; + + /** + * Creates a plain object from a Recognizer message. Also converts values to other types if specified. + * @param message Recognizer + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.Recognizer, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Recognizer to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Recognizer + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Recognizer { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 2, + DELETED = 4 + } + } + + /** Properties of an AutoDetectDecodingConfig. */ + interface IAutoDetectDecodingConfig { + } + + /** Represents an AutoDetectDecodingConfig. */ + class AutoDetectDecodingConfig implements IAutoDetectDecodingConfig { + + /** + * Constructs a new AutoDetectDecodingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IAutoDetectDecodingConfig); + + /** + * Creates a new AutoDetectDecodingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns AutoDetectDecodingConfig instance + */ + public static create(properties?: google.cloud.speech.v2.IAutoDetectDecodingConfig): google.cloud.speech.v2.AutoDetectDecodingConfig; + + /** + * Encodes the specified AutoDetectDecodingConfig message. Does not implicitly {@link google.cloud.speech.v2.AutoDetectDecodingConfig.verify|verify} messages. + * @param message AutoDetectDecodingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IAutoDetectDecodingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AutoDetectDecodingConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.AutoDetectDecodingConfig.verify|verify} messages. + * @param message AutoDetectDecodingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IAutoDetectDecodingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AutoDetectDecodingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AutoDetectDecodingConfig + * @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.v2.AutoDetectDecodingConfig; + + /** + * Decodes an AutoDetectDecodingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AutoDetectDecodingConfig + * @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.v2.AutoDetectDecodingConfig; + + /** + * Verifies an AutoDetectDecodingConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AutoDetectDecodingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AutoDetectDecodingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.AutoDetectDecodingConfig; + + /** + * Creates a plain object from an AutoDetectDecodingConfig message. Also converts values to other types if specified. + * @param message AutoDetectDecodingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.AutoDetectDecodingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AutoDetectDecodingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AutoDetectDecodingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExplicitDecodingConfig. */ + interface IExplicitDecodingConfig { + + /** ExplicitDecodingConfig encoding */ + encoding?: (google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding|keyof typeof google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding|null); + + /** ExplicitDecodingConfig sampleRateHertz */ + sampleRateHertz?: (number|null); + + /** ExplicitDecodingConfig audioChannelCount */ + audioChannelCount?: (number|null); + } + + /** Represents an ExplicitDecodingConfig. */ + class ExplicitDecodingConfig implements IExplicitDecodingConfig { + + /** + * Constructs a new ExplicitDecodingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IExplicitDecodingConfig); + + /** ExplicitDecodingConfig encoding. */ + public encoding: (google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding|keyof typeof google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding); + + /** ExplicitDecodingConfig sampleRateHertz. */ + public sampleRateHertz: number; + + /** ExplicitDecodingConfig audioChannelCount. */ + public audioChannelCount: number; + + /** + * Creates a new ExplicitDecodingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ExplicitDecodingConfig instance + */ + public static create(properties?: google.cloud.speech.v2.IExplicitDecodingConfig): google.cloud.speech.v2.ExplicitDecodingConfig; + + /** + * Encodes the specified ExplicitDecodingConfig message. Does not implicitly {@link google.cloud.speech.v2.ExplicitDecodingConfig.verify|verify} messages. + * @param message ExplicitDecodingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IExplicitDecodingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExplicitDecodingConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ExplicitDecodingConfig.verify|verify} messages. + * @param message ExplicitDecodingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IExplicitDecodingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExplicitDecodingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExplicitDecodingConfig + * @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.v2.ExplicitDecodingConfig; + + /** + * Decodes an ExplicitDecodingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExplicitDecodingConfig + * @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.v2.ExplicitDecodingConfig; + + /** + * Verifies an ExplicitDecodingConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExplicitDecodingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExplicitDecodingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ExplicitDecodingConfig; + + /** + * Creates a plain object from an ExplicitDecodingConfig message. Also converts values to other types if specified. + * @param message ExplicitDecodingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ExplicitDecodingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExplicitDecodingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExplicitDecodingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ExplicitDecodingConfig { + + /** AudioEncoding enum. */ + enum AudioEncoding { + AUDIO_ENCODING_UNSPECIFIED = 0, + LINEAR16 = 1, + MULAW = 2, + ALAW = 3 + } + } + + /** Properties of a SpeakerDiarizationConfig. */ + interface ISpeakerDiarizationConfig { + + /** SpeakerDiarizationConfig minSpeakerCount */ + minSpeakerCount?: (number|null); + + /** SpeakerDiarizationConfig maxSpeakerCount */ + maxSpeakerCount?: (number|null); + } + + /** Represents a SpeakerDiarizationConfig. */ + class SpeakerDiarizationConfig implements ISpeakerDiarizationConfig { + + /** + * Constructs a new SpeakerDiarizationConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ISpeakerDiarizationConfig); + + /** SpeakerDiarizationConfig minSpeakerCount. */ + public minSpeakerCount: number; + + /** SpeakerDiarizationConfig maxSpeakerCount. */ + public maxSpeakerCount: number; + + /** + * Creates a new SpeakerDiarizationConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeakerDiarizationConfig instance + */ + public static create(properties?: google.cloud.speech.v2.ISpeakerDiarizationConfig): google.cloud.speech.v2.SpeakerDiarizationConfig; + + /** + * Encodes the specified SpeakerDiarizationConfig message. Does not implicitly {@link google.cloud.speech.v2.SpeakerDiarizationConfig.verify|verify} messages. + * @param message SpeakerDiarizationConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ISpeakerDiarizationConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeakerDiarizationConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeakerDiarizationConfig.verify|verify} messages. + * @param message SpeakerDiarizationConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ISpeakerDiarizationConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeakerDiarizationConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeakerDiarizationConfig + * @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.v2.SpeakerDiarizationConfig; + + /** + * Decodes a SpeakerDiarizationConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeakerDiarizationConfig + * @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.v2.SpeakerDiarizationConfig; + + /** + * Verifies a SpeakerDiarizationConfig 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 SpeakerDiarizationConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeakerDiarizationConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.SpeakerDiarizationConfig; + + /** + * Creates a plain object from a SpeakerDiarizationConfig message. Also converts values to other types if specified. + * @param message SpeakerDiarizationConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.SpeakerDiarizationConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeakerDiarizationConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeakerDiarizationConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecognitionFeatures. */ + interface IRecognitionFeatures { + + /** RecognitionFeatures profanityFilter */ + profanityFilter?: (boolean|null); + + /** RecognitionFeatures enableWordTimeOffsets */ + enableWordTimeOffsets?: (boolean|null); + + /** RecognitionFeatures enableWordConfidence */ + enableWordConfidence?: (boolean|null); + + /** RecognitionFeatures enableAutomaticPunctuation */ + enableAutomaticPunctuation?: (boolean|null); + + /** RecognitionFeatures enableSpokenPunctuation */ + enableSpokenPunctuation?: (boolean|null); + + /** RecognitionFeatures enableSpokenEmojis */ + enableSpokenEmojis?: (boolean|null); + + /** RecognitionFeatures multiChannelMode */ + multiChannelMode?: (google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode|keyof typeof google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode|null); + + /** RecognitionFeatures diarizationConfig */ + diarizationConfig?: (google.cloud.speech.v2.ISpeakerDiarizationConfig|null); + + /** RecognitionFeatures maxAlternatives */ + maxAlternatives?: (number|null); + } + + /** Represents a RecognitionFeatures. */ + class RecognitionFeatures implements IRecognitionFeatures { + + /** + * Constructs a new RecognitionFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognitionFeatures); + + /** RecognitionFeatures profanityFilter. */ + public profanityFilter: boolean; + + /** RecognitionFeatures enableWordTimeOffsets. */ + public enableWordTimeOffsets: boolean; + + /** RecognitionFeatures enableWordConfidence. */ + public enableWordConfidence: boolean; + + /** RecognitionFeatures enableAutomaticPunctuation. */ + public enableAutomaticPunctuation: boolean; + + /** RecognitionFeatures enableSpokenPunctuation. */ + public enableSpokenPunctuation: boolean; + + /** RecognitionFeatures enableSpokenEmojis. */ + public enableSpokenEmojis: boolean; + + /** RecognitionFeatures multiChannelMode. */ + public multiChannelMode: (google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode|keyof typeof google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode); + + /** RecognitionFeatures diarizationConfig. */ + public diarizationConfig?: (google.cloud.speech.v2.ISpeakerDiarizationConfig|null); + + /** RecognitionFeatures maxAlternatives. */ + public maxAlternatives: number; + + /** + * Creates a new RecognitionFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns RecognitionFeatures instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognitionFeatures): google.cloud.speech.v2.RecognitionFeatures; + + /** + * Encodes the specified RecognitionFeatures message. Does not implicitly {@link google.cloud.speech.v2.RecognitionFeatures.verify|verify} messages. + * @param message RecognitionFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognitionFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecognitionFeatures message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionFeatures.verify|verify} messages. + * @param message RecognitionFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognitionFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecognitionFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecognitionFeatures + * @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.v2.RecognitionFeatures; + + /** + * Decodes a RecognitionFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecognitionFeatures + * @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.v2.RecognitionFeatures; + + /** + * Verifies a RecognitionFeatures 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 RecognitionFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecognitionFeatures + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.RecognitionFeatures; + + /** + * Creates a plain object from a RecognitionFeatures message. Also converts values to other types if specified. + * @param message RecognitionFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.RecognitionFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecognitionFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecognitionFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace RecognitionFeatures { + + /** MultiChannelMode enum. */ + enum MultiChannelMode { + MULTI_CHANNEL_MODE_UNSPECIFIED = 0, + SEPARATE_RECOGNITION_PER_CHANNEL = 1 + } + } + + /** Properties of a SpeechAdaptation. */ + interface ISpeechAdaptation { + + /** SpeechAdaptation phraseSets */ + phraseSets?: (google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet[]|null); + + /** SpeechAdaptation customClasses */ + customClasses?: (google.cloud.speech.v2.ICustomClass[]|null); + } + + /** Represents a SpeechAdaptation. */ + class SpeechAdaptation implements ISpeechAdaptation { + + /** + * Constructs a new SpeechAdaptation. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ISpeechAdaptation); + + /** SpeechAdaptation phraseSets. */ + public phraseSets: google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet[]; + + /** SpeechAdaptation customClasses. */ + public customClasses: google.cloud.speech.v2.ICustomClass[]; + + /** + * Creates a new SpeechAdaptation instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechAdaptation instance + */ + public static create(properties?: google.cloud.speech.v2.ISpeechAdaptation): google.cloud.speech.v2.SpeechAdaptation; + + /** + * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v2.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.v2.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * 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 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.v2.SpeechAdaptation; + + /** + * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @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.v2.SpeechAdaptation; + + /** + * 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 SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechAdaptation + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.SpeechAdaptation; + + /** + * 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.v2.SpeechAdaptation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechAdaptation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeechAdaptation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SpeechAdaptation { + + /** Properties of an AdaptationPhraseSet. */ + interface IAdaptationPhraseSet { + + /** AdaptationPhraseSet phraseSet */ + phraseSet?: (string|null); + + /** AdaptationPhraseSet inlinePhraseSet */ + inlinePhraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + } + + /** Represents an AdaptationPhraseSet. */ + class AdaptationPhraseSet implements IAdaptationPhraseSet { + + /** + * Constructs a new AdaptationPhraseSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet); + + /** AdaptationPhraseSet phraseSet. */ + public phraseSet?: (string|null); + + /** AdaptationPhraseSet inlinePhraseSet. */ + public inlinePhraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + + /** AdaptationPhraseSet value. */ + public value?: ("phraseSet"|"inlinePhraseSet"); + + /** + * Creates a new AdaptationPhraseSet instance using the specified properties. + * @param [properties] Properties to set + * @returns AdaptationPhraseSet instance + */ + public static create(properties?: google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet): google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet; + + /** + * Encodes the specified AdaptationPhraseSet message. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.verify|verify} messages. + * @param message AdaptationPhraseSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AdaptationPhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.verify|verify} messages. + * @param message AdaptationPhraseSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AdaptationPhraseSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AdaptationPhraseSet + * @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.v2.SpeechAdaptation.AdaptationPhraseSet; + + /** + * Decodes an AdaptationPhraseSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AdaptationPhraseSet + * @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.v2.SpeechAdaptation.AdaptationPhraseSet; + + /** + * Verifies an AdaptationPhraseSet message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AdaptationPhraseSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AdaptationPhraseSet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet; + + /** + * Creates a plain object from an AdaptationPhraseSet message. Also converts values to other types if specified. + * @param message AdaptationPhraseSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AdaptationPhraseSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AdaptationPhraseSet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a RecognitionConfig. */ + interface IRecognitionConfig { + + /** RecognitionConfig autoDecodingConfig */ + autoDecodingConfig?: (google.cloud.speech.v2.IAutoDetectDecodingConfig|null); + + /** RecognitionConfig explicitDecodingConfig */ + explicitDecodingConfig?: (google.cloud.speech.v2.IExplicitDecodingConfig|null); + + /** RecognitionConfig features */ + features?: (google.cloud.speech.v2.IRecognitionFeatures|null); + + /** RecognitionConfig adaptation */ + adaptation?: (google.cloud.speech.v2.ISpeechAdaptation|null); + } + + /** Represents a RecognitionConfig. */ + class RecognitionConfig implements IRecognitionConfig { + + /** + * Constructs a new RecognitionConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognitionConfig); + + /** RecognitionConfig autoDecodingConfig. */ + public autoDecodingConfig?: (google.cloud.speech.v2.IAutoDetectDecodingConfig|null); + + /** RecognitionConfig explicitDecodingConfig. */ + public explicitDecodingConfig?: (google.cloud.speech.v2.IExplicitDecodingConfig|null); + + /** RecognitionConfig features. */ + public features?: (google.cloud.speech.v2.IRecognitionFeatures|null); + + /** RecognitionConfig adaptation. */ + public adaptation?: (google.cloud.speech.v2.ISpeechAdaptation|null); + + /** RecognitionConfig decodingConfig. */ + public decodingConfig?: ("autoDecodingConfig"|"explicitDecodingConfig"); + + /** + * Creates a new RecognitionConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns RecognitionConfig instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognitionConfig): google.cloud.speech.v2.RecognitionConfig; + + /** + * Encodes the specified RecognitionConfig message. Does not implicitly {@link google.cloud.speech.v2.RecognitionConfig.verify|verify} messages. + * @param message RecognitionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognitionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecognitionConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionConfig.verify|verify} messages. + * @param message RecognitionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognitionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecognitionConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecognitionConfig + * @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.v2.RecognitionConfig; + + /** + * Decodes a RecognitionConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecognitionConfig + * @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.v2.RecognitionConfig; + + /** + * Verifies a RecognitionConfig 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 RecognitionConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecognitionConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.RecognitionConfig; + + /** + * Creates a plain object from a RecognitionConfig message. Also converts values to other types if specified. + * @param message RecognitionConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.RecognitionConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecognitionConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecognitionConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecognizeRequest. */ + interface IRecognizeRequest { + + /** RecognizeRequest recognizer */ + recognizer?: (string|null); + + /** RecognizeRequest config */ + config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** RecognizeRequest configMask */ + configMask?: (google.protobuf.IFieldMask|null); + + /** RecognizeRequest content */ + content?: (Uint8Array|string|null); + + /** RecognizeRequest uri */ + uri?: (string|null); + } + + /** Represents a RecognizeRequest. */ + class RecognizeRequest implements IRecognizeRequest { + + /** + * Constructs a new RecognizeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognizeRequest); + + /** RecognizeRequest recognizer. */ + public recognizer: string; + + /** RecognizeRequest config. */ + public config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** RecognizeRequest configMask. */ + public configMask?: (google.protobuf.IFieldMask|null); + + /** RecognizeRequest content. */ + public content?: (Uint8Array|string|null); + + /** RecognizeRequest uri. */ + public uri?: (string|null); + + /** RecognizeRequest audioSource. */ + public audioSource?: ("content"|"uri"); + + /** + * Creates a new RecognizeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RecognizeRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognizeRequest): google.cloud.speech.v2.RecognizeRequest; + + /** + * Encodes the specified RecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.RecognizeRequest.verify|verify} messages. + * @param message RecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognizeRequest.verify|verify} messages. + * @param message RecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecognizeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecognizeRequest + * @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.v2.RecognizeRequest; + + /** + * Decodes a RecognizeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecognizeRequest + * @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.v2.RecognizeRequest; + + /** + * Verifies a RecognizeRequest 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 RecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecognizeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.RecognizeRequest; + + /** + * Creates a plain object from a RecognizeRequest message. Also converts values to other types if specified. + * @param message RecognizeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.RecognizeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecognizeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecognizeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecognitionResponseMetadata. */ + interface IRecognitionResponseMetadata { + + /** RecognitionResponseMetadata totalBilledDuration */ + totalBilledDuration?: (google.protobuf.IDuration|null); + } + + /** Represents a RecognitionResponseMetadata. */ + class RecognitionResponseMetadata implements IRecognitionResponseMetadata { + + /** + * Constructs a new RecognitionResponseMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognitionResponseMetadata); + + /** RecognitionResponseMetadata totalBilledDuration. */ + public totalBilledDuration?: (google.protobuf.IDuration|null); + + /** + * Creates a new RecognitionResponseMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RecognitionResponseMetadata instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognitionResponseMetadata): google.cloud.speech.v2.RecognitionResponseMetadata; + + /** + * Encodes the specified RecognitionResponseMetadata message. Does not implicitly {@link google.cloud.speech.v2.RecognitionResponseMetadata.verify|verify} messages. + * @param message RecognitionResponseMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognitionResponseMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecognitionResponseMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionResponseMetadata.verify|verify} messages. + * @param message RecognitionResponseMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognitionResponseMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecognitionResponseMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecognitionResponseMetadata + * @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.v2.RecognitionResponseMetadata; + + /** + * Decodes a RecognitionResponseMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecognitionResponseMetadata + * @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.v2.RecognitionResponseMetadata; + + /** + * Verifies a RecognitionResponseMetadata 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 RecognitionResponseMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecognitionResponseMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.RecognitionResponseMetadata; + + /** + * Creates a plain object from a RecognitionResponseMetadata message. Also converts values to other types if specified. + * @param message RecognitionResponseMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.RecognitionResponseMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecognitionResponseMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecognitionResponseMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SpeechRecognitionAlternative. */ + interface ISpeechRecognitionAlternative { + + /** SpeechRecognitionAlternative transcript */ + transcript?: (string|null); + + /** SpeechRecognitionAlternative confidence */ + confidence?: (number|null); + + /** SpeechRecognitionAlternative words */ + words?: (google.cloud.speech.v2.IWordInfo[]|null); + } + + /** Represents a SpeechRecognitionAlternative. */ + class SpeechRecognitionAlternative implements ISpeechRecognitionAlternative { + + /** + * Constructs a new SpeechRecognitionAlternative. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ISpeechRecognitionAlternative); + + /** SpeechRecognitionAlternative transcript. */ + public transcript: string; + + /** SpeechRecognitionAlternative confidence. */ + public confidence: number; + + /** SpeechRecognitionAlternative words. */ + public words: google.cloud.speech.v2.IWordInfo[]; + + /** + * Creates a new SpeechRecognitionAlternative instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechRecognitionAlternative instance + */ + public static create(properties?: google.cloud.speech.v2.ISpeechRecognitionAlternative): google.cloud.speech.v2.SpeechRecognitionAlternative; + + /** + * Encodes the specified SpeechRecognitionAlternative message. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionAlternative.verify|verify} messages. + * @param message SpeechRecognitionAlternative message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ISpeechRecognitionAlternative, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechRecognitionAlternative message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionAlternative.verify|verify} messages. + * @param message SpeechRecognitionAlternative message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ISpeechRecognitionAlternative, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeechRecognitionAlternative message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeechRecognitionAlternative + * @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.v2.SpeechRecognitionAlternative; + + /** + * Decodes a SpeechRecognitionAlternative message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeechRecognitionAlternative + * @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.v2.SpeechRecognitionAlternative; + + /** + * Verifies a SpeechRecognitionAlternative 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 SpeechRecognitionAlternative message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechRecognitionAlternative + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.SpeechRecognitionAlternative; + + /** + * Creates a plain object from a SpeechRecognitionAlternative message. Also converts values to other types if specified. + * @param message SpeechRecognitionAlternative + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.SpeechRecognitionAlternative, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechRecognitionAlternative to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeechRecognitionAlternative + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a WordInfo. */ + interface IWordInfo { + + /** WordInfo startOffset */ + startOffset?: (google.protobuf.IDuration|null); + + /** WordInfo endOffset */ + endOffset?: (google.protobuf.IDuration|null); + + /** WordInfo word */ + word?: (string|null); + + /** WordInfo confidence */ + confidence?: (number|null); + + /** WordInfo speakerLabel */ + speakerLabel?: (string|null); + } + + /** Represents a WordInfo. */ + class WordInfo implements IWordInfo { + + /** + * Constructs a new WordInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IWordInfo); + + /** WordInfo startOffset. */ + public startOffset?: (google.protobuf.IDuration|null); + + /** WordInfo endOffset. */ + public endOffset?: (google.protobuf.IDuration|null); + + /** WordInfo word. */ + public word: string; + + /** WordInfo confidence. */ + public confidence: number; + + /** WordInfo speakerLabel. */ + public speakerLabel: string; + + /** + * Creates a new WordInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns WordInfo instance + */ + public static create(properties?: google.cloud.speech.v2.IWordInfo): google.cloud.speech.v2.WordInfo; + + /** + * Encodes the specified WordInfo message. Does not implicitly {@link google.cloud.speech.v2.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.v2.IWordInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WordInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.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.v2.WordInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WordInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WordInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SpeechRecognitionResult. */ + interface ISpeechRecognitionResult { + + /** SpeechRecognitionResult alternatives */ + alternatives?: (google.cloud.speech.v2.ISpeechRecognitionAlternative[]|null); + + /** SpeechRecognitionResult channelTag */ + channelTag?: (number|null); + + /** SpeechRecognitionResult resultEndOffset */ + resultEndOffset?: (google.protobuf.IDuration|null); + + /** SpeechRecognitionResult languageCode */ + languageCode?: (string|null); + } + + /** Represents a SpeechRecognitionResult. */ + class SpeechRecognitionResult implements ISpeechRecognitionResult { + + /** + * Constructs a new SpeechRecognitionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ISpeechRecognitionResult); + + /** SpeechRecognitionResult alternatives. */ + public alternatives: google.cloud.speech.v2.ISpeechRecognitionAlternative[]; + + /** SpeechRecognitionResult channelTag. */ + public channelTag: number; + + /** SpeechRecognitionResult resultEndOffset. */ + public resultEndOffset?: (google.protobuf.IDuration|null); + + /** SpeechRecognitionResult languageCode. */ + public languageCode: string; + + /** + * Creates a new SpeechRecognitionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechRecognitionResult instance + */ + public static create(properties?: google.cloud.speech.v2.ISpeechRecognitionResult): google.cloud.speech.v2.SpeechRecognitionResult; + + /** + * Encodes the specified SpeechRecognitionResult message. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionResult.verify|verify} messages. + * @param message SpeechRecognitionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ISpeechRecognitionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechRecognitionResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionResult.verify|verify} messages. + * @param message SpeechRecognitionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ISpeechRecognitionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeechRecognitionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeechRecognitionResult + * @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.v2.SpeechRecognitionResult; + + /** + * Decodes a SpeechRecognitionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeechRecognitionResult + * @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.v2.SpeechRecognitionResult; + + /** + * Verifies a SpeechRecognitionResult 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 SpeechRecognitionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechRecognitionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.SpeechRecognitionResult; + + /** + * Creates a plain object from a SpeechRecognitionResult message. Also converts values to other types if specified. + * @param message SpeechRecognitionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.SpeechRecognitionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechRecognitionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeechRecognitionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecognizeResponse. */ + interface IRecognizeResponse { + + /** RecognizeResponse results */ + results?: (google.cloud.speech.v2.ISpeechRecognitionResult[]|null); + + /** RecognizeResponse metadata */ + metadata?: (google.cloud.speech.v2.IRecognitionResponseMetadata|null); + } + + /** Represents a RecognizeResponse. */ + class RecognizeResponse implements IRecognizeResponse { + + /** + * Constructs a new RecognizeResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IRecognizeResponse); + + /** RecognizeResponse results. */ + public results: google.cloud.speech.v2.ISpeechRecognitionResult[]; + + /** RecognizeResponse metadata. */ + public metadata?: (google.cloud.speech.v2.IRecognitionResponseMetadata|null); + + /** + * Creates a new RecognizeResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RecognizeResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IRecognizeResponse): google.cloud.speech.v2.RecognizeResponse; + + /** + * Encodes the specified RecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.RecognizeResponse.verify|verify} messages. + * @param message RecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognizeResponse.verify|verify} messages. + * @param message RecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecognizeResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecognizeResponse + * @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.v2.RecognizeResponse; + + /** + * Decodes a RecognizeResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecognizeResponse + * @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.v2.RecognizeResponse; + + /** + * Verifies a RecognizeResponse 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 RecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecognizeResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.RecognizeResponse; + + /** + * Creates a plain object from a RecognizeResponse message. Also converts values to other types if specified. + * @param message RecognizeResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.RecognizeResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecognizeResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecognizeResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamingRecognitionFeatures. */ + interface IStreamingRecognitionFeatures { + + /** StreamingRecognitionFeatures enableVoiceActivityEvents */ + enableVoiceActivityEvents?: (boolean|null); + + /** StreamingRecognitionFeatures interimResults */ + interimResults?: (boolean|null); + + /** StreamingRecognitionFeatures voiceActivityTimeout */ + voiceActivityTimeout?: (google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout|null); + } + + /** Represents a StreamingRecognitionFeatures. */ + class StreamingRecognitionFeatures implements IStreamingRecognitionFeatures { + + /** + * Constructs a new StreamingRecognitionFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IStreamingRecognitionFeatures); + + /** StreamingRecognitionFeatures enableVoiceActivityEvents. */ + public enableVoiceActivityEvents: boolean; + + /** StreamingRecognitionFeatures interimResults. */ + public interimResults: boolean; + + /** StreamingRecognitionFeatures voiceActivityTimeout. */ + public voiceActivityTimeout?: (google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout|null); + + /** + * Creates a new StreamingRecognitionFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingRecognitionFeatures instance + */ + public static create(properties?: google.cloud.speech.v2.IStreamingRecognitionFeatures): google.cloud.speech.v2.StreamingRecognitionFeatures; + + /** + * Encodes the specified StreamingRecognitionFeatures message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.verify|verify} messages. + * @param message StreamingRecognitionFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IStreamingRecognitionFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingRecognitionFeatures message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.verify|verify} messages. + * @param message StreamingRecognitionFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IStreamingRecognitionFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingRecognitionFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingRecognitionFeatures + * @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.v2.StreamingRecognitionFeatures; + + /** + * Decodes a StreamingRecognitionFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingRecognitionFeatures + * @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.v2.StreamingRecognitionFeatures; + + /** + * Verifies a StreamingRecognitionFeatures 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 StreamingRecognitionFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingRecognitionFeatures + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognitionFeatures; + + /** + * Creates a plain object from a StreamingRecognitionFeatures message. Also converts values to other types if specified. + * @param message StreamingRecognitionFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognitionFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingRecognitionFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingRecognitionFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace StreamingRecognitionFeatures { + + /** Properties of a VoiceActivityTimeout. */ + interface IVoiceActivityTimeout { + + /** VoiceActivityTimeout speechStartTimeout */ + speechStartTimeout?: (google.protobuf.IDuration|null); + + /** VoiceActivityTimeout speechEndTimeout */ + speechEndTimeout?: (google.protobuf.IDuration|null); + } + + /** Represents a VoiceActivityTimeout. */ + class VoiceActivityTimeout implements IVoiceActivityTimeout { + + /** + * Constructs a new VoiceActivityTimeout. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout); + + /** VoiceActivityTimeout speechStartTimeout. */ + public speechStartTimeout?: (google.protobuf.IDuration|null); + + /** VoiceActivityTimeout speechEndTimeout. */ + public speechEndTimeout?: (google.protobuf.IDuration|null); + + /** + * Creates a new VoiceActivityTimeout instance using the specified properties. + * @param [properties] Properties to set + * @returns VoiceActivityTimeout instance + */ + public static create(properties?: google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout): google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout; + + /** + * Encodes the specified VoiceActivityTimeout message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.verify|verify} messages. + * @param message VoiceActivityTimeout message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VoiceActivityTimeout message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.verify|verify} messages. + * @param message VoiceActivityTimeout message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VoiceActivityTimeout message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VoiceActivityTimeout + * @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.v2.StreamingRecognitionFeatures.VoiceActivityTimeout; + + /** + * Decodes a VoiceActivityTimeout message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VoiceActivityTimeout + * @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.v2.StreamingRecognitionFeatures.VoiceActivityTimeout; + + /** + * Verifies a VoiceActivityTimeout 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 VoiceActivityTimeout message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VoiceActivityTimeout + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout; + + /** + * Creates a plain object from a VoiceActivityTimeout message. Also converts values to other types if specified. + * @param message VoiceActivityTimeout + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VoiceActivityTimeout to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VoiceActivityTimeout + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a StreamingRecognitionConfig. */ + interface IStreamingRecognitionConfig { + + /** StreamingRecognitionConfig config */ + config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** StreamingRecognitionConfig configMask */ + configMask?: (google.protobuf.IFieldMask|null); + + /** StreamingRecognitionConfig streamingFeatures */ + streamingFeatures?: (google.cloud.speech.v2.IStreamingRecognitionFeatures|null); + } + + /** Represents a StreamingRecognitionConfig. */ + class StreamingRecognitionConfig implements IStreamingRecognitionConfig { + + /** + * Constructs a new StreamingRecognitionConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IStreamingRecognitionConfig); + + /** StreamingRecognitionConfig config. */ + public config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** StreamingRecognitionConfig configMask. */ + public configMask?: (google.protobuf.IFieldMask|null); + + /** StreamingRecognitionConfig streamingFeatures. */ + public streamingFeatures?: (google.cloud.speech.v2.IStreamingRecognitionFeatures|null); + + /** + * Creates a new StreamingRecognitionConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingRecognitionConfig instance + */ + public static create(properties?: google.cloud.speech.v2.IStreamingRecognitionConfig): google.cloud.speech.v2.StreamingRecognitionConfig; + + /** + * Encodes the specified StreamingRecognitionConfig message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionConfig.verify|verify} messages. + * @param message StreamingRecognitionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IStreamingRecognitionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingRecognitionConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionConfig.verify|verify} messages. + * @param message StreamingRecognitionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IStreamingRecognitionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingRecognitionConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingRecognitionConfig + * @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.v2.StreamingRecognitionConfig; + + /** + * Decodes a StreamingRecognitionConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingRecognitionConfig + * @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.v2.StreamingRecognitionConfig; + + /** + * Verifies a StreamingRecognitionConfig 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 StreamingRecognitionConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingRecognitionConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognitionConfig; + + /** + * Creates a plain object from a StreamingRecognitionConfig message. Also converts values to other types if specified. + * @param message StreamingRecognitionConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognitionConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingRecognitionConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingRecognitionConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamingRecognizeRequest. */ + interface IStreamingRecognizeRequest { + + /** StreamingRecognizeRequest recognizer */ + recognizer?: (string|null); + + /** StreamingRecognizeRequest streamingConfig */ + streamingConfig?: (google.cloud.speech.v2.IStreamingRecognitionConfig|null); + + /** StreamingRecognizeRequest audio */ + audio?: (Uint8Array|string|null); + } + + /** Represents a StreamingRecognizeRequest. */ + class StreamingRecognizeRequest implements IStreamingRecognizeRequest { + + /** + * Constructs a new StreamingRecognizeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IStreamingRecognizeRequest); + + /** StreamingRecognizeRequest recognizer. */ + public recognizer: string; + + /** StreamingRecognizeRequest streamingConfig. */ + public streamingConfig?: (google.cloud.speech.v2.IStreamingRecognitionConfig|null); + + /** StreamingRecognizeRequest audio. */ + public audio?: (Uint8Array|string|null); + + /** StreamingRecognizeRequest streamingRequest. */ + public streamingRequest?: ("streamingConfig"|"audio"); + + /** + * Creates a new StreamingRecognizeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingRecognizeRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IStreamingRecognizeRequest): google.cloud.speech.v2.StreamingRecognizeRequest; + + /** + * Encodes the specified StreamingRecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeRequest.verify|verify} messages. + * @param message StreamingRecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IStreamingRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingRecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeRequest.verify|verify} messages. + * @param message StreamingRecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IStreamingRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingRecognizeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingRecognizeRequest + * @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.v2.StreamingRecognizeRequest; + + /** + * Decodes a StreamingRecognizeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingRecognizeRequest + * @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.v2.StreamingRecognizeRequest; + + /** + * Verifies a StreamingRecognizeRequest 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 StreamingRecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingRecognizeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognizeRequest; + + /** + * Creates a plain object from a StreamingRecognizeRequest message. Also converts values to other types if specified. + * @param message StreamingRecognizeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognizeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingRecognizeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingRecognizeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeRequest. */ + interface IBatchRecognizeRequest { + + /** BatchRecognizeRequest recognizer */ + recognizer?: (string|null); + + /** BatchRecognizeRequest config */ + config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** BatchRecognizeRequest configMask */ + configMask?: (google.protobuf.IFieldMask|null); + + /** BatchRecognizeRequest files */ + files?: (google.cloud.speech.v2.IBatchRecognizeFileMetadata[]|null); + } + + /** Represents a BatchRecognizeRequest. */ + class BatchRecognizeRequest implements IBatchRecognizeRequest { + + /** + * Constructs a new BatchRecognizeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeRequest); + + /** BatchRecognizeRequest recognizer. */ + public recognizer: string; + + /** BatchRecognizeRequest config. */ + public config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** BatchRecognizeRequest configMask. */ + public configMask?: (google.protobuf.IFieldMask|null); + + /** BatchRecognizeRequest files. */ + public files: google.cloud.speech.v2.IBatchRecognizeFileMetadata[]; + + /** + * Creates a new BatchRecognizeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeRequest): google.cloud.speech.v2.BatchRecognizeRequest; + + /** + * Encodes the specified BatchRecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeRequest.verify|verify} messages. + * @param message BatchRecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeRequest.verify|verify} messages. + * @param message BatchRecognizeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeRequest + * @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.v2.BatchRecognizeRequest; + + /** + * Decodes a BatchRecognizeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeRequest + * @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.v2.BatchRecognizeRequest; + + /** + * Verifies a BatchRecognizeRequest 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 BatchRecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeRequest; + + /** + * Creates a plain object from a BatchRecognizeRequest message. Also converts values to other types if specified. + * @param message BatchRecognizeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeResponse. */ + interface IBatchRecognizeResponse { + + /** BatchRecognizeResponse results */ + results?: ({ [k: string]: google.cloud.speech.v2.IBatchRecognizeFileResult }|null); + } + + /** Represents a BatchRecognizeResponse. */ + class BatchRecognizeResponse implements IBatchRecognizeResponse { + + /** + * Constructs a new BatchRecognizeResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeResponse); + + /** BatchRecognizeResponse results. */ + public results: { [k: string]: google.cloud.speech.v2.IBatchRecognizeFileResult }; + + /** + * Creates a new BatchRecognizeResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeResponse): google.cloud.speech.v2.BatchRecognizeResponse; + + /** + * Encodes the specified BatchRecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeResponse.verify|verify} messages. + * @param message BatchRecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeResponse.verify|verify} messages. + * @param message BatchRecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeResponse + * @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.v2.BatchRecognizeResponse; + + /** + * Decodes a BatchRecognizeResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeResponse + * @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.v2.BatchRecognizeResponse; + + /** + * Verifies a BatchRecognizeResponse 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 BatchRecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeResponse; + + /** + * Creates a plain object from a BatchRecognizeResponse message. Also converts values to other types if specified. + * @param message BatchRecognizeResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeFileResult. */ + interface IBatchRecognizeFileResult { + + /** BatchRecognizeFileResult uri */ + uri?: (string|null); + + /** BatchRecognizeFileResult error */ + error?: (google.rpc.IStatus|null); + } + + /** Represents a BatchRecognizeFileResult. */ + class BatchRecognizeFileResult implements IBatchRecognizeFileResult { + + /** + * Constructs a new BatchRecognizeFileResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeFileResult); + + /** BatchRecognizeFileResult uri. */ + public uri: string; + + /** BatchRecognizeFileResult error. */ + public error?: (google.rpc.IStatus|null); + + /** + * Creates a new BatchRecognizeFileResult instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeFileResult instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeFileResult): google.cloud.speech.v2.BatchRecognizeFileResult; + + /** + * Encodes the specified BatchRecognizeFileResult message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileResult.verify|verify} messages. + * @param message BatchRecognizeFileResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeFileResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeFileResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileResult.verify|verify} messages. + * @param message BatchRecognizeFileResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeFileResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeFileResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeFileResult + * @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.v2.BatchRecognizeFileResult; + + /** + * Decodes a BatchRecognizeFileResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeFileResult + * @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.v2.BatchRecognizeFileResult; + + /** + * Verifies a BatchRecognizeFileResult 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 BatchRecognizeFileResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeFileResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeFileResult; + + /** + * Creates a plain object from a BatchRecognizeFileResult message. Also converts values to other types if specified. + * @param message BatchRecognizeFileResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeFileResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeFileResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeFileResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeTranscriptionMetadata. */ + interface IBatchRecognizeTranscriptionMetadata { + + /** BatchRecognizeTranscriptionMetadata progressPercent */ + progressPercent?: (number|null); + + /** BatchRecognizeTranscriptionMetadata error */ + error?: (google.rpc.IStatus|null); + + /** BatchRecognizeTranscriptionMetadata uri */ + uri?: (string|null); + } + + /** Represents a BatchRecognizeTranscriptionMetadata. */ + class BatchRecognizeTranscriptionMetadata implements IBatchRecognizeTranscriptionMetadata { + + /** + * Constructs a new BatchRecognizeTranscriptionMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata); + + /** BatchRecognizeTranscriptionMetadata progressPercent. */ + public progressPercent: number; + + /** BatchRecognizeTranscriptionMetadata error. */ + public error?: (google.rpc.IStatus|null); + + /** BatchRecognizeTranscriptionMetadata uri. */ + public uri: string; + + /** + * Creates a new BatchRecognizeTranscriptionMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeTranscriptionMetadata instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata): google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata; + + /** + * Encodes the specified BatchRecognizeTranscriptionMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.verify|verify} messages. + * @param message BatchRecognizeTranscriptionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeTranscriptionMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.verify|verify} messages. + * @param message BatchRecognizeTranscriptionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeTranscriptionMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeTranscriptionMetadata + * @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.v2.BatchRecognizeTranscriptionMetadata; + + /** + * Decodes a BatchRecognizeTranscriptionMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeTranscriptionMetadata + * @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.v2.BatchRecognizeTranscriptionMetadata; + + /** + * Verifies a BatchRecognizeTranscriptionMetadata 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 BatchRecognizeTranscriptionMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeTranscriptionMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata; + + /** + * Creates a plain object from a BatchRecognizeTranscriptionMetadata message. Also converts values to other types if specified. + * @param message BatchRecognizeTranscriptionMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeTranscriptionMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeTranscriptionMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeMetadata. */ + interface IBatchRecognizeMetadata { + + /** BatchRecognizeMetadata transcriptionMetadata */ + transcriptionMetadata?: ({ [k: string]: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata }|null); + } + + /** Represents a BatchRecognizeMetadata. */ + class BatchRecognizeMetadata implements IBatchRecognizeMetadata { + + /** + * Constructs a new BatchRecognizeMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeMetadata); + + /** BatchRecognizeMetadata transcriptionMetadata. */ + public transcriptionMetadata: { [k: string]: google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata }; + + /** + * Creates a new BatchRecognizeMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeMetadata instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeMetadata): google.cloud.speech.v2.BatchRecognizeMetadata; + + /** + * Encodes the specified BatchRecognizeMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeMetadata.verify|verify} messages. + * @param message BatchRecognizeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeMetadata.verify|verify} messages. + * @param message BatchRecognizeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeMetadata + * @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.v2.BatchRecognizeMetadata; + + /** + * Decodes a BatchRecognizeMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeMetadata + * @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.v2.BatchRecognizeMetadata; + + /** + * Verifies a BatchRecognizeMetadata 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 BatchRecognizeMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeMetadata; + + /** + * Creates a plain object from a BatchRecognizeMetadata message. Also converts values to other types if specified. + * @param message BatchRecognizeMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRecognizeFileMetadata. */ + interface IBatchRecognizeFileMetadata { + + /** BatchRecognizeFileMetadata uri */ + uri?: (string|null); + + /** BatchRecognizeFileMetadata config */ + config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** BatchRecognizeFileMetadata configMask */ + configMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a BatchRecognizeFileMetadata. */ + class BatchRecognizeFileMetadata implements IBatchRecognizeFileMetadata { + + /** + * Constructs a new BatchRecognizeFileMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IBatchRecognizeFileMetadata); + + /** BatchRecognizeFileMetadata uri. */ + public uri?: (string|null); + + /** BatchRecognizeFileMetadata config. */ + public config?: (google.cloud.speech.v2.IRecognitionConfig|null); + + /** BatchRecognizeFileMetadata configMask. */ + public configMask?: (google.protobuf.IFieldMask|null); + + /** BatchRecognizeFileMetadata audioSource. */ + public audioSource?: "uri"; + + /** + * Creates a new BatchRecognizeFileMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRecognizeFileMetadata instance + */ + public static create(properties?: google.cloud.speech.v2.IBatchRecognizeFileMetadata): google.cloud.speech.v2.BatchRecognizeFileMetadata; + + /** + * Encodes the specified BatchRecognizeFileMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileMetadata.verify|verify} messages. + * @param message BatchRecognizeFileMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IBatchRecognizeFileMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRecognizeFileMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileMetadata.verify|verify} messages. + * @param message BatchRecognizeFileMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IBatchRecognizeFileMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRecognizeFileMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRecognizeFileMetadata + * @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.v2.BatchRecognizeFileMetadata; + + /** + * Decodes a BatchRecognizeFileMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRecognizeFileMetadata + * @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.v2.BatchRecognizeFileMetadata; + + /** + * Verifies a BatchRecognizeFileMetadata 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 BatchRecognizeFileMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRecognizeFileMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.BatchRecognizeFileMetadata; + + /** + * Creates a plain object from a BatchRecognizeFileMetadata message. Also converts values to other types if specified. + * @param message BatchRecognizeFileMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.BatchRecognizeFileMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRecognizeFileMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRecognizeFileMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamingRecognitionResult. */ + interface IStreamingRecognitionResult { + + /** StreamingRecognitionResult alternatives */ + alternatives?: (google.cloud.speech.v2.ISpeechRecognitionAlternative[]|null); + + /** StreamingRecognitionResult isFinal */ + isFinal?: (boolean|null); + + /** StreamingRecognitionResult stability */ + stability?: (number|null); + + /** StreamingRecognitionResult resultEndOffset */ + resultEndOffset?: (google.protobuf.IDuration|null); + + /** StreamingRecognitionResult channelTag */ + channelTag?: (number|null); + + /** StreamingRecognitionResult languageCode */ + languageCode?: (string|null); + } + + /** Represents a StreamingRecognitionResult. */ + class StreamingRecognitionResult implements IStreamingRecognitionResult { + + /** + * Constructs a new StreamingRecognitionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IStreamingRecognitionResult); + + /** StreamingRecognitionResult alternatives. */ + public alternatives: google.cloud.speech.v2.ISpeechRecognitionAlternative[]; + + /** StreamingRecognitionResult isFinal. */ + public isFinal: boolean; + + /** StreamingRecognitionResult stability. */ + public stability: number; + + /** StreamingRecognitionResult resultEndOffset. */ + public resultEndOffset?: (google.protobuf.IDuration|null); + + /** StreamingRecognitionResult channelTag. */ + public channelTag: number; + + /** StreamingRecognitionResult languageCode. */ + public languageCode: string; + + /** + * Creates a new StreamingRecognitionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingRecognitionResult instance + */ + public static create(properties?: google.cloud.speech.v2.IStreamingRecognitionResult): google.cloud.speech.v2.StreamingRecognitionResult; + + /** + * Encodes the specified StreamingRecognitionResult message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionResult.verify|verify} messages. + * @param message StreamingRecognitionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IStreamingRecognitionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingRecognitionResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionResult.verify|verify} messages. + * @param message StreamingRecognitionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IStreamingRecognitionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingRecognitionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingRecognitionResult + * @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.v2.StreamingRecognitionResult; + + /** + * Decodes a StreamingRecognitionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingRecognitionResult + * @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.v2.StreamingRecognitionResult; + + /** + * Verifies a StreamingRecognitionResult 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 StreamingRecognitionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingRecognitionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognitionResult; + + /** + * Creates a plain object from a StreamingRecognitionResult message. Also converts values to other types if specified. + * @param message StreamingRecognitionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognitionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingRecognitionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingRecognitionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamingRecognizeResponse. */ + interface IStreamingRecognizeResponse { + + /** StreamingRecognizeResponse results */ + results?: (google.cloud.speech.v2.IStreamingRecognitionResult[]|null); + + /** StreamingRecognizeResponse speechEventType */ + speechEventType?: (google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType|keyof typeof google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType|null); + + /** StreamingRecognizeResponse speechEventOffset */ + speechEventOffset?: (google.protobuf.IDuration|null); + + /** StreamingRecognizeResponse metadata */ + metadata?: (google.cloud.speech.v2.IRecognitionResponseMetadata|null); + } + + /** Represents a StreamingRecognizeResponse. */ + class StreamingRecognizeResponse implements IStreamingRecognizeResponse { + + /** + * Constructs a new StreamingRecognizeResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IStreamingRecognizeResponse); + + /** StreamingRecognizeResponse results. */ + public results: google.cloud.speech.v2.IStreamingRecognitionResult[]; + + /** StreamingRecognizeResponse speechEventType. */ + public speechEventType: (google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType|keyof typeof google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType); + + /** StreamingRecognizeResponse speechEventOffset. */ + public speechEventOffset?: (google.protobuf.IDuration|null); + + /** StreamingRecognizeResponse metadata. */ + public metadata?: (google.cloud.speech.v2.IRecognitionResponseMetadata|null); + + /** + * Creates a new StreamingRecognizeResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingRecognizeResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IStreamingRecognizeResponse): google.cloud.speech.v2.StreamingRecognizeResponse; + + /** + * Encodes the specified StreamingRecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeResponse.verify|verify} messages. + * @param message StreamingRecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IStreamingRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingRecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeResponse.verify|verify} messages. + * @param message StreamingRecognizeResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IStreamingRecognizeResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingRecognizeResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingRecognizeResponse + * @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.v2.StreamingRecognizeResponse; + + /** + * Decodes a StreamingRecognizeResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingRecognizeResponse + * @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.v2.StreamingRecognizeResponse; + + /** + * Verifies a StreamingRecognizeResponse 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 StreamingRecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingRecognizeResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.StreamingRecognizeResponse; + + /** + * Creates a plain object from a StreamingRecognizeResponse message. Also converts values to other types if specified. + * @param message StreamingRecognizeResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.StreamingRecognizeResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingRecognizeResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingRecognizeResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace StreamingRecognizeResponse { + + /** SpeechEventType enum. */ + enum SpeechEventType { + SPEECH_EVENT_TYPE_UNSPECIFIED = 0, + END_OF_SINGLE_UTTERANCE = 1, + SPEECH_ACTIVITY_BEGIN = 2, + SPEECH_ACTIVITY_END = 3 + } + } + + /** Properties of a Config. */ + interface IConfig { + + /** Config name */ + name?: (string|null); + + /** Config kmsKeyName */ + kmsKeyName?: (string|null); + + /** Config updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Config. */ + class Config implements IConfig { + + /** + * Constructs a new Config. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IConfig); + + /** Config name. */ + public name: string; + + /** Config kmsKeyName. */ + public kmsKeyName: string; + + /** Config updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new Config instance using the specified properties. + * @param [properties] Properties to set + * @returns Config instance + */ + public static create(properties?: google.cloud.speech.v2.IConfig): google.cloud.speech.v2.Config; + + /** + * Encodes the specified Config message. Does not implicitly {@link google.cloud.speech.v2.Config.verify|verify} messages. + * @param message Config message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Config message, length delimited. Does not implicitly {@link google.cloud.speech.v2.Config.verify|verify} messages. + * @param message Config message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Config message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Config + * @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.v2.Config; + + /** + * Decodes a Config message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Config + * @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.v2.Config; + + /** + * Verifies a Config 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 Config message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Config + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.Config; + + /** + * Creates a plain object from a Config message. Also converts values to other types if specified. + * @param message Config + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.Config, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Config to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Config + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetConfigRequest. */ + interface IGetConfigRequest { + + /** GetConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetConfigRequest. */ + class GetConfigRequest implements IGetConfigRequest { + + /** + * Constructs a new GetConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IGetConfigRequest); + + /** GetConfigRequest name. */ + public name: string; + + /** + * Creates a new GetConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetConfigRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IGetConfigRequest): google.cloud.speech.v2.GetConfigRequest; + + /** + * Encodes the specified GetConfigRequest message. Does not implicitly {@link google.cloud.speech.v2.GetConfigRequest.verify|verify} messages. + * @param message GetConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IGetConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetConfigRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetConfigRequest.verify|verify} messages. + * @param message GetConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IGetConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetConfigRequest + * @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.v2.GetConfigRequest; + + /** + * Decodes a GetConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetConfigRequest + * @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.v2.GetConfigRequest; + + /** + * Verifies a GetConfigRequest 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 GetConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.GetConfigRequest; + + /** + * Creates a plain object from a GetConfigRequest message. Also converts values to other types if specified. + * @param message GetConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.GetConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateConfigRequest. */ + interface IUpdateConfigRequest { + + /** UpdateConfigRequest config */ + config?: (google.cloud.speech.v2.IConfig|null); + + /** UpdateConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateConfigRequest. */ + class UpdateConfigRequest implements IUpdateConfigRequest { + + /** + * Constructs a new UpdateConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUpdateConfigRequest); + + /** UpdateConfigRequest config. */ + public config?: (google.cloud.speech.v2.IConfig|null); + + /** UpdateConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateConfigRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUpdateConfigRequest): google.cloud.speech.v2.UpdateConfigRequest; + + /** + * Encodes the specified UpdateConfigRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateConfigRequest.verify|verify} messages. + * @param message UpdateConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUpdateConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateConfigRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateConfigRequest.verify|verify} messages. + * @param message UpdateConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUpdateConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateConfigRequest + * @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.v2.UpdateConfigRequest; + + /** + * Decodes an UpdateConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateConfigRequest + * @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.v2.UpdateConfigRequest; + + /** + * Verifies an UpdateConfigRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UpdateConfigRequest; + + /** + * Creates a plain object from an UpdateConfigRequest message. Also converts values to other types if specified. + * @param message UpdateConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UpdateConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CustomClass. */ + interface ICustomClass { + + /** CustomClass name */ + name?: (string|null); + + /** CustomClass uid */ + uid?: (string|null); + + /** CustomClass displayName */ + displayName?: (string|null); + + /** CustomClass items */ + items?: (google.cloud.speech.v2.CustomClass.IClassItem[]|null); + + /** CustomClass state */ + state?: (google.cloud.speech.v2.CustomClass.State|keyof typeof google.cloud.speech.v2.CustomClass.State|null); + + /** CustomClass createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass deleteTime */ + deleteTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass annotations */ + annotations?: ({ [k: string]: string }|null); + + /** CustomClass etag */ + etag?: (string|null); + + /** CustomClass reconciling */ + reconciling?: (boolean|null); + + /** CustomClass kmsKeyName */ + kmsKeyName?: (string|null); + + /** CustomClass kmsKeyVersionName */ + kmsKeyVersionName?: (string|null); + } + + /** Represents a CustomClass. */ + class CustomClass implements ICustomClass { + + /** + * Constructs a new CustomClass. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ICustomClass); + + /** CustomClass name. */ + public name: string; + + /** CustomClass uid. */ + public uid: string; + + /** CustomClass displayName. */ + public displayName: string; + + /** CustomClass items. */ + public items: google.cloud.speech.v2.CustomClass.IClassItem[]; + + /** CustomClass state. */ + public state: (google.cloud.speech.v2.CustomClass.State|keyof typeof google.cloud.speech.v2.CustomClass.State); + + /** CustomClass createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass deleteTime. */ + public deleteTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** CustomClass annotations. */ + public annotations: { [k: string]: string }; + + /** CustomClass etag. */ + public etag: string; + + /** CustomClass reconciling. */ + public reconciling: boolean; + + /** CustomClass kmsKeyName. */ + public kmsKeyName: string; + + /** CustomClass kmsKeyVersionName. */ + public kmsKeyVersionName: string; + + /** + * Creates a new CustomClass instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomClass instance + */ + public static create(properties?: google.cloud.speech.v2.ICustomClass): google.cloud.speech.v2.CustomClass; + + /** + * Encodes the specified CustomClass message. Does not implicitly {@link google.cloud.speech.v2.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.v2.ICustomClass, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomClass message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.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.v2.CustomClass, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomClass to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomClass + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + 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.v2.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.v2.CustomClass.IClassItem): google.cloud.speech.v2.CustomClass.ClassItem; + + /** + * Encodes the specified ClassItem message. Does not implicitly {@link google.cloud.speech.v2.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.v2.CustomClass.IClassItem, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClassItem message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.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.v2.CustomClass.ClassItem, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClassItem to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ClassItem + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 2, + DELETED = 4 + } + } + + /** Properties of a PhraseSet. */ + interface IPhraseSet { + + /** PhraseSet name */ + name?: (string|null); + + /** PhraseSet uid */ + uid?: (string|null); + + /** PhraseSet phrases */ + phrases?: (google.cloud.speech.v2.PhraseSet.IPhrase[]|null); + + /** PhraseSet boost */ + boost?: (number|null); + + /** PhraseSet displayName */ + displayName?: (string|null); + + /** PhraseSet state */ + state?: (google.cloud.speech.v2.PhraseSet.State|keyof typeof google.cloud.speech.v2.PhraseSet.State|null); + + /** PhraseSet createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet deleteTime */ + deleteTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet annotations */ + annotations?: ({ [k: string]: string }|null); + + /** PhraseSet etag */ + etag?: (string|null); + + /** PhraseSet reconciling */ + reconciling?: (boolean|null); + + /** PhraseSet kmsKeyName */ + kmsKeyName?: (string|null); + + /** PhraseSet kmsKeyVersionName */ + kmsKeyVersionName?: (string|null); + } + + /** Represents a PhraseSet. */ + class PhraseSet implements IPhraseSet { + + /** + * Constructs a new PhraseSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IPhraseSet); + + /** PhraseSet name. */ + public name: string; + + /** PhraseSet uid. */ + public uid: string; + + /** PhraseSet phrases. */ + public phrases: google.cloud.speech.v2.PhraseSet.IPhrase[]; + + /** PhraseSet boost. */ + public boost: number; + + /** PhraseSet displayName. */ + public displayName: string; + + /** PhraseSet state. */ + public state: (google.cloud.speech.v2.PhraseSet.State|keyof typeof google.cloud.speech.v2.PhraseSet.State); + + /** PhraseSet createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet deleteTime. */ + public deleteTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** PhraseSet annotations. */ + public annotations: { [k: string]: string }; + + /** PhraseSet etag. */ + public etag: string; + + /** PhraseSet reconciling. */ + public reconciling: boolean; + + /** PhraseSet kmsKeyName. */ + public kmsKeyName: string; + + /** PhraseSet kmsKeyVersionName. */ + public kmsKeyVersionName: string; + + /** + * Creates a new PhraseSet instance using the specified properties. + * @param [properties] Properties to set + * @returns PhraseSet instance + */ + public static create(properties?: google.cloud.speech.v2.IPhraseSet): google.cloud.speech.v2.PhraseSet; + + /** + * Encodes the specified PhraseSet message. Does not implicitly {@link google.cloud.speech.v2.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.v2.IPhraseSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.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.v2.PhraseSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PhraseSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PhraseSet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + 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.v2.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.v2.PhraseSet.IPhrase): google.cloud.speech.v2.PhraseSet.Phrase; + + /** + * Encodes the specified Phrase message. Does not implicitly {@link google.cloud.speech.v2.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.v2.PhraseSet.IPhrase, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Phrase message, length delimited. Does not implicitly {@link google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.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.v2.PhraseSet.Phrase, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Phrase to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Phrase + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 2, + DELETED = 4 + } + } + + /** Properties of a CreateCustomClassRequest. */ + interface ICreateCustomClassRequest { + + /** CreateCustomClassRequest customClass */ + customClass?: (google.cloud.speech.v2.ICustomClass|null); + + /** CreateCustomClassRequest validateOnly */ + validateOnly?: (boolean|null); + + /** CreateCustomClassRequest customClassId */ + customClassId?: (string|null); + + /** CreateCustomClassRequest parent */ + parent?: (string|null); + } + + /** Represents a CreateCustomClassRequest. */ + class CreateCustomClassRequest implements ICreateCustomClassRequest { + + /** + * Constructs a new CreateCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ICreateCustomClassRequest); + + /** CreateCustomClassRequest customClass. */ + public customClass?: (google.cloud.speech.v2.ICustomClass|null); + + /** CreateCustomClassRequest validateOnly. */ + public validateOnly: boolean; + + /** CreateCustomClassRequest customClassId. */ + public customClassId: string; + + /** CreateCustomClassRequest parent. */ + public parent: string; + + /** + * Creates a new CreateCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v2.ICreateCustomClassRequest): google.cloud.speech.v2.CreateCustomClassRequest; + + /** + * Encodes the specified CreateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.CreateCustomClassRequest.verify|verify} messages. + * @param message CreateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ICreateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreateCustomClassRequest.verify|verify} messages. + * @param message CreateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ICreateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateCustomClassRequest + * @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.v2.CreateCustomClassRequest; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateCustomClassRequest + * @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.v2.CreateCustomClassRequest; + + /** + * Verifies a CreateCustomClassRequest 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 CreateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.CreateCustomClassRequest; + + /** + * Creates a plain object from a CreateCustomClassRequest message. Also converts values to other types if specified. + * @param message CreateCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.CreateCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateCustomClassRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCustomClassesRequest. */ + interface IListCustomClassesRequest { + + /** ListCustomClassesRequest parent */ + parent?: (string|null); + + /** ListCustomClassesRequest pageSize */ + pageSize?: (number|null); + + /** ListCustomClassesRequest pageToken */ + pageToken?: (string|null); + + /** ListCustomClassesRequest showDeleted */ + showDeleted?: (boolean|null); + } + + /** Represents a ListCustomClassesRequest. */ + class ListCustomClassesRequest implements IListCustomClassesRequest { + + /** + * Constructs a new ListCustomClassesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListCustomClassesRequest); + + /** ListCustomClassesRequest parent. */ + public parent: string; + + /** ListCustomClassesRequest pageSize. */ + public pageSize: number; + + /** ListCustomClassesRequest pageToken. */ + public pageToken: string; + + /** ListCustomClassesRequest showDeleted. */ + public showDeleted: boolean; + + /** + * Creates a new ListCustomClassesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCustomClassesRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IListCustomClassesRequest): google.cloud.speech.v2.ListCustomClassesRequest; + + /** + * Encodes the specified ListCustomClassesRequest message. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesRequest.verify|verify} messages. + * @param message ListCustomClassesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListCustomClassesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCustomClassesRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesRequest.verify|verify} messages. + * @param message ListCustomClassesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListCustomClassesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCustomClassesRequest + * @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.v2.ListCustomClassesRequest; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCustomClassesRequest + * @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.v2.ListCustomClassesRequest; + + /** + * Verifies a ListCustomClassesRequest 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 ListCustomClassesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCustomClassesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListCustomClassesRequest; + + /** + * Creates a plain object from a ListCustomClassesRequest message. Also converts values to other types if specified. + * @param message ListCustomClassesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListCustomClassesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCustomClassesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCustomClassesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCustomClassesResponse. */ + interface IListCustomClassesResponse { + + /** ListCustomClassesResponse customClasses */ + customClasses?: (google.cloud.speech.v2.ICustomClass[]|null); + + /** ListCustomClassesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCustomClassesResponse. */ + class ListCustomClassesResponse implements IListCustomClassesResponse { + + /** + * Constructs a new ListCustomClassesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListCustomClassesResponse); + + /** ListCustomClassesResponse customClasses. */ + public customClasses: google.cloud.speech.v2.ICustomClass[]; + + /** ListCustomClassesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListCustomClassesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCustomClassesResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IListCustomClassesResponse): google.cloud.speech.v2.ListCustomClassesResponse; + + /** + * Encodes the specified ListCustomClassesResponse message. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesResponse.verify|verify} messages. + * @param message ListCustomClassesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListCustomClassesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCustomClassesResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesResponse.verify|verify} messages. + * @param message ListCustomClassesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListCustomClassesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCustomClassesResponse + * @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.v2.ListCustomClassesResponse; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCustomClassesResponse + * @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.v2.ListCustomClassesResponse; + + /** + * Verifies a ListCustomClassesResponse 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 ListCustomClassesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCustomClassesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListCustomClassesResponse; + + /** + * Creates a plain object from a ListCustomClassesResponse message. Also converts values to other types if specified. + * @param message ListCustomClassesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListCustomClassesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCustomClassesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCustomClassesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetCustomClassRequest. */ + interface IGetCustomClassRequest { + + /** GetCustomClassRequest name */ + name?: (string|null); + } + + /** Represents a GetCustomClassRequest. */ + class GetCustomClassRequest implements IGetCustomClassRequest { + + /** + * Constructs a new GetCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IGetCustomClassRequest); + + /** GetCustomClassRequest name. */ + public name: string; + + /** + * Creates a new GetCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IGetCustomClassRequest): google.cloud.speech.v2.GetCustomClassRequest; + + /** + * Encodes the specified GetCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.GetCustomClassRequest.verify|verify} messages. + * @param message GetCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IGetCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetCustomClassRequest.verify|verify} messages. + * @param message GetCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IGetCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCustomClassRequest + * @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.v2.GetCustomClassRequest; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCustomClassRequest + * @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.v2.GetCustomClassRequest; + + /** + * Verifies a GetCustomClassRequest 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 GetCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.GetCustomClassRequest; + + /** + * Creates a plain object from a GetCustomClassRequest message. Also converts values to other types if specified. + * @param message GetCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.GetCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCustomClassRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCustomClassRequest. */ + interface IUpdateCustomClassRequest { + + /** UpdateCustomClassRequest customClass */ + customClass?: (google.cloud.speech.v2.ICustomClass|null); + + /** UpdateCustomClassRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateCustomClassRequest validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents an UpdateCustomClassRequest. */ + class UpdateCustomClassRequest implements IUpdateCustomClassRequest { + + /** + * Constructs a new UpdateCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUpdateCustomClassRequest); + + /** UpdateCustomClassRequest customClass. */ + public customClass?: (google.cloud.speech.v2.ICustomClass|null); + + /** UpdateCustomClassRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateCustomClassRequest validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new UpdateCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUpdateCustomClassRequest): google.cloud.speech.v2.UpdateCustomClassRequest; + + /** + * Encodes the specified UpdateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateCustomClassRequest.verify|verify} messages. + * @param message UpdateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUpdateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateCustomClassRequest.verify|verify} messages. + * @param message UpdateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUpdateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCustomClassRequest + * @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.v2.UpdateCustomClassRequest; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCustomClassRequest + * @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.v2.UpdateCustomClassRequest; + + /** + * Verifies an UpdateCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UpdateCustomClassRequest; + + /** + * Creates a plain object from an UpdateCustomClassRequest message. Also converts values to other types if specified. + * @param message UpdateCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UpdateCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCustomClassRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteCustomClassRequest. */ + interface IDeleteCustomClassRequest { + + /** DeleteCustomClassRequest name */ + name?: (string|null); + + /** DeleteCustomClassRequest validateOnly */ + validateOnly?: (boolean|null); + + /** DeleteCustomClassRequest allowMissing */ + allowMissing?: (boolean|null); + + /** DeleteCustomClassRequest etag */ + etag?: (string|null); + } + + /** Represents a DeleteCustomClassRequest. */ + class DeleteCustomClassRequest implements IDeleteCustomClassRequest { + + /** + * Constructs a new DeleteCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IDeleteCustomClassRequest); + + /** DeleteCustomClassRequest name. */ + public name: string; + + /** DeleteCustomClassRequest validateOnly. */ + public validateOnly: boolean; + + /** DeleteCustomClassRequest allowMissing. */ + public allowMissing: boolean; + + /** DeleteCustomClassRequest etag. */ + public etag: string; + + /** + * Creates a new DeleteCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IDeleteCustomClassRequest): google.cloud.speech.v2.DeleteCustomClassRequest; + + /** + * Encodes the specified DeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.DeleteCustomClassRequest.verify|verify} messages. + * @param message DeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IDeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeleteCustomClassRequest.verify|verify} messages. + * @param message DeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IDeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteCustomClassRequest + * @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.v2.DeleteCustomClassRequest; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteCustomClassRequest + * @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.v2.DeleteCustomClassRequest; + + /** + * Verifies a DeleteCustomClassRequest 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 DeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.DeleteCustomClassRequest; + + /** + * Creates a plain object from a DeleteCustomClassRequest message. Also converts values to other types if specified. + * @param message DeleteCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.DeleteCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteCustomClassRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UndeleteCustomClassRequest. */ + interface IUndeleteCustomClassRequest { + + /** UndeleteCustomClassRequest name */ + name?: (string|null); + + /** UndeleteCustomClassRequest validateOnly */ + validateOnly?: (boolean|null); + + /** UndeleteCustomClassRequest etag */ + etag?: (string|null); + } + + /** Represents an UndeleteCustomClassRequest. */ + class UndeleteCustomClassRequest implements IUndeleteCustomClassRequest { + + /** + * Constructs a new UndeleteCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUndeleteCustomClassRequest); + + /** UndeleteCustomClassRequest name. */ + public name: string; + + /** UndeleteCustomClassRequest validateOnly. */ + public validateOnly: boolean; + + /** UndeleteCustomClassRequest etag. */ + public etag: string; + + /** + * Creates a new UndeleteCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UndeleteCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUndeleteCustomClassRequest): google.cloud.speech.v2.UndeleteCustomClassRequest; + + /** + * Encodes the specified UndeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeleteCustomClassRequest.verify|verify} messages. + * @param message UndeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUndeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UndeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeleteCustomClassRequest.verify|verify} messages. + * @param message UndeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUndeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UndeleteCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UndeleteCustomClassRequest + * @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.v2.UndeleteCustomClassRequest; + + /** + * Decodes an UndeleteCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UndeleteCustomClassRequest + * @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.v2.UndeleteCustomClassRequest; + + /** + * Verifies an UndeleteCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UndeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UndeleteCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UndeleteCustomClassRequest; + + /** + * Creates a plain object from an UndeleteCustomClassRequest message. Also converts values to other types if specified. + * @param message UndeleteCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UndeleteCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UndeleteCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UndeleteCustomClassRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreatePhraseSetRequest. */ + interface ICreatePhraseSetRequest { + + /** CreatePhraseSetRequest phraseSet */ + phraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + + /** CreatePhraseSetRequest validateOnly */ + validateOnly?: (boolean|null); + + /** CreatePhraseSetRequest phraseSetId */ + phraseSetId?: (string|null); + + /** CreatePhraseSetRequest parent */ + parent?: (string|null); + } + + /** Represents a CreatePhraseSetRequest. */ + class CreatePhraseSetRequest implements ICreatePhraseSetRequest { + + /** + * Constructs a new CreatePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.ICreatePhraseSetRequest); + + /** CreatePhraseSetRequest phraseSet. */ + public phraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + + /** CreatePhraseSetRequest validateOnly. */ + public validateOnly: boolean; + + /** CreatePhraseSetRequest phraseSetId. */ + public phraseSetId: string; + + /** CreatePhraseSetRequest parent. */ + public parent: string; + + /** + * Creates a new CreatePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreatePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v2.ICreatePhraseSetRequest): google.cloud.speech.v2.CreatePhraseSetRequest; + + /** + * Encodes the specified CreatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.CreatePhraseSetRequest.verify|verify} messages. + * @param message CreatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.ICreatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreatePhraseSetRequest.verify|verify} messages. + * @param message CreatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.ICreatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreatePhraseSetRequest + * @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.v2.CreatePhraseSetRequest; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreatePhraseSetRequest + * @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.v2.CreatePhraseSetRequest; + + /** + * Verifies a CreatePhraseSetRequest 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 CreatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreatePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.CreatePhraseSetRequest; + + /** + * Creates a plain object from a CreatePhraseSetRequest message. Also converts values to other types if specified. + * @param message CreatePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.CreatePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreatePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreatePhraseSetRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListPhraseSetsRequest. */ + interface IListPhraseSetsRequest { + + /** ListPhraseSetsRequest parent */ + parent?: (string|null); + + /** ListPhraseSetsRequest pageSize */ + pageSize?: (number|null); + + /** ListPhraseSetsRequest pageToken */ + pageToken?: (string|null); + + /** ListPhraseSetsRequest showDeleted */ + showDeleted?: (boolean|null); + } + + /** Represents a ListPhraseSetsRequest. */ + class ListPhraseSetsRequest implements IListPhraseSetsRequest { + + /** + * Constructs a new ListPhraseSetsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListPhraseSetsRequest); + + /** ListPhraseSetsRequest parent. */ + public parent: string; + + /** ListPhraseSetsRequest pageSize. */ + public pageSize: number; + + /** ListPhraseSetsRequest pageToken. */ + public pageToken: string; + + /** ListPhraseSetsRequest showDeleted. */ + public showDeleted: boolean; + + /** + * Creates a new ListPhraseSetsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListPhraseSetsRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IListPhraseSetsRequest): google.cloud.speech.v2.ListPhraseSetsRequest; + + /** + * Encodes the specified ListPhraseSetsRequest message. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsRequest.verify|verify} messages. + * @param message ListPhraseSetsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListPhraseSetsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListPhraseSetsRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsRequest.verify|verify} messages. + * @param message ListPhraseSetsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListPhraseSetsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListPhraseSetsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListPhraseSetsRequest + * @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.v2.ListPhraseSetsRequest; + + /** + * Decodes a ListPhraseSetsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListPhraseSetsRequest + * @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.v2.ListPhraseSetsRequest; + + /** + * Verifies a ListPhraseSetsRequest 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 ListPhraseSetsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListPhraseSetsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListPhraseSetsRequest; + + /** + * Creates a plain object from a ListPhraseSetsRequest message. Also converts values to other types if specified. + * @param message ListPhraseSetsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListPhraseSetsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListPhraseSetsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListPhraseSetsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListPhraseSetsResponse. */ + interface IListPhraseSetsResponse { + + /** ListPhraseSetsResponse phraseSets */ + phraseSets?: (google.cloud.speech.v2.IPhraseSet[]|null); + + /** ListPhraseSetsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListPhraseSetsResponse. */ + class ListPhraseSetsResponse implements IListPhraseSetsResponse { + + /** + * Constructs a new ListPhraseSetsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IListPhraseSetsResponse); + + /** ListPhraseSetsResponse phraseSets. */ + public phraseSets: google.cloud.speech.v2.IPhraseSet[]; + + /** ListPhraseSetsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListPhraseSetsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListPhraseSetsResponse instance + */ + public static create(properties?: google.cloud.speech.v2.IListPhraseSetsResponse): google.cloud.speech.v2.ListPhraseSetsResponse; + + /** + * Encodes the specified ListPhraseSetsResponse message. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsResponse.verify|verify} messages. + * @param message ListPhraseSetsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IListPhraseSetsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListPhraseSetsResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsResponse.verify|verify} messages. + * @param message ListPhraseSetsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IListPhraseSetsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListPhraseSetsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListPhraseSetsResponse + * @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.v2.ListPhraseSetsResponse; + + /** + * Decodes a ListPhraseSetsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListPhraseSetsResponse + * @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.v2.ListPhraseSetsResponse; + + /** + * Verifies a ListPhraseSetsResponse 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 ListPhraseSetsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListPhraseSetsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.ListPhraseSetsResponse; + + /** + * Creates a plain object from a ListPhraseSetsResponse message. Also converts values to other types if specified. + * @param message ListPhraseSetsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.ListPhraseSetsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListPhraseSetsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListPhraseSetsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetPhraseSetRequest. */ + interface IGetPhraseSetRequest { + + /** GetPhraseSetRequest name */ + name?: (string|null); + } + + /** Represents a GetPhraseSetRequest. */ + class GetPhraseSetRequest implements IGetPhraseSetRequest { + + /** + * Constructs a new GetPhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IGetPhraseSetRequest); + + /** GetPhraseSetRequest name. */ + public name: string; + + /** + * Creates a new GetPhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetPhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IGetPhraseSetRequest): google.cloud.speech.v2.GetPhraseSetRequest; + + /** + * Encodes the specified GetPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.GetPhraseSetRequest.verify|verify} messages. + * @param message GetPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IGetPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetPhraseSetRequest.verify|verify} messages. + * @param message GetPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IGetPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetPhraseSetRequest + * @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.v2.GetPhraseSetRequest; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetPhraseSetRequest + * @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.v2.GetPhraseSetRequest; + + /** + * Verifies a GetPhraseSetRequest 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 GetPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetPhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.GetPhraseSetRequest; + + /** + * Creates a plain object from a GetPhraseSetRequest message. Also converts values to other types if specified. + * @param message GetPhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.GetPhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetPhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetPhraseSetRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdatePhraseSetRequest. */ + interface IUpdatePhraseSetRequest { + + /** UpdatePhraseSetRequest phraseSet */ + phraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + + /** UpdatePhraseSetRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdatePhraseSetRequest validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents an UpdatePhraseSetRequest. */ + class UpdatePhraseSetRequest implements IUpdatePhraseSetRequest { + + /** + * Constructs a new UpdatePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUpdatePhraseSetRequest); + + /** UpdatePhraseSetRequest phraseSet. */ + public phraseSet?: (google.cloud.speech.v2.IPhraseSet|null); + + /** UpdatePhraseSetRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdatePhraseSetRequest validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new UpdatePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdatePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUpdatePhraseSetRequest): google.cloud.speech.v2.UpdatePhraseSetRequest; + + /** + * Encodes the specified UpdatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdatePhraseSetRequest.verify|verify} messages. + * @param message UpdatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUpdatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdatePhraseSetRequest.verify|verify} messages. + * @param message UpdatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUpdatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdatePhraseSetRequest + * @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.v2.UpdatePhraseSetRequest; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdatePhraseSetRequest + * @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.v2.UpdatePhraseSetRequest; + + /** + * Verifies an UpdatePhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdatePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UpdatePhraseSetRequest; + + /** + * Creates a plain object from an UpdatePhraseSetRequest message. Also converts values to other types if specified. + * @param message UpdatePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UpdatePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdatePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdatePhraseSetRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeletePhraseSetRequest. */ + interface IDeletePhraseSetRequest { + + /** DeletePhraseSetRequest name */ + name?: (string|null); + + /** DeletePhraseSetRequest validateOnly */ + validateOnly?: (boolean|null); + + /** DeletePhraseSetRequest allowMissing */ + allowMissing?: (boolean|null); + + /** DeletePhraseSetRequest etag */ + etag?: (string|null); + } + + /** Represents a DeletePhraseSetRequest. */ + class DeletePhraseSetRequest implements IDeletePhraseSetRequest { + + /** + * Constructs a new DeletePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IDeletePhraseSetRequest); + + /** DeletePhraseSetRequest name. */ + public name: string; + + /** DeletePhraseSetRequest validateOnly. */ + public validateOnly: boolean; + + /** DeletePhraseSetRequest allowMissing. */ + public allowMissing: boolean; + + /** DeletePhraseSetRequest etag. */ + public etag: string; + + /** + * Creates a new DeletePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeletePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IDeletePhraseSetRequest): google.cloud.speech.v2.DeletePhraseSetRequest; + + /** + * Encodes the specified DeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.DeletePhraseSetRequest.verify|verify} messages. + * @param message DeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IDeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeletePhraseSetRequest.verify|verify} messages. + * @param message DeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IDeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeletePhraseSetRequest + * @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.v2.DeletePhraseSetRequest; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeletePhraseSetRequest + * @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.v2.DeletePhraseSetRequest; + + /** + * Verifies a DeletePhraseSetRequest 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 DeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeletePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.DeletePhraseSetRequest; + + /** + * Creates a plain object from a DeletePhraseSetRequest message. Also converts values to other types if specified. + * @param message DeletePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.DeletePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeletePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeletePhraseSetRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UndeletePhraseSetRequest. */ + interface IUndeletePhraseSetRequest { + + /** UndeletePhraseSetRequest name */ + name?: (string|null); + + /** UndeletePhraseSetRequest validateOnly */ + validateOnly?: (boolean|null); + + /** UndeletePhraseSetRequest etag */ + etag?: (string|null); + } + + /** Represents an UndeletePhraseSetRequest. */ + class UndeletePhraseSetRequest implements IUndeletePhraseSetRequest { + + /** + * Constructs a new UndeletePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v2.IUndeletePhraseSetRequest); + + /** UndeletePhraseSetRequest name. */ + public name: string; + + /** UndeletePhraseSetRequest validateOnly. */ + public validateOnly: boolean; + + /** UndeletePhraseSetRequest etag. */ + public etag: string; + + /** + * Creates a new UndeletePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UndeletePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v2.IUndeletePhraseSetRequest): google.cloud.speech.v2.UndeletePhraseSetRequest; + + /** + * Encodes the specified UndeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeletePhraseSetRequest.verify|verify} messages. + * @param message UndeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v2.IUndeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UndeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeletePhraseSetRequest.verify|verify} messages. + * @param message UndeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v2.IUndeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UndeletePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UndeletePhraseSetRequest + * @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.v2.UndeletePhraseSetRequest; + + /** + * Decodes an UndeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UndeletePhraseSetRequest + * @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.v2.UndeletePhraseSetRequest; + + /** + * Verifies an UndeletePhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UndeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UndeletePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v2.UndeletePhraseSetRequest; + + /** + * Creates a plain object from an UndeletePhraseSetRequest message. Also converts values to other types if specified. + * @param message UndeletePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v2.UndeletePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UndeletePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UndeletePhraseSetRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } } } diff --git a/packages/google-cloud-speech/protos/protos.js b/packages/google-cloud-speech/protos/protos.js index aa6127df811..4e1e39889e3 100644 --- a/packages/google-cloud-speech/protos/protos.js +++ b/packages/google-cloud-speech/protos/protos.js @@ -21335,6 +21335,17029 @@ return v1p1beta1; })(); + speech.v2 = (function() { + + /** + * Namespace v2. + * @memberof google.cloud.speech + * @namespace + */ + var v2 = {}; + + v2.Speech = (function() { + + /** + * Constructs a new Speech service. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a Speech + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Speech(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Speech.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Speech; + + /** + * Creates new Speech service using the specified rpc implementation. + * @function create + * @memberof google.cloud.speech.v2.Speech + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Speech} RPC service. Useful where requests and/or responses are streamed. + */ + Speech.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createRecognizer}. + * @memberof google.cloud.speech.v2.Speech + * @typedef CreateRecognizerCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateRecognizer. + * @function createRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreateRecognizerRequest} request CreateRecognizerRequest message or plain object + * @param {google.cloud.speech.v2.Speech.CreateRecognizerCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.createRecognizer = function createRecognizer(request, callback) { + return this.rpcCall(createRecognizer, $root.google.cloud.speech.v2.CreateRecognizerRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateRecognizer" }); + + /** + * Calls CreateRecognizer. + * @function createRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreateRecognizerRequest} request CreateRecognizerRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listRecognizers}. + * @memberof google.cloud.speech.v2.Speech + * @typedef ListRecognizersCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.ListRecognizersResponse} [response] ListRecognizersResponse + */ + + /** + * Calls ListRecognizers. + * @function listRecognizers + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListRecognizersRequest} request ListRecognizersRequest message or plain object + * @param {google.cloud.speech.v2.Speech.ListRecognizersCallback} callback Node-style callback called with the error, if any, and ListRecognizersResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.listRecognizers = function listRecognizers(request, callback) { + return this.rpcCall(listRecognizers, $root.google.cloud.speech.v2.ListRecognizersRequest, $root.google.cloud.speech.v2.ListRecognizersResponse, request, callback); + }, "name", { value: "ListRecognizers" }); + + /** + * Calls ListRecognizers. + * @function listRecognizers + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListRecognizersRequest} request ListRecognizersRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getRecognizer}. + * @memberof google.cloud.speech.v2.Speech + * @typedef GetRecognizerCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.Recognizer} [response] Recognizer + */ + + /** + * Calls GetRecognizer. + * @function getRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetRecognizerRequest} request GetRecognizerRequest message or plain object + * @param {google.cloud.speech.v2.Speech.GetRecognizerCallback} callback Node-style callback called with the error, if any, and Recognizer + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.getRecognizer = function getRecognizer(request, callback) { + return this.rpcCall(getRecognizer, $root.google.cloud.speech.v2.GetRecognizerRequest, $root.google.cloud.speech.v2.Recognizer, request, callback); + }, "name", { value: "GetRecognizer" }); + + /** + * Calls GetRecognizer. + * @function getRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetRecognizerRequest} request GetRecognizerRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateRecognizer}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UpdateRecognizerCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UpdateRecognizer. + * @function updateRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest} request UpdateRecognizerRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UpdateRecognizerCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.updateRecognizer = function updateRecognizer(request, callback) { + return this.rpcCall(updateRecognizer, $root.google.cloud.speech.v2.UpdateRecognizerRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdateRecognizer" }); + + /** + * Calls UpdateRecognizer. + * @function updateRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest} request UpdateRecognizerRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deleteRecognizer}. + * @memberof google.cloud.speech.v2.Speech + * @typedef DeleteRecognizerCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeleteRecognizer. + * @function deleteRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest} request DeleteRecognizerRequest message or plain object + * @param {google.cloud.speech.v2.Speech.DeleteRecognizerCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.deleteRecognizer = function deleteRecognizer(request, callback) { + return this.rpcCall(deleteRecognizer, $root.google.cloud.speech.v2.DeleteRecognizerRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeleteRecognizer" }); + + /** + * Calls DeleteRecognizer. + * @function deleteRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest} request DeleteRecognizerRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeleteRecognizer}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UndeleteRecognizerCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UndeleteRecognizer. + * @function undeleteRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest} request UndeleteRecognizerRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UndeleteRecognizerCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.undeleteRecognizer = function undeleteRecognizer(request, callback) { + return this.rpcCall(undeleteRecognizer, $root.google.cloud.speech.v2.UndeleteRecognizerRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UndeleteRecognizer" }); + + /** + * Calls UndeleteRecognizer. + * @function undeleteRecognizer + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest} request UndeleteRecognizerRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|recognize}. + * @memberof google.cloud.speech.v2.Speech + * @typedef RecognizeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.RecognizeResponse} [response] RecognizeResponse + */ + + /** + * Calls Recognize. + * @function recognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IRecognizeRequest} request RecognizeRequest message or plain object + * @param {google.cloud.speech.v2.Speech.RecognizeCallback} callback Node-style callback called with the error, if any, and RecognizeResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.recognize = function recognize(request, callback) { + return this.rpcCall(recognize, $root.google.cloud.speech.v2.RecognizeRequest, $root.google.cloud.speech.v2.RecognizeResponse, request, callback); + }, "name", { value: "Recognize" }); + + /** + * Calls Recognize. + * @function recognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IRecognizeRequest} request RecognizeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|streamingRecognize}. + * @memberof google.cloud.speech.v2.Speech + * @typedef StreamingRecognizeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.StreamingRecognizeResponse} [response] StreamingRecognizeResponse + */ + + /** + * Calls StreamingRecognize. + * @function streamingRecognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest} request StreamingRecognizeRequest message or plain object + * @param {google.cloud.speech.v2.Speech.StreamingRecognizeCallback} callback Node-style callback called with the error, if any, and StreamingRecognizeResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.streamingRecognize = function streamingRecognize(request, callback) { + return this.rpcCall(streamingRecognize, $root.google.cloud.speech.v2.StreamingRecognizeRequest, $root.google.cloud.speech.v2.StreamingRecognizeResponse, request, callback); + }, "name", { value: "StreamingRecognize" }); + + /** + * Calls StreamingRecognize. + * @function streamingRecognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest} request StreamingRecognizeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|batchRecognize}. + * @memberof google.cloud.speech.v2.Speech + * @typedef BatchRecognizeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls BatchRecognize. + * @function batchRecognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IBatchRecognizeRequest} request BatchRecognizeRequest message or plain object + * @param {google.cloud.speech.v2.Speech.BatchRecognizeCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.batchRecognize = function batchRecognize(request, callback) { + return this.rpcCall(batchRecognize, $root.google.cloud.speech.v2.BatchRecognizeRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "BatchRecognize" }); + + /** + * Calls BatchRecognize. + * @function batchRecognize + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IBatchRecognizeRequest} request BatchRecognizeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getConfig}. + * @memberof google.cloud.speech.v2.Speech + * @typedef GetConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.Config} [response] Config + */ + + /** + * Calls GetConfig. + * @function getConfig + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetConfigRequest} request GetConfigRequest message or plain object + * @param {google.cloud.speech.v2.Speech.GetConfigCallback} callback Node-style callback called with the error, if any, and Config + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.getConfig = function getConfig(request, callback) { + return this.rpcCall(getConfig, $root.google.cloud.speech.v2.GetConfigRequest, $root.google.cloud.speech.v2.Config, request, callback); + }, "name", { value: "GetConfig" }); + + /** + * Calls GetConfig. + * @function getConfig + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetConfigRequest} request GetConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateConfig}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UpdateConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.Config} [response] Config + */ + + /** + * Calls UpdateConfig. + * @function updateConfig + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateConfigRequest} request UpdateConfigRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UpdateConfigCallback} callback Node-style callback called with the error, if any, and Config + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.updateConfig = function updateConfig(request, callback) { + return this.rpcCall(updateConfig, $root.google.cloud.speech.v2.UpdateConfigRequest, $root.google.cloud.speech.v2.Config, request, callback); + }, "name", { value: "UpdateConfig" }); + + /** + * Calls UpdateConfig. + * @function updateConfig + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateConfigRequest} request UpdateConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createCustomClass}. + * @memberof google.cloud.speech.v2.Speech + * @typedef CreateCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateCustomClass. + * @function createCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreateCustomClassRequest} request CreateCustomClassRequest message or plain object + * @param {google.cloud.speech.v2.Speech.CreateCustomClassCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.createCustomClass = function createCustomClass(request, callback) { + return this.rpcCall(createCustomClass, $root.google.cloud.speech.v2.CreateCustomClassRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateCustomClass" }); + + /** + * Calls CreateCustomClass. + * @function createCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreateCustomClassRequest} request CreateCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listCustomClasses}. + * @memberof google.cloud.speech.v2.Speech + * @typedef ListCustomClassesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.ListCustomClassesResponse} [response] ListCustomClassesResponse + */ + + /** + * Calls ListCustomClasses. + * @function listCustomClasses + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListCustomClassesRequest} request ListCustomClassesRequest message or plain object + * @param {google.cloud.speech.v2.Speech.ListCustomClassesCallback} callback Node-style callback called with the error, if any, and ListCustomClassesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.listCustomClasses = function listCustomClasses(request, callback) { + return this.rpcCall(listCustomClasses, $root.google.cloud.speech.v2.ListCustomClassesRequest, $root.google.cloud.speech.v2.ListCustomClassesResponse, request, callback); + }, "name", { value: "ListCustomClasses" }); + + /** + * Calls ListCustomClasses. + * @function listCustomClasses + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListCustomClassesRequest} request ListCustomClassesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getCustomClass}. + * @memberof google.cloud.speech.v2.Speech + * @typedef GetCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.CustomClass} [response] CustomClass + */ + + /** + * Calls GetCustomClass. + * @function getCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetCustomClassRequest} request GetCustomClassRequest message or plain object + * @param {google.cloud.speech.v2.Speech.GetCustomClassCallback} callback Node-style callback called with the error, if any, and CustomClass + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.getCustomClass = function getCustomClass(request, callback) { + return this.rpcCall(getCustomClass, $root.google.cloud.speech.v2.GetCustomClassRequest, $root.google.cloud.speech.v2.CustomClass, request, callback); + }, "name", { value: "GetCustomClass" }); + + /** + * Calls GetCustomClass. + * @function getCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetCustomClassRequest} request GetCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updateCustomClass}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UpdateCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UpdateCustomClass. + * @function updateCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest} request UpdateCustomClassRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UpdateCustomClassCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.updateCustomClass = function updateCustomClass(request, callback) { + return this.rpcCall(updateCustomClass, $root.google.cloud.speech.v2.UpdateCustomClassRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdateCustomClass" }); + + /** + * Calls UpdateCustomClass. + * @function updateCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest} request UpdateCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deleteCustomClass}. + * @memberof google.cloud.speech.v2.Speech + * @typedef DeleteCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeleteCustomClass. + * @function deleteCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest} request DeleteCustomClassRequest message or plain object + * @param {google.cloud.speech.v2.Speech.DeleteCustomClassCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.deleteCustomClass = function deleteCustomClass(request, callback) { + return this.rpcCall(deleteCustomClass, $root.google.cloud.speech.v2.DeleteCustomClassRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeleteCustomClass" }); + + /** + * Calls DeleteCustomClass. + * @function deleteCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest} request DeleteCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeleteCustomClass}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UndeleteCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UndeleteCustomClass. + * @function undeleteCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest} request UndeleteCustomClassRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UndeleteCustomClassCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.undeleteCustomClass = function undeleteCustomClass(request, callback) { + return this.rpcCall(undeleteCustomClass, $root.google.cloud.speech.v2.UndeleteCustomClassRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UndeleteCustomClass" }); + + /** + * Calls UndeleteCustomClass. + * @function undeleteCustomClass + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest} request UndeleteCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|createPhraseSet}. + * @memberof google.cloud.speech.v2.Speech + * @typedef CreatePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreatePhraseSet. + * @function createPhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest} request CreatePhraseSetRequest message or plain object + * @param {google.cloud.speech.v2.Speech.CreatePhraseSetCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.createPhraseSet = function createPhraseSet(request, callback) { + return this.rpcCall(createPhraseSet, $root.google.cloud.speech.v2.CreatePhraseSetRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreatePhraseSet" }); + + /** + * Calls CreatePhraseSet. + * @function createPhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest} request CreatePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|listPhraseSets}. + * @memberof google.cloud.speech.v2.Speech + * @typedef ListPhraseSetsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.ListPhraseSetsResponse} [response] ListPhraseSetsResponse + */ + + /** + * Calls ListPhraseSets. + * @function listPhraseSets + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListPhraseSetsRequest} request ListPhraseSetsRequest message or plain object + * @param {google.cloud.speech.v2.Speech.ListPhraseSetsCallback} callback Node-style callback called with the error, if any, and ListPhraseSetsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.listPhraseSets = function listPhraseSets(request, callback) { + return this.rpcCall(listPhraseSets, $root.google.cloud.speech.v2.ListPhraseSetsRequest, $root.google.cloud.speech.v2.ListPhraseSetsResponse, request, callback); + }, "name", { value: "ListPhraseSets" }); + + /** + * Calls ListPhraseSets. + * @function listPhraseSets + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IListPhraseSetsRequest} request ListPhraseSetsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|getPhraseSet}. + * @memberof google.cloud.speech.v2.Speech + * @typedef GetPhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v2.PhraseSet} [response] PhraseSet + */ + + /** + * Calls GetPhraseSet. + * @function getPhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetPhraseSetRequest} request GetPhraseSetRequest message or plain object + * @param {google.cloud.speech.v2.Speech.GetPhraseSetCallback} callback Node-style callback called with the error, if any, and PhraseSet + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.getPhraseSet = function getPhraseSet(request, callback) { + return this.rpcCall(getPhraseSet, $root.google.cloud.speech.v2.GetPhraseSetRequest, $root.google.cloud.speech.v2.PhraseSet, request, callback); + }, "name", { value: "GetPhraseSet" }); + + /** + * Calls GetPhraseSet. + * @function getPhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IGetPhraseSetRequest} request GetPhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|updatePhraseSet}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UpdatePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UpdatePhraseSet. + * @function updatePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest} request UpdatePhraseSetRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UpdatePhraseSetCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.updatePhraseSet = function updatePhraseSet(request, callback) { + return this.rpcCall(updatePhraseSet, $root.google.cloud.speech.v2.UpdatePhraseSetRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdatePhraseSet" }); + + /** + * Calls UpdatePhraseSet. + * @function updatePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest} request UpdatePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|deletePhraseSet}. + * @memberof google.cloud.speech.v2.Speech + * @typedef DeletePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeletePhraseSet. + * @function deletePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest} request DeletePhraseSetRequest message or plain object + * @param {google.cloud.speech.v2.Speech.DeletePhraseSetCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.deletePhraseSet = function deletePhraseSet(request, callback) { + return this.rpcCall(deletePhraseSet, $root.google.cloud.speech.v2.DeletePhraseSetRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeletePhraseSet" }); + + /** + * Calls DeletePhraseSet. + * @function deletePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest} request DeletePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v2.Speech|undeletePhraseSet}. + * @memberof google.cloud.speech.v2.Speech + * @typedef UndeletePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UndeletePhraseSet. + * @function undeletePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest} request UndeletePhraseSetRequest message or plain object + * @param {google.cloud.speech.v2.Speech.UndeletePhraseSetCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Speech.prototype.undeletePhraseSet = function undeletePhraseSet(request, callback) { + return this.rpcCall(undeletePhraseSet, $root.google.cloud.speech.v2.UndeletePhraseSetRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UndeletePhraseSet" }); + + /** + * Calls UndeletePhraseSet. + * @function undeletePhraseSet + * @memberof google.cloud.speech.v2.Speech + * @instance + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest} request UndeletePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Speech; + })(); + + v2.CreateRecognizerRequest = (function() { + + /** + * Properties of a CreateRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @interface ICreateRecognizerRequest + * @property {google.cloud.speech.v2.IRecognizer|null} [recognizer] CreateRecognizerRequest recognizer + * @property {boolean|null} [validateOnly] CreateRecognizerRequest validateOnly + * @property {string|null} [recognizerId] CreateRecognizerRequest recognizerId + * @property {string|null} [parent] CreateRecognizerRequest parent + */ + + /** + * Constructs a new CreateRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a CreateRecognizerRequest. + * @implements ICreateRecognizerRequest + * @constructor + * @param {google.cloud.speech.v2.ICreateRecognizerRequest=} [properties] Properties to set + */ + function CreateRecognizerRequest(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]]; + } + + /** + * CreateRecognizerRequest recognizer. + * @member {google.cloud.speech.v2.IRecognizer|null|undefined} recognizer + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @instance + */ + CreateRecognizerRequest.prototype.recognizer = null; + + /** + * CreateRecognizerRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @instance + */ + CreateRecognizerRequest.prototype.validateOnly = false; + + /** + * CreateRecognizerRequest recognizerId. + * @member {string} recognizerId + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @instance + */ + CreateRecognizerRequest.prototype.recognizerId = ""; + + /** + * CreateRecognizerRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @instance + */ + CreateRecognizerRequest.prototype.parent = ""; + + /** + * Creates a new CreateRecognizerRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.ICreateRecognizerRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.CreateRecognizerRequest} CreateRecognizerRequest instance + */ + CreateRecognizerRequest.create = function create(properties) { + return new CreateRecognizerRequest(properties); + }; + + /** + * Encodes the specified CreateRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.CreateRecognizerRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.ICreateRecognizerRequest} message CreateRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateRecognizerRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recognizer != null && Object.hasOwnProperty.call(message, "recognizer")) + $root.google.cloud.speech.v2.Recognizer.encode(message.recognizer, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.recognizerId != null && Object.hasOwnProperty.call(message, "recognizerId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.recognizerId); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.parent); + return writer; + }; + + /** + * Encodes the specified CreateRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreateRecognizerRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.ICreateRecognizerRequest} message CreateRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateRecognizerRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateRecognizerRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.CreateRecognizerRequest} CreateRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateRecognizerRequest.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.v2.CreateRecognizerRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recognizer = $root.google.cloud.speech.v2.Recognizer.decode(reader, reader.uint32()); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.recognizerId = reader.string(); + break; + } + case 4: { + message.parent = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateRecognizerRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.CreateRecognizerRequest} CreateRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateRecognizerRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateRecognizerRequest message. + * @function verify + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateRecognizerRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) { + var error = $root.google.cloud.speech.v2.Recognizer.verify(message.recognizer); + if (error) + return "recognizer." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.recognizerId != null && message.hasOwnProperty("recognizerId")) + if (!$util.isString(message.recognizerId)) + return "recognizerId: string expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + return null; + }; + + /** + * Creates a CreateRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.CreateRecognizerRequest} CreateRecognizerRequest + */ + CreateRecognizerRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.CreateRecognizerRequest) + return object; + var message = new $root.google.cloud.speech.v2.CreateRecognizerRequest(); + if (object.recognizer != null) { + if (typeof object.recognizer !== "object") + throw TypeError(".google.cloud.speech.v2.CreateRecognizerRequest.recognizer: object expected"); + message.recognizer = $root.google.cloud.speech.v2.Recognizer.fromObject(object.recognizer); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.recognizerId != null) + message.recognizerId = String(object.recognizerId); + if (object.parent != null) + message.parent = String(object.parent); + return message; + }; + + /** + * Creates a plain object from a CreateRecognizerRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.CreateRecognizerRequest} message CreateRecognizerRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateRecognizerRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.recognizer = null; + object.validateOnly = false; + object.recognizerId = ""; + object.parent = ""; + } + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + object.recognizer = $root.google.cloud.speech.v2.Recognizer.toObject(message.recognizer, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.recognizerId != null && message.hasOwnProperty("recognizerId")) + object.recognizerId = message.recognizerId; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + return object; + }; + + /** + * Converts this CreateRecognizerRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @instance + * @returns {Object.} JSON object + */ + CreateRecognizerRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateRecognizerRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.CreateRecognizerRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateRecognizerRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.CreateRecognizerRequest"; + }; + + return CreateRecognizerRequest; + })(); + + v2.OperationMetadata = (function() { + + /** + * Properties of an OperationMetadata. + * @memberof google.cloud.speech.v2 + * @interface IOperationMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] OperationMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] OperationMetadata updateTime + * @property {string|null} [resource] OperationMetadata resource + * @property {string|null} [method] OperationMetadata method + * @property {string|null} [kmsKeyName] OperationMetadata kmsKeyName + * @property {string|null} [kmsKeyVersionName] OperationMetadata kmsKeyVersionName + * @property {google.cloud.speech.v2.IBatchRecognizeRequest|null} [batchRecognizeRequest] OperationMetadata batchRecognizeRequest + * @property {google.cloud.speech.v2.ICreateRecognizerRequest|null} [createRecognizerRequest] OperationMetadata createRecognizerRequest + * @property {google.cloud.speech.v2.IUpdateRecognizerRequest|null} [updateRecognizerRequest] OperationMetadata updateRecognizerRequest + * @property {google.cloud.speech.v2.IDeleteRecognizerRequest|null} [deleteRecognizerRequest] OperationMetadata deleteRecognizerRequest + * @property {google.cloud.speech.v2.IUndeleteRecognizerRequest|null} [undeleteRecognizerRequest] OperationMetadata undeleteRecognizerRequest + * @property {google.cloud.speech.v2.ICreateCustomClassRequest|null} [createCustomClassRequest] OperationMetadata createCustomClassRequest + * @property {google.cloud.speech.v2.IUpdateCustomClassRequest|null} [updateCustomClassRequest] OperationMetadata updateCustomClassRequest + * @property {google.cloud.speech.v2.IDeleteCustomClassRequest|null} [deleteCustomClassRequest] OperationMetadata deleteCustomClassRequest + * @property {google.cloud.speech.v2.IUndeleteCustomClassRequest|null} [undeleteCustomClassRequest] OperationMetadata undeleteCustomClassRequest + * @property {google.cloud.speech.v2.ICreatePhraseSetRequest|null} [createPhraseSetRequest] OperationMetadata createPhraseSetRequest + * @property {google.cloud.speech.v2.IUpdatePhraseSetRequest|null} [updatePhraseSetRequest] OperationMetadata updatePhraseSetRequest + * @property {google.cloud.speech.v2.IDeletePhraseSetRequest|null} [deletePhraseSetRequest] OperationMetadata deletePhraseSetRequest + * @property {google.cloud.speech.v2.IUndeletePhraseSetRequest|null} [undeletePhraseSetRequest] OperationMetadata undeletePhraseSetRequest + * @property {google.cloud.speech.v2.IUpdateConfigRequest|null} [updateConfigRequest] OperationMetadata updateConfigRequest + * @property {number|null} [progressPercent] OperationMetadata progressPercent + * @property {google.cloud.speech.v2.IBatchRecognizeMetadata|null} [batchRecognizeMetadata] OperationMetadata batchRecognizeMetadata + */ + + /** + * Constructs a new OperationMetadata. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an OperationMetadata. + * @implements IOperationMetadata + * @constructor + * @param {google.cloud.speech.v2.IOperationMetadata=} [properties] Properties to set + */ + function OperationMetadata(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]]; + } + + /** + * OperationMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.createTime = null; + + /** + * OperationMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.updateTime = null; + + /** + * OperationMetadata resource. + * @member {string} resource + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.resource = ""; + + /** + * OperationMetadata method. + * @member {string} method + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.method = ""; + + /** + * OperationMetadata kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.kmsKeyName = ""; + + /** + * OperationMetadata kmsKeyVersionName. + * @member {string} kmsKeyVersionName + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.kmsKeyVersionName = ""; + + /** + * OperationMetadata batchRecognizeRequest. + * @member {google.cloud.speech.v2.IBatchRecognizeRequest|null|undefined} batchRecognizeRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.batchRecognizeRequest = null; + + /** + * OperationMetadata createRecognizerRequest. + * @member {google.cloud.speech.v2.ICreateRecognizerRequest|null|undefined} createRecognizerRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.createRecognizerRequest = null; + + /** + * OperationMetadata updateRecognizerRequest. + * @member {google.cloud.speech.v2.IUpdateRecognizerRequest|null|undefined} updateRecognizerRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.updateRecognizerRequest = null; + + /** + * OperationMetadata deleteRecognizerRequest. + * @member {google.cloud.speech.v2.IDeleteRecognizerRequest|null|undefined} deleteRecognizerRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.deleteRecognizerRequest = null; + + /** + * OperationMetadata undeleteRecognizerRequest. + * @member {google.cloud.speech.v2.IUndeleteRecognizerRequest|null|undefined} undeleteRecognizerRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.undeleteRecognizerRequest = null; + + /** + * OperationMetadata createCustomClassRequest. + * @member {google.cloud.speech.v2.ICreateCustomClassRequest|null|undefined} createCustomClassRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.createCustomClassRequest = null; + + /** + * OperationMetadata updateCustomClassRequest. + * @member {google.cloud.speech.v2.IUpdateCustomClassRequest|null|undefined} updateCustomClassRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.updateCustomClassRequest = null; + + /** + * OperationMetadata deleteCustomClassRequest. + * @member {google.cloud.speech.v2.IDeleteCustomClassRequest|null|undefined} deleteCustomClassRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.deleteCustomClassRequest = null; + + /** + * OperationMetadata undeleteCustomClassRequest. + * @member {google.cloud.speech.v2.IUndeleteCustomClassRequest|null|undefined} undeleteCustomClassRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.undeleteCustomClassRequest = null; + + /** + * OperationMetadata createPhraseSetRequest. + * @member {google.cloud.speech.v2.ICreatePhraseSetRequest|null|undefined} createPhraseSetRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.createPhraseSetRequest = null; + + /** + * OperationMetadata updatePhraseSetRequest. + * @member {google.cloud.speech.v2.IUpdatePhraseSetRequest|null|undefined} updatePhraseSetRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.updatePhraseSetRequest = null; + + /** + * OperationMetadata deletePhraseSetRequest. + * @member {google.cloud.speech.v2.IDeletePhraseSetRequest|null|undefined} deletePhraseSetRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.deletePhraseSetRequest = null; + + /** + * OperationMetadata undeletePhraseSetRequest. + * @member {google.cloud.speech.v2.IUndeletePhraseSetRequest|null|undefined} undeletePhraseSetRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.undeletePhraseSetRequest = null; + + /** + * OperationMetadata updateConfigRequest. + * @member {google.cloud.speech.v2.IUpdateConfigRequest|null|undefined} updateConfigRequest + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.updateConfigRequest = null; + + /** + * OperationMetadata progressPercent. + * @member {number} progressPercent + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.progressPercent = 0; + + /** + * OperationMetadata batchRecognizeMetadata. + * @member {google.cloud.speech.v2.IBatchRecognizeMetadata|null|undefined} batchRecognizeMetadata + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + OperationMetadata.prototype.batchRecognizeMetadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * OperationMetadata request. + * @member {"batchRecognizeRequest"|"createRecognizerRequest"|"updateRecognizerRequest"|"deleteRecognizerRequest"|"undeleteRecognizerRequest"|"createCustomClassRequest"|"updateCustomClassRequest"|"deleteCustomClassRequest"|"undeleteCustomClassRequest"|"createPhraseSetRequest"|"updatePhraseSetRequest"|"deletePhraseSetRequest"|"undeletePhraseSetRequest"|"updateConfigRequest"|undefined} request + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + Object.defineProperty(OperationMetadata.prototype, "request", { + get: $util.oneOfGetter($oneOfFields = ["batchRecognizeRequest", "createRecognizerRequest", "updateRecognizerRequest", "deleteRecognizerRequest", "undeleteRecognizerRequest", "createCustomClassRequest", "updateCustomClassRequest", "deleteCustomClassRequest", "undeleteCustomClassRequest", "createPhraseSetRequest", "updatePhraseSetRequest", "deletePhraseSetRequest", "undeletePhraseSetRequest", "updateConfigRequest"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * OperationMetadata metadata. + * @member {"batchRecognizeMetadata"|undefined} metadata + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + */ + Object.defineProperty(OperationMetadata.prototype, "metadata", { + get: $util.oneOfGetter($oneOfFields = ["batchRecognizeMetadata"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new OperationMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {google.cloud.speech.v2.IOperationMetadata=} [properties] Properties to set + * @returns {google.cloud.speech.v2.OperationMetadata} OperationMetadata instance + */ + OperationMetadata.create = function create(properties) { + return new OperationMetadata(properties); + }; + + /** + * Encodes the specified OperationMetadata message. Does not implicitly {@link google.cloud.speech.v2.OperationMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {google.cloud.speech.v2.IOperationMetadata} message OperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.resource != null && Object.hasOwnProperty.call(message, "resource")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.resource); + if (message.method != null && Object.hasOwnProperty.call(message, "method")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.method); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.kmsKeyName); + if (message.kmsKeyVersionName != null && Object.hasOwnProperty.call(message, "kmsKeyVersionName")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.kmsKeyVersionName); + if (message.batchRecognizeRequest != null && Object.hasOwnProperty.call(message, "batchRecognizeRequest")) + $root.google.cloud.speech.v2.BatchRecognizeRequest.encode(message.batchRecognizeRequest, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.createRecognizerRequest != null && Object.hasOwnProperty.call(message, "createRecognizerRequest")) + $root.google.cloud.speech.v2.CreateRecognizerRequest.encode(message.createRecognizerRequest, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.updateRecognizerRequest != null && Object.hasOwnProperty.call(message, "updateRecognizerRequest")) + $root.google.cloud.speech.v2.UpdateRecognizerRequest.encode(message.updateRecognizerRequest, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.deleteRecognizerRequest != null && Object.hasOwnProperty.call(message, "deleteRecognizerRequest")) + $root.google.cloud.speech.v2.DeleteRecognizerRequest.encode(message.deleteRecognizerRequest, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.undeleteRecognizerRequest != null && Object.hasOwnProperty.call(message, "undeleteRecognizerRequest")) + $root.google.cloud.speech.v2.UndeleteRecognizerRequest.encode(message.undeleteRecognizerRequest, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.createCustomClassRequest != null && Object.hasOwnProperty.call(message, "createCustomClassRequest")) + $root.google.cloud.speech.v2.CreateCustomClassRequest.encode(message.createCustomClassRequest, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + if (message.updateCustomClassRequest != null && Object.hasOwnProperty.call(message, "updateCustomClassRequest")) + $root.google.cloud.speech.v2.UpdateCustomClassRequest.encode(message.updateCustomClassRequest, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.deleteCustomClassRequest != null && Object.hasOwnProperty.call(message, "deleteCustomClassRequest")) + $root.google.cloud.speech.v2.DeleteCustomClassRequest.encode(message.deleteCustomClassRequest, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.undeleteCustomClassRequest != null && Object.hasOwnProperty.call(message, "undeleteCustomClassRequest")) + $root.google.cloud.speech.v2.UndeleteCustomClassRequest.encode(message.undeleteCustomClassRequest, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.createPhraseSetRequest != null && Object.hasOwnProperty.call(message, "createPhraseSetRequest")) + $root.google.cloud.speech.v2.CreatePhraseSetRequest.encode(message.createPhraseSetRequest, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.updatePhraseSetRequest != null && Object.hasOwnProperty.call(message, "updatePhraseSetRequest")) + $root.google.cloud.speech.v2.UpdatePhraseSetRequest.encode(message.updatePhraseSetRequest, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.deletePhraseSetRequest != null && Object.hasOwnProperty.call(message, "deletePhraseSetRequest")) + $root.google.cloud.speech.v2.DeletePhraseSetRequest.encode(message.deletePhraseSetRequest, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + if (message.undeletePhraseSetRequest != null && Object.hasOwnProperty.call(message, "undeletePhraseSetRequest")) + $root.google.cloud.speech.v2.UndeletePhraseSetRequest.encode(message.undeletePhraseSetRequest, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.updateConfigRequest != null && Object.hasOwnProperty.call(message, "updateConfigRequest")) + $root.google.cloud.speech.v2.UpdateConfigRequest.encode(message.updateConfigRequest, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.progressPercent != null && Object.hasOwnProperty.call(message, "progressPercent")) + writer.uint32(/* id 22, wireType 0 =*/176).int32(message.progressPercent); + if (message.batchRecognizeMetadata != null && Object.hasOwnProperty.call(message, "batchRecognizeMetadata")) + $root.google.cloud.speech.v2.BatchRecognizeMetadata.encode(message.batchRecognizeMetadata, writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OperationMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.OperationMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {google.cloud.speech.v2.IOperationMetadata} message OperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OperationMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.OperationMetadata} OperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationMetadata.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.v2.OperationMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.resource = reader.string(); + break; + } + case 4: { + message.method = reader.string(); + break; + } + case 6: { + message.kmsKeyName = reader.string(); + break; + } + case 7: { + message.kmsKeyVersionName = reader.string(); + break; + } + case 8: { + message.batchRecognizeRequest = $root.google.cloud.speech.v2.BatchRecognizeRequest.decode(reader, reader.uint32()); + break; + } + case 9: { + message.createRecognizerRequest = $root.google.cloud.speech.v2.CreateRecognizerRequest.decode(reader, reader.uint32()); + break; + } + case 10: { + message.updateRecognizerRequest = $root.google.cloud.speech.v2.UpdateRecognizerRequest.decode(reader, reader.uint32()); + break; + } + case 11: { + message.deleteRecognizerRequest = $root.google.cloud.speech.v2.DeleteRecognizerRequest.decode(reader, reader.uint32()); + break; + } + case 12: { + message.undeleteRecognizerRequest = $root.google.cloud.speech.v2.UndeleteRecognizerRequest.decode(reader, reader.uint32()); + break; + } + case 13: { + message.createCustomClassRequest = $root.google.cloud.speech.v2.CreateCustomClassRequest.decode(reader, reader.uint32()); + break; + } + case 14: { + message.updateCustomClassRequest = $root.google.cloud.speech.v2.UpdateCustomClassRequest.decode(reader, reader.uint32()); + break; + } + case 15: { + message.deleteCustomClassRequest = $root.google.cloud.speech.v2.DeleteCustomClassRequest.decode(reader, reader.uint32()); + break; + } + case 16: { + message.undeleteCustomClassRequest = $root.google.cloud.speech.v2.UndeleteCustomClassRequest.decode(reader, reader.uint32()); + break; + } + case 17: { + message.createPhraseSetRequest = $root.google.cloud.speech.v2.CreatePhraseSetRequest.decode(reader, reader.uint32()); + break; + } + case 18: { + message.updatePhraseSetRequest = $root.google.cloud.speech.v2.UpdatePhraseSetRequest.decode(reader, reader.uint32()); + break; + } + case 19: { + message.deletePhraseSetRequest = $root.google.cloud.speech.v2.DeletePhraseSetRequest.decode(reader, reader.uint32()); + break; + } + case 20: { + message.undeletePhraseSetRequest = $root.google.cloud.speech.v2.UndeletePhraseSetRequest.decode(reader, reader.uint32()); + break; + } + case 21: { + message.updateConfigRequest = $root.google.cloud.speech.v2.UpdateConfigRequest.decode(reader, reader.uint32()); + break; + } + case 22: { + message.progressPercent = reader.int32(); + break; + } + case 23: { + message.batchRecognizeMetadata = $root.google.cloud.speech.v2.BatchRecognizeMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OperationMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.OperationMetadata} OperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OperationMetadata message. + * @function verify + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OperationMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.resource != null && message.hasOwnProperty("resource")) + if (!$util.isString(message.resource)) + return "resource: string expected"; + if (message.method != null && message.hasOwnProperty("method")) + if (!$util.isString(message.method)) + return "method: string expected"; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + if (!$util.isString(message.kmsKeyVersionName)) + return "kmsKeyVersionName: string expected"; + if (message.batchRecognizeRequest != null && message.hasOwnProperty("batchRecognizeRequest")) { + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.BatchRecognizeRequest.verify(message.batchRecognizeRequest); + if (error) + return "batchRecognizeRequest." + error; + } + } + if (message.createRecognizerRequest != null && message.hasOwnProperty("createRecognizerRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.CreateRecognizerRequest.verify(message.createRecognizerRequest); + if (error) + return "createRecognizerRequest." + error; + } + } + if (message.updateRecognizerRequest != null && message.hasOwnProperty("updateRecognizerRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UpdateRecognizerRequest.verify(message.updateRecognizerRequest); + if (error) + return "updateRecognizerRequest." + error; + } + } + if (message.deleteRecognizerRequest != null && message.hasOwnProperty("deleteRecognizerRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.DeleteRecognizerRequest.verify(message.deleteRecognizerRequest); + if (error) + return "deleteRecognizerRequest." + error; + } + } + if (message.undeleteRecognizerRequest != null && message.hasOwnProperty("undeleteRecognizerRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UndeleteRecognizerRequest.verify(message.undeleteRecognizerRequest); + if (error) + return "undeleteRecognizerRequest." + error; + } + } + if (message.createCustomClassRequest != null && message.hasOwnProperty("createCustomClassRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.CreateCustomClassRequest.verify(message.createCustomClassRequest); + if (error) + return "createCustomClassRequest." + error; + } + } + if (message.updateCustomClassRequest != null && message.hasOwnProperty("updateCustomClassRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UpdateCustomClassRequest.verify(message.updateCustomClassRequest); + if (error) + return "updateCustomClassRequest." + error; + } + } + if (message.deleteCustomClassRequest != null && message.hasOwnProperty("deleteCustomClassRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.DeleteCustomClassRequest.verify(message.deleteCustomClassRequest); + if (error) + return "deleteCustomClassRequest." + error; + } + } + if (message.undeleteCustomClassRequest != null && message.hasOwnProperty("undeleteCustomClassRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UndeleteCustomClassRequest.verify(message.undeleteCustomClassRequest); + if (error) + return "undeleteCustomClassRequest." + error; + } + } + if (message.createPhraseSetRequest != null && message.hasOwnProperty("createPhraseSetRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.CreatePhraseSetRequest.verify(message.createPhraseSetRequest); + if (error) + return "createPhraseSetRequest." + error; + } + } + if (message.updatePhraseSetRequest != null && message.hasOwnProperty("updatePhraseSetRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UpdatePhraseSetRequest.verify(message.updatePhraseSetRequest); + if (error) + return "updatePhraseSetRequest." + error; + } + } + if (message.deletePhraseSetRequest != null && message.hasOwnProperty("deletePhraseSetRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.DeletePhraseSetRequest.verify(message.deletePhraseSetRequest); + if (error) + return "deletePhraseSetRequest." + error; + } + } + if (message.undeletePhraseSetRequest != null && message.hasOwnProperty("undeletePhraseSetRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UndeletePhraseSetRequest.verify(message.undeletePhraseSetRequest); + if (error) + return "undeletePhraseSetRequest." + error; + } + } + if (message.updateConfigRequest != null && message.hasOwnProperty("updateConfigRequest")) { + if (properties.request === 1) + return "request: multiple values"; + properties.request = 1; + { + var error = $root.google.cloud.speech.v2.UpdateConfigRequest.verify(message.updateConfigRequest); + if (error) + return "updateConfigRequest." + error; + } + } + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + if (!$util.isInteger(message.progressPercent)) + return "progressPercent: integer expected"; + if (message.batchRecognizeMetadata != null && message.hasOwnProperty("batchRecognizeMetadata")) { + properties.metadata = 1; + { + var error = $root.google.cloud.speech.v2.BatchRecognizeMetadata.verify(message.batchRecognizeMetadata); + if (error) + return "batchRecognizeMetadata." + error; + } + } + return null; + }; + + /** + * Creates an OperationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.OperationMetadata} OperationMetadata + */ + OperationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.OperationMetadata) + return object; + var message = new $root.google.cloud.speech.v2.OperationMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.resource != null) + message.resource = String(object.resource); + if (object.method != null) + message.method = String(object.method); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.kmsKeyVersionName != null) + message.kmsKeyVersionName = String(object.kmsKeyVersionName); + if (object.batchRecognizeRequest != null) { + if (typeof object.batchRecognizeRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.batchRecognizeRequest: object expected"); + message.batchRecognizeRequest = $root.google.cloud.speech.v2.BatchRecognizeRequest.fromObject(object.batchRecognizeRequest); + } + if (object.createRecognizerRequest != null) { + if (typeof object.createRecognizerRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.createRecognizerRequest: object expected"); + message.createRecognizerRequest = $root.google.cloud.speech.v2.CreateRecognizerRequest.fromObject(object.createRecognizerRequest); + } + if (object.updateRecognizerRequest != null) { + if (typeof object.updateRecognizerRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.updateRecognizerRequest: object expected"); + message.updateRecognizerRequest = $root.google.cloud.speech.v2.UpdateRecognizerRequest.fromObject(object.updateRecognizerRequest); + } + if (object.deleteRecognizerRequest != null) { + if (typeof object.deleteRecognizerRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.deleteRecognizerRequest: object expected"); + message.deleteRecognizerRequest = $root.google.cloud.speech.v2.DeleteRecognizerRequest.fromObject(object.deleteRecognizerRequest); + } + if (object.undeleteRecognizerRequest != null) { + if (typeof object.undeleteRecognizerRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.undeleteRecognizerRequest: object expected"); + message.undeleteRecognizerRequest = $root.google.cloud.speech.v2.UndeleteRecognizerRequest.fromObject(object.undeleteRecognizerRequest); + } + if (object.createCustomClassRequest != null) { + if (typeof object.createCustomClassRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.createCustomClassRequest: object expected"); + message.createCustomClassRequest = $root.google.cloud.speech.v2.CreateCustomClassRequest.fromObject(object.createCustomClassRequest); + } + if (object.updateCustomClassRequest != null) { + if (typeof object.updateCustomClassRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.updateCustomClassRequest: object expected"); + message.updateCustomClassRequest = $root.google.cloud.speech.v2.UpdateCustomClassRequest.fromObject(object.updateCustomClassRequest); + } + if (object.deleteCustomClassRequest != null) { + if (typeof object.deleteCustomClassRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.deleteCustomClassRequest: object expected"); + message.deleteCustomClassRequest = $root.google.cloud.speech.v2.DeleteCustomClassRequest.fromObject(object.deleteCustomClassRequest); + } + if (object.undeleteCustomClassRequest != null) { + if (typeof object.undeleteCustomClassRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.undeleteCustomClassRequest: object expected"); + message.undeleteCustomClassRequest = $root.google.cloud.speech.v2.UndeleteCustomClassRequest.fromObject(object.undeleteCustomClassRequest); + } + if (object.createPhraseSetRequest != null) { + if (typeof object.createPhraseSetRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.createPhraseSetRequest: object expected"); + message.createPhraseSetRequest = $root.google.cloud.speech.v2.CreatePhraseSetRequest.fromObject(object.createPhraseSetRequest); + } + if (object.updatePhraseSetRequest != null) { + if (typeof object.updatePhraseSetRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.updatePhraseSetRequest: object expected"); + message.updatePhraseSetRequest = $root.google.cloud.speech.v2.UpdatePhraseSetRequest.fromObject(object.updatePhraseSetRequest); + } + if (object.deletePhraseSetRequest != null) { + if (typeof object.deletePhraseSetRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.deletePhraseSetRequest: object expected"); + message.deletePhraseSetRequest = $root.google.cloud.speech.v2.DeletePhraseSetRequest.fromObject(object.deletePhraseSetRequest); + } + if (object.undeletePhraseSetRequest != null) { + if (typeof object.undeletePhraseSetRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.undeletePhraseSetRequest: object expected"); + message.undeletePhraseSetRequest = $root.google.cloud.speech.v2.UndeletePhraseSetRequest.fromObject(object.undeletePhraseSetRequest); + } + if (object.updateConfigRequest != null) { + if (typeof object.updateConfigRequest !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.updateConfigRequest: object expected"); + message.updateConfigRequest = $root.google.cloud.speech.v2.UpdateConfigRequest.fromObject(object.updateConfigRequest); + } + if (object.progressPercent != null) + message.progressPercent = object.progressPercent | 0; + if (object.batchRecognizeMetadata != null) { + if (typeof object.batchRecognizeMetadata !== "object") + throw TypeError(".google.cloud.speech.v2.OperationMetadata.batchRecognizeMetadata: object expected"); + message.batchRecognizeMetadata = $root.google.cloud.speech.v2.BatchRecognizeMetadata.fromObject(object.batchRecognizeMetadata); + } + return message; + }; + + /** + * Creates a plain object from an OperationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {google.cloud.speech.v2.OperationMetadata} message OperationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + object.resource = ""; + object.method = ""; + object.kmsKeyName = ""; + object.kmsKeyVersionName = ""; + object.progressPercent = 0; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.resource != null && message.hasOwnProperty("resource")) + object.resource = message.resource; + if (message.method != null && message.hasOwnProperty("method")) + object.method = message.method; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + object.kmsKeyVersionName = message.kmsKeyVersionName; + if (message.batchRecognizeRequest != null && message.hasOwnProperty("batchRecognizeRequest")) { + object.batchRecognizeRequest = $root.google.cloud.speech.v2.BatchRecognizeRequest.toObject(message.batchRecognizeRequest, options); + if (options.oneofs) + object.request = "batchRecognizeRequest"; + } + if (message.createRecognizerRequest != null && message.hasOwnProperty("createRecognizerRequest")) { + object.createRecognizerRequest = $root.google.cloud.speech.v2.CreateRecognizerRequest.toObject(message.createRecognizerRequest, options); + if (options.oneofs) + object.request = "createRecognizerRequest"; + } + if (message.updateRecognizerRequest != null && message.hasOwnProperty("updateRecognizerRequest")) { + object.updateRecognizerRequest = $root.google.cloud.speech.v2.UpdateRecognizerRequest.toObject(message.updateRecognizerRequest, options); + if (options.oneofs) + object.request = "updateRecognizerRequest"; + } + if (message.deleteRecognizerRequest != null && message.hasOwnProperty("deleteRecognizerRequest")) { + object.deleteRecognizerRequest = $root.google.cloud.speech.v2.DeleteRecognizerRequest.toObject(message.deleteRecognizerRequest, options); + if (options.oneofs) + object.request = "deleteRecognizerRequest"; + } + if (message.undeleteRecognizerRequest != null && message.hasOwnProperty("undeleteRecognizerRequest")) { + object.undeleteRecognizerRequest = $root.google.cloud.speech.v2.UndeleteRecognizerRequest.toObject(message.undeleteRecognizerRequest, options); + if (options.oneofs) + object.request = "undeleteRecognizerRequest"; + } + if (message.createCustomClassRequest != null && message.hasOwnProperty("createCustomClassRequest")) { + object.createCustomClassRequest = $root.google.cloud.speech.v2.CreateCustomClassRequest.toObject(message.createCustomClassRequest, options); + if (options.oneofs) + object.request = "createCustomClassRequest"; + } + if (message.updateCustomClassRequest != null && message.hasOwnProperty("updateCustomClassRequest")) { + object.updateCustomClassRequest = $root.google.cloud.speech.v2.UpdateCustomClassRequest.toObject(message.updateCustomClassRequest, options); + if (options.oneofs) + object.request = "updateCustomClassRequest"; + } + if (message.deleteCustomClassRequest != null && message.hasOwnProperty("deleteCustomClassRequest")) { + object.deleteCustomClassRequest = $root.google.cloud.speech.v2.DeleteCustomClassRequest.toObject(message.deleteCustomClassRequest, options); + if (options.oneofs) + object.request = "deleteCustomClassRequest"; + } + if (message.undeleteCustomClassRequest != null && message.hasOwnProperty("undeleteCustomClassRequest")) { + object.undeleteCustomClassRequest = $root.google.cloud.speech.v2.UndeleteCustomClassRequest.toObject(message.undeleteCustomClassRequest, options); + if (options.oneofs) + object.request = "undeleteCustomClassRequest"; + } + if (message.createPhraseSetRequest != null && message.hasOwnProperty("createPhraseSetRequest")) { + object.createPhraseSetRequest = $root.google.cloud.speech.v2.CreatePhraseSetRequest.toObject(message.createPhraseSetRequest, options); + if (options.oneofs) + object.request = "createPhraseSetRequest"; + } + if (message.updatePhraseSetRequest != null && message.hasOwnProperty("updatePhraseSetRequest")) { + object.updatePhraseSetRequest = $root.google.cloud.speech.v2.UpdatePhraseSetRequest.toObject(message.updatePhraseSetRequest, options); + if (options.oneofs) + object.request = "updatePhraseSetRequest"; + } + if (message.deletePhraseSetRequest != null && message.hasOwnProperty("deletePhraseSetRequest")) { + object.deletePhraseSetRequest = $root.google.cloud.speech.v2.DeletePhraseSetRequest.toObject(message.deletePhraseSetRequest, options); + if (options.oneofs) + object.request = "deletePhraseSetRequest"; + } + if (message.undeletePhraseSetRequest != null && message.hasOwnProperty("undeletePhraseSetRequest")) { + object.undeletePhraseSetRequest = $root.google.cloud.speech.v2.UndeletePhraseSetRequest.toObject(message.undeletePhraseSetRequest, options); + if (options.oneofs) + object.request = "undeletePhraseSetRequest"; + } + if (message.updateConfigRequest != null && message.hasOwnProperty("updateConfigRequest")) { + object.updateConfigRequest = $root.google.cloud.speech.v2.UpdateConfigRequest.toObject(message.updateConfigRequest, options); + if (options.oneofs) + object.request = "updateConfigRequest"; + } + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + object.progressPercent = message.progressPercent; + if (message.batchRecognizeMetadata != null && message.hasOwnProperty("batchRecognizeMetadata")) { + object.batchRecognizeMetadata = $root.google.cloud.speech.v2.BatchRecognizeMetadata.toObject(message.batchRecognizeMetadata, options); + if (options.oneofs) + object.metadata = "batchRecognizeMetadata"; + } + return object; + }; + + /** + * Converts this OperationMetadata to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.OperationMetadata + * @instance + * @returns {Object.} JSON object + */ + OperationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OperationMetadata + * @function getTypeUrl + * @memberof google.cloud.speech.v2.OperationMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OperationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.OperationMetadata"; + }; + + return OperationMetadata; + })(); + + v2.ListRecognizersRequest = (function() { + + /** + * Properties of a ListRecognizersRequest. + * @memberof google.cloud.speech.v2 + * @interface IListRecognizersRequest + * @property {string|null} [parent] ListRecognizersRequest parent + * @property {number|null} [pageSize] ListRecognizersRequest pageSize + * @property {string|null} [pageToken] ListRecognizersRequest pageToken + * @property {boolean|null} [showDeleted] ListRecognizersRequest showDeleted + */ + + /** + * Constructs a new ListRecognizersRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListRecognizersRequest. + * @implements IListRecognizersRequest + * @constructor + * @param {google.cloud.speech.v2.IListRecognizersRequest=} [properties] Properties to set + */ + function ListRecognizersRequest(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]]; + } + + /** + * ListRecognizersRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @instance + */ + ListRecognizersRequest.prototype.parent = ""; + + /** + * ListRecognizersRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @instance + */ + ListRecognizersRequest.prototype.pageSize = 0; + + /** + * ListRecognizersRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @instance + */ + ListRecognizersRequest.prototype.pageToken = ""; + + /** + * ListRecognizersRequest showDeleted. + * @member {boolean} showDeleted + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @instance + */ + ListRecognizersRequest.prototype.showDeleted = false; + + /** + * Creates a new ListRecognizersRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {google.cloud.speech.v2.IListRecognizersRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListRecognizersRequest} ListRecognizersRequest instance + */ + ListRecognizersRequest.create = function create(properties) { + return new ListRecognizersRequest(properties); + }; + + /** + * Encodes the specified ListRecognizersRequest message. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {google.cloud.speech.v2.IListRecognizersRequest} message ListRecognizersRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListRecognizersRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.showDeleted != null && Object.hasOwnProperty.call(message, "showDeleted")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.showDeleted); + return writer; + }; + + /** + * Encodes the specified ListRecognizersRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {google.cloud.speech.v2.IListRecognizersRequest} message ListRecognizersRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListRecognizersRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListRecognizersRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListRecognizersRequest} ListRecognizersRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListRecognizersRequest.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.v2.ListRecognizersRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.showDeleted = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListRecognizersRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListRecognizersRequest} ListRecognizersRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListRecognizersRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListRecognizersRequest message. + * @function verify + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListRecognizersRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + if (typeof message.showDeleted !== "boolean") + return "showDeleted: boolean expected"; + return null; + }; + + /** + * Creates a ListRecognizersRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListRecognizersRequest} ListRecognizersRequest + */ + ListRecognizersRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListRecognizersRequest) + return object; + var message = new $root.google.cloud.speech.v2.ListRecognizersRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.showDeleted != null) + message.showDeleted = Boolean(object.showDeleted); + return message; + }; + + /** + * Creates a plain object from a ListRecognizersRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {google.cloud.speech.v2.ListRecognizersRequest} message ListRecognizersRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListRecognizersRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.showDeleted = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + object.showDeleted = message.showDeleted; + return object; + }; + + /** + * Converts this ListRecognizersRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @instance + * @returns {Object.} JSON object + */ + ListRecognizersRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListRecognizersRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListRecognizersRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListRecognizersRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListRecognizersRequest"; + }; + + return ListRecognizersRequest; + })(); + + v2.ListRecognizersResponse = (function() { + + /** + * Properties of a ListRecognizersResponse. + * @memberof google.cloud.speech.v2 + * @interface IListRecognizersResponse + * @property {Array.|null} [recognizers] ListRecognizersResponse recognizers + * @property {string|null} [nextPageToken] ListRecognizersResponse nextPageToken + */ + + /** + * Constructs a new ListRecognizersResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListRecognizersResponse. + * @implements IListRecognizersResponse + * @constructor + * @param {google.cloud.speech.v2.IListRecognizersResponse=} [properties] Properties to set + */ + function ListRecognizersResponse(properties) { + this.recognizers = []; + 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]]; + } + + /** + * ListRecognizersResponse recognizers. + * @member {Array.} recognizers + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @instance + */ + ListRecognizersResponse.prototype.recognizers = $util.emptyArray; + + /** + * ListRecognizersResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @instance + */ + ListRecognizersResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListRecognizersResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {google.cloud.speech.v2.IListRecognizersResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListRecognizersResponse} ListRecognizersResponse instance + */ + ListRecognizersResponse.create = function create(properties) { + return new ListRecognizersResponse(properties); + }; + + /** + * Encodes the specified ListRecognizersResponse message. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {google.cloud.speech.v2.IListRecognizersResponse} message ListRecognizersResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListRecognizersResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recognizers != null && message.recognizers.length) + for (var i = 0; i < message.recognizers.length; ++i) + $root.google.cloud.speech.v2.Recognizer.encode(message.recognizers[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListRecognizersResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListRecognizersResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {google.cloud.speech.v2.IListRecognizersResponse} message ListRecognizersResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListRecognizersResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListRecognizersResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListRecognizersResponse} ListRecognizersResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListRecognizersResponse.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.v2.ListRecognizersResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.recognizers && message.recognizers.length)) + message.recognizers = []; + message.recognizers.push($root.google.cloud.speech.v2.Recognizer.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListRecognizersResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListRecognizersResponse} ListRecognizersResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListRecognizersResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListRecognizersResponse message. + * @function verify + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListRecognizersResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recognizers != null && message.hasOwnProperty("recognizers")) { + if (!Array.isArray(message.recognizers)) + return "recognizers: array expected"; + for (var i = 0; i < message.recognizers.length; ++i) { + var error = $root.google.cloud.speech.v2.Recognizer.verify(message.recognizers[i]); + if (error) + return "recognizers." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListRecognizersResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListRecognizersResponse} ListRecognizersResponse + */ + ListRecognizersResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListRecognizersResponse) + return object; + var message = new $root.google.cloud.speech.v2.ListRecognizersResponse(); + if (object.recognizers) { + if (!Array.isArray(object.recognizers)) + throw TypeError(".google.cloud.speech.v2.ListRecognizersResponse.recognizers: array expected"); + message.recognizers = []; + for (var i = 0; i < object.recognizers.length; ++i) { + if (typeof object.recognizers[i] !== "object") + throw TypeError(".google.cloud.speech.v2.ListRecognizersResponse.recognizers: object expected"); + message.recognizers[i] = $root.google.cloud.speech.v2.Recognizer.fromObject(object.recognizers[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListRecognizersResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {google.cloud.speech.v2.ListRecognizersResponse} message ListRecognizersResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListRecognizersResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.recognizers = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.recognizers && message.recognizers.length) { + object.recognizers = []; + for (var j = 0; j < message.recognizers.length; ++j) + object.recognizers[j] = $root.google.cloud.speech.v2.Recognizer.toObject(message.recognizers[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListRecognizersResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @instance + * @returns {Object.} JSON object + */ + ListRecognizersResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListRecognizersResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListRecognizersResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListRecognizersResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListRecognizersResponse"; + }; + + return ListRecognizersResponse; + })(); + + v2.GetRecognizerRequest = (function() { + + /** + * Properties of a GetRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @interface IGetRecognizerRequest + * @property {string|null} [name] GetRecognizerRequest name + */ + + /** + * Constructs a new GetRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a GetRecognizerRequest. + * @implements IGetRecognizerRequest + * @constructor + * @param {google.cloud.speech.v2.IGetRecognizerRequest=} [properties] Properties to set + */ + function GetRecognizerRequest(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]]; + } + + /** + * GetRecognizerRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @instance + */ + GetRecognizerRequest.prototype.name = ""; + + /** + * Creates a new GetRecognizerRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IGetRecognizerRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.GetRecognizerRequest} GetRecognizerRequest instance + */ + GetRecognizerRequest.create = function create(properties) { + return new GetRecognizerRequest(properties); + }; + + /** + * Encodes the specified GetRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.GetRecognizerRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IGetRecognizerRequest} message GetRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetRecognizerRequest.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); + return writer; + }; + + /** + * Encodes the specified GetRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetRecognizerRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IGetRecognizerRequest} message GetRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetRecognizerRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetRecognizerRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.GetRecognizerRequest} GetRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetRecognizerRequest.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.v2.GetRecognizerRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetRecognizerRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.GetRecognizerRequest} GetRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetRecognizerRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetRecognizerRequest message. + * @function verify + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetRecognizerRequest.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"; + return null; + }; + + /** + * Creates a GetRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.GetRecognizerRequest} GetRecognizerRequest + */ + GetRecognizerRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.GetRecognizerRequest) + return object; + var message = new $root.google.cloud.speech.v2.GetRecognizerRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetRecognizerRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {google.cloud.speech.v2.GetRecognizerRequest} message GetRecognizerRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetRecognizerRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetRecognizerRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @instance + * @returns {Object.} JSON object + */ + GetRecognizerRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetRecognizerRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.GetRecognizerRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetRecognizerRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.GetRecognizerRequest"; + }; + + return GetRecognizerRequest; + })(); + + v2.UpdateRecognizerRequest = (function() { + + /** + * Properties of an UpdateRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @interface IUpdateRecognizerRequest + * @property {google.cloud.speech.v2.IRecognizer|null} [recognizer] UpdateRecognizerRequest recognizer + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateRecognizerRequest updateMask + * @property {boolean|null} [validateOnly] UpdateRecognizerRequest validateOnly + */ + + /** + * Constructs a new UpdateRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UpdateRecognizerRequest. + * @implements IUpdateRecognizerRequest + * @constructor + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest=} [properties] Properties to set + */ + function UpdateRecognizerRequest(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]]; + } + + /** + * UpdateRecognizerRequest recognizer. + * @member {google.cloud.speech.v2.IRecognizer|null|undefined} recognizer + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @instance + */ + UpdateRecognizerRequest.prototype.recognizer = null; + + /** + * UpdateRecognizerRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @instance + */ + UpdateRecognizerRequest.prototype.updateMask = null; + + /** + * UpdateRecognizerRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @instance + */ + UpdateRecognizerRequest.prototype.validateOnly = false; + + /** + * Creates a new UpdateRecognizerRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UpdateRecognizerRequest} UpdateRecognizerRequest instance + */ + UpdateRecognizerRequest.create = function create(properties) { + return new UpdateRecognizerRequest(properties); + }; + + /** + * Encodes the specified UpdateRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateRecognizerRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest} message UpdateRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateRecognizerRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recognizer != null && Object.hasOwnProperty.call(message, "recognizer")) + $root.google.cloud.speech.v2.Recognizer.encode(message.recognizer, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified UpdateRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateRecognizerRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUpdateRecognizerRequest} message UpdateRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateRecognizerRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateRecognizerRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UpdateRecognizerRequest} UpdateRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateRecognizerRequest.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.v2.UpdateRecognizerRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recognizer = $root.google.cloud.speech.v2.Recognizer.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateRecognizerRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UpdateRecognizerRequest} UpdateRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateRecognizerRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateRecognizerRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateRecognizerRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) { + var error = $root.google.cloud.speech.v2.Recognizer.verify(message.recognizer); + if (error) + return "recognizer." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates an UpdateRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UpdateRecognizerRequest} UpdateRecognizerRequest + */ + UpdateRecognizerRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UpdateRecognizerRequest) + return object; + var message = new $root.google.cloud.speech.v2.UpdateRecognizerRequest(); + if (object.recognizer != null) { + if (typeof object.recognizer !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateRecognizerRequest.recognizer: object expected"); + message.recognizer = $root.google.cloud.speech.v2.Recognizer.fromObject(object.recognizer); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateRecognizerRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from an UpdateRecognizerRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {google.cloud.speech.v2.UpdateRecognizerRequest} message UpdateRecognizerRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateRecognizerRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.recognizer = null; + object.updateMask = null; + object.validateOnly = false; + } + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + object.recognizer = $root.google.cloud.speech.v2.Recognizer.toObject(message.recognizer, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this UpdateRecognizerRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateRecognizerRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateRecognizerRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UpdateRecognizerRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateRecognizerRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UpdateRecognizerRequest"; + }; + + return UpdateRecognizerRequest; + })(); + + v2.DeleteRecognizerRequest = (function() { + + /** + * Properties of a DeleteRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @interface IDeleteRecognizerRequest + * @property {string|null} [name] DeleteRecognizerRequest name + * @property {boolean|null} [validateOnly] DeleteRecognizerRequest validateOnly + * @property {boolean|null} [allowMissing] DeleteRecognizerRequest allowMissing + * @property {string|null} [etag] DeleteRecognizerRequest etag + */ + + /** + * Constructs a new DeleteRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a DeleteRecognizerRequest. + * @implements IDeleteRecognizerRequest + * @constructor + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest=} [properties] Properties to set + */ + function DeleteRecognizerRequest(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]]; + } + + /** + * DeleteRecognizerRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @instance + */ + DeleteRecognizerRequest.prototype.name = ""; + + /** + * DeleteRecognizerRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @instance + */ + DeleteRecognizerRequest.prototype.validateOnly = false; + + /** + * DeleteRecognizerRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @instance + */ + DeleteRecognizerRequest.prototype.allowMissing = false; + + /** + * DeleteRecognizerRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @instance + */ + DeleteRecognizerRequest.prototype.etag = ""; + + /** + * Creates a new DeleteRecognizerRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.DeleteRecognizerRequest} DeleteRecognizerRequest instance + */ + DeleteRecognizerRequest.create = function create(properties) { + return new DeleteRecognizerRequest(properties); + }; + + /** + * Encodes the specified DeleteRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.DeleteRecognizerRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest} message DeleteRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteRecognizerRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified DeleteRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeleteRecognizerRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IDeleteRecognizerRequest} message DeleteRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteRecognizerRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteRecognizerRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.DeleteRecognizerRequest} DeleteRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteRecognizerRequest.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.v2.DeleteRecognizerRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteRecognizerRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.DeleteRecognizerRequest} DeleteRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteRecognizerRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteRecognizerRequest message. + * @function verify + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteRecognizerRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a DeleteRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.DeleteRecognizerRequest} DeleteRecognizerRequest + */ + DeleteRecognizerRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.DeleteRecognizerRequest) + return object; + var message = new $root.google.cloud.speech.v2.DeleteRecognizerRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a DeleteRecognizerRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.DeleteRecognizerRequest} message DeleteRecognizerRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteRecognizerRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + object.allowMissing = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this DeleteRecognizerRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteRecognizerRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteRecognizerRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.DeleteRecognizerRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteRecognizerRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.DeleteRecognizerRequest"; + }; + + return DeleteRecognizerRequest; + })(); + + v2.UndeleteRecognizerRequest = (function() { + + /** + * Properties of an UndeleteRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @interface IUndeleteRecognizerRequest + * @property {string|null} [name] UndeleteRecognizerRequest name + * @property {boolean|null} [validateOnly] UndeleteRecognizerRequest validateOnly + * @property {string|null} [etag] UndeleteRecognizerRequest etag + */ + + /** + * Constructs a new UndeleteRecognizerRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UndeleteRecognizerRequest. + * @implements IUndeleteRecognizerRequest + * @constructor + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest=} [properties] Properties to set + */ + function UndeleteRecognizerRequest(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]]; + } + + /** + * UndeleteRecognizerRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @instance + */ + UndeleteRecognizerRequest.prototype.name = ""; + + /** + * UndeleteRecognizerRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @instance + */ + UndeleteRecognizerRequest.prototype.validateOnly = false; + + /** + * UndeleteRecognizerRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @instance + */ + UndeleteRecognizerRequest.prototype.etag = ""; + + /** + * Creates a new UndeleteRecognizerRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UndeleteRecognizerRequest} UndeleteRecognizerRequest instance + */ + UndeleteRecognizerRequest.create = function create(properties) { + return new UndeleteRecognizerRequest(properties); + }; + + /** + * Encodes the specified UndeleteRecognizerRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeleteRecognizerRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest} message UndeleteRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeleteRecognizerRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.etag); + return writer; + }; + + /** + * Encodes the specified UndeleteRecognizerRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeleteRecognizerRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteRecognizerRequest} message UndeleteRecognizerRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeleteRecognizerRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UndeleteRecognizerRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UndeleteRecognizerRequest} UndeleteRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeleteRecognizerRequest.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.v2.UndeleteRecognizerRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UndeleteRecognizerRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UndeleteRecognizerRequest} UndeleteRecognizerRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeleteRecognizerRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UndeleteRecognizerRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UndeleteRecognizerRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates an UndeleteRecognizerRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UndeleteRecognizerRequest} UndeleteRecognizerRequest + */ + UndeleteRecognizerRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UndeleteRecognizerRequest) + return object; + var message = new $root.google.cloud.speech.v2.UndeleteRecognizerRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from an UndeleteRecognizerRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {google.cloud.speech.v2.UndeleteRecognizerRequest} message UndeleteRecognizerRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UndeleteRecognizerRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this UndeleteRecognizerRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @instance + * @returns {Object.} JSON object + */ + UndeleteRecognizerRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UndeleteRecognizerRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UndeleteRecognizerRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UndeleteRecognizerRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UndeleteRecognizerRequest"; + }; + + return UndeleteRecognizerRequest; + })(); + + v2.Recognizer = (function() { + + /** + * Properties of a Recognizer. + * @memberof google.cloud.speech.v2 + * @interface IRecognizer + * @property {string|null} [name] Recognizer name + * @property {string|null} [uid] Recognizer uid + * @property {string|null} [displayName] Recognizer displayName + * @property {string|null} [model] Recognizer model + * @property {Array.|null} [languageCodes] Recognizer languageCodes + * @property {google.cloud.speech.v2.IRecognitionConfig|null} [defaultRecognitionConfig] Recognizer defaultRecognitionConfig + * @property {Object.|null} [annotations] Recognizer annotations + * @property {google.cloud.speech.v2.Recognizer.State|null} [state] Recognizer state + * @property {google.protobuf.ITimestamp|null} [createTime] Recognizer createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Recognizer updateTime + * @property {google.protobuf.ITimestamp|null} [deleteTime] Recognizer deleteTime + * @property {google.protobuf.ITimestamp|null} [expireTime] Recognizer expireTime + * @property {string|null} [etag] Recognizer etag + * @property {boolean|null} [reconciling] Recognizer reconciling + * @property {string|null} [kmsKeyName] Recognizer kmsKeyName + * @property {string|null} [kmsKeyVersionName] Recognizer kmsKeyVersionName + */ + + /** + * Constructs a new Recognizer. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a Recognizer. + * @implements IRecognizer + * @constructor + * @param {google.cloud.speech.v2.IRecognizer=} [properties] Properties to set + */ + function Recognizer(properties) { + this.languageCodes = []; + this.annotations = {}; + 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]]; + } + + /** + * Recognizer name. + * @member {string} name + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.name = ""; + + /** + * Recognizer uid. + * @member {string} uid + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.uid = ""; + + /** + * Recognizer displayName. + * @member {string} displayName + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.displayName = ""; + + /** + * Recognizer model. + * @member {string} model + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.model = ""; + + /** + * Recognizer languageCodes. + * @member {Array.} languageCodes + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.languageCodes = $util.emptyArray; + + /** + * Recognizer defaultRecognitionConfig. + * @member {google.cloud.speech.v2.IRecognitionConfig|null|undefined} defaultRecognitionConfig + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.defaultRecognitionConfig = null; + + /** + * Recognizer annotations. + * @member {Object.} annotations + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.annotations = $util.emptyObject; + + /** + * Recognizer state. + * @member {google.cloud.speech.v2.Recognizer.State} state + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.state = 0; + + /** + * Recognizer createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.createTime = null; + + /** + * Recognizer updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.updateTime = null; + + /** + * Recognizer deleteTime. + * @member {google.protobuf.ITimestamp|null|undefined} deleteTime + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.deleteTime = null; + + /** + * Recognizer expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.expireTime = null; + + /** + * Recognizer etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.etag = ""; + + /** + * Recognizer reconciling. + * @member {boolean} reconciling + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.reconciling = false; + + /** + * Recognizer kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.kmsKeyName = ""; + + /** + * Recognizer kmsKeyVersionName. + * @member {string} kmsKeyVersionName + * @memberof google.cloud.speech.v2.Recognizer + * @instance + */ + Recognizer.prototype.kmsKeyVersionName = ""; + + /** + * Creates a new Recognizer instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {google.cloud.speech.v2.IRecognizer=} [properties] Properties to set + * @returns {google.cloud.speech.v2.Recognizer} Recognizer instance + */ + Recognizer.create = function create(properties) { + return new Recognizer(properties); + }; + + /** + * Encodes the specified Recognizer message. Does not implicitly {@link google.cloud.speech.v2.Recognizer.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {google.cloud.speech.v2.IRecognizer} message Recognizer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Recognizer.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.uid != null && Object.hasOwnProperty.call(message, "uid")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.uid); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.displayName); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.model); + if (message.defaultRecognitionConfig != null && Object.hasOwnProperty.call(message, "defaultRecognitionConfig")) + $root.google.cloud.speech.v2.RecognitionConfig.encode(message.defaultRecognitionConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.annotations != null && Object.hasOwnProperty.call(message, "annotations")) + for (var keys = Object.keys(message.annotations), i = 0; i < keys.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.annotations[keys[i]]).ldelim(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.state); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.deleteTime != null && Object.hasOwnProperty.call(message, "deleteTime")) + $root.google.protobuf.Timestamp.encode(message.deleteTime, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.etag); + if (message.reconciling != null && Object.hasOwnProperty.call(message, "reconciling")) + writer.uint32(/* id 13, wireType 0 =*/104).bool(message.reconciling); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.kmsKeyName); + if (message.kmsKeyVersionName != null && Object.hasOwnProperty.call(message, "kmsKeyVersionName")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.kmsKeyVersionName); + if (message.languageCodes != null && message.languageCodes.length) + for (var i = 0; i < message.languageCodes.length; ++i) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.languageCodes[i]); + return writer; + }; + + /** + * Encodes the specified Recognizer message, length delimited. Does not implicitly {@link google.cloud.speech.v2.Recognizer.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {google.cloud.speech.v2.IRecognizer} message Recognizer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Recognizer.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Recognizer message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.Recognizer} Recognizer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Recognizer.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.v2.Recognizer(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.uid = reader.string(); + break; + } + case 3: { + message.displayName = reader.string(); + break; + } + case 4: { + message.model = reader.string(); + break; + } + case 17: { + if (!(message.languageCodes && message.languageCodes.length)) + message.languageCodes = []; + message.languageCodes.push(reader.string()); + break; + } + case 6: { + message.defaultRecognitionConfig = $root.google.cloud.speech.v2.RecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 7: { + if (message.annotations === $util.emptyObject) + message.annotations = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.annotations[key] = value; + break; + } + case 8: { + message.state = reader.int32(); + break; + } + case 9: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 11: { + message.deleteTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 14: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 12: { + message.etag = reader.string(); + break; + } + case 13: { + message.reconciling = reader.bool(); + break; + } + case 15: { + message.kmsKeyName = reader.string(); + break; + } + case 16: { + message.kmsKeyVersionName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Recognizer message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.Recognizer} Recognizer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Recognizer.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Recognizer message. + * @function verify + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Recognizer.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.uid != null && message.hasOwnProperty("uid")) + if (!$util.isString(message.uid)) + return "uid: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + if (message.languageCodes != null && message.hasOwnProperty("languageCodes")) { + if (!Array.isArray(message.languageCodes)) + return "languageCodes: array expected"; + for (var i = 0; i < message.languageCodes.length; ++i) + if (!$util.isString(message.languageCodes[i])) + return "languageCodes: string[] expected"; + } + if (message.defaultRecognitionConfig != null && message.hasOwnProperty("defaultRecognitionConfig")) { + var error = $root.google.cloud.speech.v2.RecognitionConfig.verify(message.defaultRecognitionConfig); + if (error) + return "defaultRecognitionConfig." + error; + } + if (message.annotations != null && message.hasOwnProperty("annotations")) { + if (!$util.isObject(message.annotations)) + return "annotations: object expected"; + var key = Object.keys(message.annotations); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.annotations[key[i]])) + return "annotations: string{k:string} expected"; + } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 2: + case 4: + break; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.deleteTime); + if (error) + return "deleteTime." + error; + } + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + if (typeof message.reconciling !== "boolean") + return "reconciling: boolean expected"; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + if (!$util.isString(message.kmsKeyVersionName)) + return "kmsKeyVersionName: string expected"; + return null; + }; + + /** + * Creates a Recognizer message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.Recognizer} Recognizer + */ + Recognizer.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.Recognizer) + return object; + var message = new $root.google.cloud.speech.v2.Recognizer(); + if (object.name != null) + message.name = String(object.name); + if (object.uid != null) + message.uid = String(object.uid); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.model != null) + message.model = String(object.model); + if (object.languageCodes) { + if (!Array.isArray(object.languageCodes)) + throw TypeError(".google.cloud.speech.v2.Recognizer.languageCodes: array expected"); + message.languageCodes = []; + for (var i = 0; i < object.languageCodes.length; ++i) + message.languageCodes[i] = String(object.languageCodes[i]); + } + if (object.defaultRecognitionConfig != null) { + if (typeof object.defaultRecognitionConfig !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.defaultRecognitionConfig: object expected"); + message.defaultRecognitionConfig = $root.google.cloud.speech.v2.RecognitionConfig.fromObject(object.defaultRecognitionConfig); + } + if (object.annotations) { + if (typeof object.annotations !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.annotations: object expected"); + message.annotations = {}; + for (var keys = Object.keys(object.annotations), i = 0; i < keys.length; ++i) + message.annotations[keys[i]] = String(object.annotations[keys[i]]); + } + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 2: + message.state = 2; + break; + case "DELETED": + case 4: + message.state = 4; + break; + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.deleteTime != null) { + if (typeof object.deleteTime !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.deleteTime: object expected"); + message.deleteTime = $root.google.protobuf.Timestamp.fromObject(object.deleteTime); + } + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.speech.v2.Recognizer.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.etag != null) + message.etag = String(object.etag); + if (object.reconciling != null) + message.reconciling = Boolean(object.reconciling); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.kmsKeyVersionName != null) + message.kmsKeyVersionName = String(object.kmsKeyVersionName); + return message; + }; + + /** + * Creates a plain object from a Recognizer message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {google.cloud.speech.v2.Recognizer} message Recognizer + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Recognizer.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languageCodes = []; + if (options.objects || options.defaults) + object.annotations = {}; + if (options.defaults) { + object.name = ""; + object.uid = ""; + object.displayName = ""; + object.model = ""; + object.defaultRecognitionConfig = null; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.createTime = null; + object.updateTime = null; + object.deleteTime = null; + object.etag = ""; + object.reconciling = false; + object.expireTime = null; + object.kmsKeyName = ""; + object.kmsKeyVersionName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.uid != null && message.hasOwnProperty("uid")) + object.uid = message.uid; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.defaultRecognitionConfig != null && message.hasOwnProperty("defaultRecognitionConfig")) + object.defaultRecognitionConfig = $root.google.cloud.speech.v2.RecognitionConfig.toObject(message.defaultRecognitionConfig, options); + var keys2; + if (message.annotations && (keys2 = Object.keys(message.annotations)).length) { + object.annotations = {}; + for (var j = 0; j < keys2.length; ++j) + object.annotations[keys2[j]] = message.annotations[keys2[j]]; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.speech.v2.Recognizer.State[message.state] : message.state; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) + object.deleteTime = $root.google.protobuf.Timestamp.toObject(message.deleteTime, options); + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + object.reconciling = message.reconciling; + if (message.expireTime != null && message.hasOwnProperty("expireTime")) + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + object.kmsKeyVersionName = message.kmsKeyVersionName; + if (message.languageCodes && message.languageCodes.length) { + object.languageCodes = []; + for (var j = 0; j < message.languageCodes.length; ++j) + object.languageCodes[j] = message.languageCodes[j]; + } + return object; + }; + + /** + * Converts this Recognizer to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.Recognizer + * @instance + * @returns {Object.} JSON object + */ + Recognizer.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Recognizer + * @function getTypeUrl + * @memberof google.cloud.speech.v2.Recognizer + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Recognizer.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.Recognizer"; + }; + + /** + * State enum. + * @name google.cloud.speech.v2.Recognizer.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=2 ACTIVE value + * @property {number} DELETED=4 DELETED value + */ + Recognizer.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[2] = "ACTIVE"] = 2; + values[valuesById[4] = "DELETED"] = 4; + return values; + })(); + + return Recognizer; + })(); + + v2.AutoDetectDecodingConfig = (function() { + + /** + * Properties of an AutoDetectDecodingConfig. + * @memberof google.cloud.speech.v2 + * @interface IAutoDetectDecodingConfig + */ + + /** + * Constructs a new AutoDetectDecodingConfig. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an AutoDetectDecodingConfig. + * @implements IAutoDetectDecodingConfig + * @constructor + * @param {google.cloud.speech.v2.IAutoDetectDecodingConfig=} [properties] Properties to set + */ + function AutoDetectDecodingConfig(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]]; + } + + /** + * Creates a new AutoDetectDecodingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {google.cloud.speech.v2.IAutoDetectDecodingConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.AutoDetectDecodingConfig} AutoDetectDecodingConfig instance + */ + AutoDetectDecodingConfig.create = function create(properties) { + return new AutoDetectDecodingConfig(properties); + }; + + /** + * Encodes the specified AutoDetectDecodingConfig message. Does not implicitly {@link google.cloud.speech.v2.AutoDetectDecodingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {google.cloud.speech.v2.IAutoDetectDecodingConfig} message AutoDetectDecodingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AutoDetectDecodingConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AutoDetectDecodingConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.AutoDetectDecodingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {google.cloud.speech.v2.IAutoDetectDecodingConfig} message AutoDetectDecodingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AutoDetectDecodingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AutoDetectDecodingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.AutoDetectDecodingConfig} AutoDetectDecodingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AutoDetectDecodingConfig.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.v2.AutoDetectDecodingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AutoDetectDecodingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.AutoDetectDecodingConfig} AutoDetectDecodingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AutoDetectDecodingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AutoDetectDecodingConfig message. + * @function verify + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AutoDetectDecodingConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AutoDetectDecodingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.AutoDetectDecodingConfig} AutoDetectDecodingConfig + */ + AutoDetectDecodingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.AutoDetectDecodingConfig) + return object; + return new $root.google.cloud.speech.v2.AutoDetectDecodingConfig(); + }; + + /** + * Creates a plain object from an AutoDetectDecodingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {google.cloud.speech.v2.AutoDetectDecodingConfig} message AutoDetectDecodingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AutoDetectDecodingConfig.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AutoDetectDecodingConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @instance + * @returns {Object.} JSON object + */ + AutoDetectDecodingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AutoDetectDecodingConfig + * @function getTypeUrl + * @memberof google.cloud.speech.v2.AutoDetectDecodingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AutoDetectDecodingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.AutoDetectDecodingConfig"; + }; + + return AutoDetectDecodingConfig; + })(); + + v2.ExplicitDecodingConfig = (function() { + + /** + * Properties of an ExplicitDecodingConfig. + * @memberof google.cloud.speech.v2 + * @interface IExplicitDecodingConfig + * @property {google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding|null} [encoding] ExplicitDecodingConfig encoding + * @property {number|null} [sampleRateHertz] ExplicitDecodingConfig sampleRateHertz + * @property {number|null} [audioChannelCount] ExplicitDecodingConfig audioChannelCount + */ + + /** + * Constructs a new ExplicitDecodingConfig. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an ExplicitDecodingConfig. + * @implements IExplicitDecodingConfig + * @constructor + * @param {google.cloud.speech.v2.IExplicitDecodingConfig=} [properties] Properties to set + */ + function ExplicitDecodingConfig(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]]; + } + + /** + * ExplicitDecodingConfig encoding. + * @member {google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding} encoding + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @instance + */ + ExplicitDecodingConfig.prototype.encoding = 0; + + /** + * ExplicitDecodingConfig sampleRateHertz. + * @member {number} sampleRateHertz + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @instance + */ + ExplicitDecodingConfig.prototype.sampleRateHertz = 0; + + /** + * ExplicitDecodingConfig audioChannelCount. + * @member {number} audioChannelCount + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @instance + */ + ExplicitDecodingConfig.prototype.audioChannelCount = 0; + + /** + * Creates a new ExplicitDecodingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {google.cloud.speech.v2.IExplicitDecodingConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ExplicitDecodingConfig} ExplicitDecodingConfig instance + */ + ExplicitDecodingConfig.create = function create(properties) { + return new ExplicitDecodingConfig(properties); + }; + + /** + * Encodes the specified ExplicitDecodingConfig message. Does not implicitly {@link google.cloud.speech.v2.ExplicitDecodingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {google.cloud.speech.v2.IExplicitDecodingConfig} message ExplicitDecodingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplicitDecodingConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.encoding != null && Object.hasOwnProperty.call(message, "encoding")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.encoding); + if (message.sampleRateHertz != null && Object.hasOwnProperty.call(message, "sampleRateHertz")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.sampleRateHertz); + if (message.audioChannelCount != null && Object.hasOwnProperty.call(message, "audioChannelCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.audioChannelCount); + return writer; + }; + + /** + * Encodes the specified ExplicitDecodingConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ExplicitDecodingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {google.cloud.speech.v2.IExplicitDecodingConfig} message ExplicitDecodingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplicitDecodingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExplicitDecodingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ExplicitDecodingConfig} ExplicitDecodingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplicitDecodingConfig.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.v2.ExplicitDecodingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.encoding = reader.int32(); + break; + } + case 2: { + message.sampleRateHertz = reader.int32(); + break; + } + case 3: { + message.audioChannelCount = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExplicitDecodingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ExplicitDecodingConfig} ExplicitDecodingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplicitDecodingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExplicitDecodingConfig message. + * @function verify + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExplicitDecodingConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.encoding != null && message.hasOwnProperty("encoding")) + switch (message.encoding) { + default: + return "encoding: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.sampleRateHertz != null && message.hasOwnProperty("sampleRateHertz")) + if (!$util.isInteger(message.sampleRateHertz)) + return "sampleRateHertz: integer expected"; + if (message.audioChannelCount != null && message.hasOwnProperty("audioChannelCount")) + if (!$util.isInteger(message.audioChannelCount)) + return "audioChannelCount: integer expected"; + return null; + }; + + /** + * Creates an ExplicitDecodingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ExplicitDecodingConfig} ExplicitDecodingConfig + */ + ExplicitDecodingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ExplicitDecodingConfig) + return object; + var message = new $root.google.cloud.speech.v2.ExplicitDecodingConfig(); + switch (object.encoding) { + case "AUDIO_ENCODING_UNSPECIFIED": + case 0: + message.encoding = 0; + break; + case "LINEAR16": + case 1: + message.encoding = 1; + break; + case "MULAW": + case 2: + message.encoding = 2; + break; + case "ALAW": + case 3: + message.encoding = 3; + break; + } + if (object.sampleRateHertz != null) + message.sampleRateHertz = object.sampleRateHertz | 0; + if (object.audioChannelCount != null) + message.audioChannelCount = object.audioChannelCount | 0; + return message; + }; + + /** + * Creates a plain object from an ExplicitDecodingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {google.cloud.speech.v2.ExplicitDecodingConfig} message ExplicitDecodingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExplicitDecodingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.encoding = options.enums === String ? "AUDIO_ENCODING_UNSPECIFIED" : 0; + object.sampleRateHertz = 0; + object.audioChannelCount = 0; + } + if (message.encoding != null && message.hasOwnProperty("encoding")) + object.encoding = options.enums === String ? $root.google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding[message.encoding] : message.encoding; + if (message.sampleRateHertz != null && message.hasOwnProperty("sampleRateHertz")) + object.sampleRateHertz = message.sampleRateHertz; + if (message.audioChannelCount != null && message.hasOwnProperty("audioChannelCount")) + object.audioChannelCount = message.audioChannelCount; + return object; + }; + + /** + * Converts this ExplicitDecodingConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @instance + * @returns {Object.} JSON object + */ + ExplicitDecodingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExplicitDecodingConfig + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ExplicitDecodingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExplicitDecodingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ExplicitDecodingConfig"; + }; + + /** + * AudioEncoding enum. + * @name google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding + * @enum {number} + * @property {number} AUDIO_ENCODING_UNSPECIFIED=0 AUDIO_ENCODING_UNSPECIFIED value + * @property {number} LINEAR16=1 LINEAR16 value + * @property {number} MULAW=2 MULAW value + * @property {number} ALAW=3 ALAW value + */ + ExplicitDecodingConfig.AudioEncoding = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "AUDIO_ENCODING_UNSPECIFIED"] = 0; + values[valuesById[1] = "LINEAR16"] = 1; + values[valuesById[2] = "MULAW"] = 2; + values[valuesById[3] = "ALAW"] = 3; + return values; + })(); + + return ExplicitDecodingConfig; + })(); + + v2.SpeakerDiarizationConfig = (function() { + + /** + * Properties of a SpeakerDiarizationConfig. + * @memberof google.cloud.speech.v2 + * @interface ISpeakerDiarizationConfig + * @property {number|null} [minSpeakerCount] SpeakerDiarizationConfig minSpeakerCount + * @property {number|null} [maxSpeakerCount] SpeakerDiarizationConfig maxSpeakerCount + */ + + /** + * Constructs a new SpeakerDiarizationConfig. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a SpeakerDiarizationConfig. + * @implements ISpeakerDiarizationConfig + * @constructor + * @param {google.cloud.speech.v2.ISpeakerDiarizationConfig=} [properties] Properties to set + */ + function SpeakerDiarizationConfig(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]]; + } + + /** + * SpeakerDiarizationConfig minSpeakerCount. + * @member {number} minSpeakerCount + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @instance + */ + SpeakerDiarizationConfig.prototype.minSpeakerCount = 0; + + /** + * SpeakerDiarizationConfig maxSpeakerCount. + * @member {number} maxSpeakerCount + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @instance + */ + SpeakerDiarizationConfig.prototype.maxSpeakerCount = 0; + + /** + * Creates a new SpeakerDiarizationConfig instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {google.cloud.speech.v2.ISpeakerDiarizationConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.SpeakerDiarizationConfig} SpeakerDiarizationConfig instance + */ + SpeakerDiarizationConfig.create = function create(properties) { + return new SpeakerDiarizationConfig(properties); + }; + + /** + * Encodes the specified SpeakerDiarizationConfig message. Does not implicitly {@link google.cloud.speech.v2.SpeakerDiarizationConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {google.cloud.speech.v2.ISpeakerDiarizationConfig} message SpeakerDiarizationConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeakerDiarizationConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.minSpeakerCount != null && Object.hasOwnProperty.call(message, "minSpeakerCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.minSpeakerCount); + if (message.maxSpeakerCount != null && Object.hasOwnProperty.call(message, "maxSpeakerCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.maxSpeakerCount); + return writer; + }; + + /** + * Encodes the specified SpeakerDiarizationConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeakerDiarizationConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {google.cloud.speech.v2.ISpeakerDiarizationConfig} message SpeakerDiarizationConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeakerDiarizationConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeakerDiarizationConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.SpeakerDiarizationConfig} SpeakerDiarizationConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeakerDiarizationConfig.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.v2.SpeakerDiarizationConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.minSpeakerCount = reader.int32(); + break; + } + case 3: { + message.maxSpeakerCount = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeakerDiarizationConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.SpeakerDiarizationConfig} SpeakerDiarizationConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeakerDiarizationConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeakerDiarizationConfig message. + * @function verify + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeakerDiarizationConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.minSpeakerCount != null && message.hasOwnProperty("minSpeakerCount")) + if (!$util.isInteger(message.minSpeakerCount)) + return "minSpeakerCount: integer expected"; + if (message.maxSpeakerCount != null && message.hasOwnProperty("maxSpeakerCount")) + if (!$util.isInteger(message.maxSpeakerCount)) + return "maxSpeakerCount: integer expected"; + return null; + }; + + /** + * Creates a SpeakerDiarizationConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.SpeakerDiarizationConfig} SpeakerDiarizationConfig + */ + SpeakerDiarizationConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.SpeakerDiarizationConfig) + return object; + var message = new $root.google.cloud.speech.v2.SpeakerDiarizationConfig(); + if (object.minSpeakerCount != null) + message.minSpeakerCount = object.minSpeakerCount | 0; + if (object.maxSpeakerCount != null) + message.maxSpeakerCount = object.maxSpeakerCount | 0; + return message; + }; + + /** + * Creates a plain object from a SpeakerDiarizationConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {google.cloud.speech.v2.SpeakerDiarizationConfig} message SpeakerDiarizationConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeakerDiarizationConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.minSpeakerCount = 0; + object.maxSpeakerCount = 0; + } + if (message.minSpeakerCount != null && message.hasOwnProperty("minSpeakerCount")) + object.minSpeakerCount = message.minSpeakerCount; + if (message.maxSpeakerCount != null && message.hasOwnProperty("maxSpeakerCount")) + object.maxSpeakerCount = message.maxSpeakerCount; + return object; + }; + + /** + * Converts this SpeakerDiarizationConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @instance + * @returns {Object.} JSON object + */ + SpeakerDiarizationConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeakerDiarizationConfig + * @function getTypeUrl + * @memberof google.cloud.speech.v2.SpeakerDiarizationConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeakerDiarizationConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.SpeakerDiarizationConfig"; + }; + + return SpeakerDiarizationConfig; + })(); + + v2.RecognitionFeatures = (function() { + + /** + * Properties of a RecognitionFeatures. + * @memberof google.cloud.speech.v2 + * @interface IRecognitionFeatures + * @property {boolean|null} [profanityFilter] RecognitionFeatures profanityFilter + * @property {boolean|null} [enableWordTimeOffsets] RecognitionFeatures enableWordTimeOffsets + * @property {boolean|null} [enableWordConfidence] RecognitionFeatures enableWordConfidence + * @property {boolean|null} [enableAutomaticPunctuation] RecognitionFeatures enableAutomaticPunctuation + * @property {boolean|null} [enableSpokenPunctuation] RecognitionFeatures enableSpokenPunctuation + * @property {boolean|null} [enableSpokenEmojis] RecognitionFeatures enableSpokenEmojis + * @property {google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode|null} [multiChannelMode] RecognitionFeatures multiChannelMode + * @property {google.cloud.speech.v2.ISpeakerDiarizationConfig|null} [diarizationConfig] RecognitionFeatures diarizationConfig + * @property {number|null} [maxAlternatives] RecognitionFeatures maxAlternatives + */ + + /** + * Constructs a new RecognitionFeatures. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a RecognitionFeatures. + * @implements IRecognitionFeatures + * @constructor + * @param {google.cloud.speech.v2.IRecognitionFeatures=} [properties] Properties to set + */ + function RecognitionFeatures(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]]; + } + + /** + * RecognitionFeatures profanityFilter. + * @member {boolean} profanityFilter + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.profanityFilter = false; + + /** + * RecognitionFeatures enableWordTimeOffsets. + * @member {boolean} enableWordTimeOffsets + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.enableWordTimeOffsets = false; + + /** + * RecognitionFeatures enableWordConfidence. + * @member {boolean} enableWordConfidence + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.enableWordConfidence = false; + + /** + * RecognitionFeatures enableAutomaticPunctuation. + * @member {boolean} enableAutomaticPunctuation + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.enableAutomaticPunctuation = false; + + /** + * RecognitionFeatures enableSpokenPunctuation. + * @member {boolean} enableSpokenPunctuation + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.enableSpokenPunctuation = false; + + /** + * RecognitionFeatures enableSpokenEmojis. + * @member {boolean} enableSpokenEmojis + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.enableSpokenEmojis = false; + + /** + * RecognitionFeatures multiChannelMode. + * @member {google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode} multiChannelMode + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.multiChannelMode = 0; + + /** + * RecognitionFeatures diarizationConfig. + * @member {google.cloud.speech.v2.ISpeakerDiarizationConfig|null|undefined} diarizationConfig + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.diarizationConfig = null; + + /** + * RecognitionFeatures maxAlternatives. + * @member {number} maxAlternatives + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + */ + RecognitionFeatures.prototype.maxAlternatives = 0; + + /** + * Creates a new RecognitionFeatures instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IRecognitionFeatures=} [properties] Properties to set + * @returns {google.cloud.speech.v2.RecognitionFeatures} RecognitionFeatures instance + */ + RecognitionFeatures.create = function create(properties) { + return new RecognitionFeatures(properties); + }; + + /** + * Encodes the specified RecognitionFeatures message. Does not implicitly {@link google.cloud.speech.v2.RecognitionFeatures.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IRecognitionFeatures} message RecognitionFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.profanityFilter != null && Object.hasOwnProperty.call(message, "profanityFilter")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.profanityFilter); + if (message.enableWordTimeOffsets != null && Object.hasOwnProperty.call(message, "enableWordTimeOffsets")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.enableWordTimeOffsets); + if (message.enableWordConfidence != null && Object.hasOwnProperty.call(message, "enableWordConfidence")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.enableWordConfidence); + if (message.enableAutomaticPunctuation != null && Object.hasOwnProperty.call(message, "enableAutomaticPunctuation")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.enableAutomaticPunctuation); + if (message.diarizationConfig != null && Object.hasOwnProperty.call(message, "diarizationConfig")) + $root.google.cloud.speech.v2.SpeakerDiarizationConfig.encode(message.diarizationConfig, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.enableSpokenPunctuation != null && Object.hasOwnProperty.call(message, "enableSpokenPunctuation")) + writer.uint32(/* id 14, wireType 0 =*/112).bool(message.enableSpokenPunctuation); + if (message.enableSpokenEmojis != null && Object.hasOwnProperty.call(message, "enableSpokenEmojis")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.enableSpokenEmojis); + if (message.maxAlternatives != null && Object.hasOwnProperty.call(message, "maxAlternatives")) + writer.uint32(/* id 16, wireType 0 =*/128).int32(message.maxAlternatives); + if (message.multiChannelMode != null && Object.hasOwnProperty.call(message, "multiChannelMode")) + writer.uint32(/* id 17, wireType 0 =*/136).int32(message.multiChannelMode); + return writer; + }; + + /** + * Encodes the specified RecognitionFeatures message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IRecognitionFeatures} message RecognitionFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecognitionFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.RecognitionFeatures} RecognitionFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionFeatures.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.v2.RecognitionFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.profanityFilter = reader.bool(); + break; + } + case 2: { + message.enableWordTimeOffsets = reader.bool(); + break; + } + case 3: { + message.enableWordConfidence = reader.bool(); + break; + } + case 4: { + message.enableAutomaticPunctuation = reader.bool(); + break; + } + case 14: { + message.enableSpokenPunctuation = reader.bool(); + break; + } + case 15: { + message.enableSpokenEmojis = reader.bool(); + break; + } + case 17: { + message.multiChannelMode = reader.int32(); + break; + } + case 9: { + message.diarizationConfig = $root.google.cloud.speech.v2.SpeakerDiarizationConfig.decode(reader, reader.uint32()); + break; + } + case 16: { + message.maxAlternatives = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecognitionFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.RecognitionFeatures} RecognitionFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecognitionFeatures message. + * @function verify + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecognitionFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.profanityFilter != null && message.hasOwnProperty("profanityFilter")) + if (typeof message.profanityFilter !== "boolean") + return "profanityFilter: boolean expected"; + 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")) + if (typeof message.enableSpokenPunctuation !== "boolean") + return "enableSpokenPunctuation: boolean expected"; + if (message.enableSpokenEmojis != null && message.hasOwnProperty("enableSpokenEmojis")) + if (typeof message.enableSpokenEmojis !== "boolean") + return "enableSpokenEmojis: boolean expected"; + if (message.multiChannelMode != null && message.hasOwnProperty("multiChannelMode")) + switch (message.multiChannelMode) { + default: + return "multiChannelMode: enum value expected"; + case 0: + case 1: + break; + } + if (message.diarizationConfig != null && message.hasOwnProperty("diarizationConfig")) { + var error = $root.google.cloud.speech.v2.SpeakerDiarizationConfig.verify(message.diarizationConfig); + if (error) + return "diarizationConfig." + error; + } + if (message.maxAlternatives != null && message.hasOwnProperty("maxAlternatives")) + if (!$util.isInteger(message.maxAlternatives)) + return "maxAlternatives: integer expected"; + return null; + }; + + /** + * Creates a RecognitionFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.RecognitionFeatures} RecognitionFeatures + */ + RecognitionFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.RecognitionFeatures) + return object; + var message = new $root.google.cloud.speech.v2.RecognitionFeatures(); + if (object.profanityFilter != null) + message.profanityFilter = Boolean(object.profanityFilter); + 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) + message.enableSpokenPunctuation = Boolean(object.enableSpokenPunctuation); + if (object.enableSpokenEmojis != null) + message.enableSpokenEmojis = Boolean(object.enableSpokenEmojis); + switch (object.multiChannelMode) { + case "MULTI_CHANNEL_MODE_UNSPECIFIED": + case 0: + message.multiChannelMode = 0; + break; + case "SEPARATE_RECOGNITION_PER_CHANNEL": + case 1: + message.multiChannelMode = 1; + break; + } + if (object.diarizationConfig != null) { + if (typeof object.diarizationConfig !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionFeatures.diarizationConfig: object expected"); + message.diarizationConfig = $root.google.cloud.speech.v2.SpeakerDiarizationConfig.fromObject(object.diarizationConfig); + } + if (object.maxAlternatives != null) + message.maxAlternatives = object.maxAlternatives | 0; + return message; + }; + + /** + * Creates a plain object from a RecognitionFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {google.cloud.speech.v2.RecognitionFeatures} message RecognitionFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecognitionFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.profanityFilter = false; + object.enableWordTimeOffsets = false; + object.enableWordConfidence = false; + object.enableAutomaticPunctuation = false; + object.diarizationConfig = null; + object.enableSpokenPunctuation = false; + object.enableSpokenEmojis = false; + object.maxAlternatives = 0; + object.multiChannelMode = options.enums === String ? "MULTI_CHANNEL_MODE_UNSPECIFIED" : 0; + } + if (message.profanityFilter != null && message.hasOwnProperty("profanityFilter")) + object.profanityFilter = message.profanityFilter; + if (message.enableWordTimeOffsets != null && message.hasOwnProperty("enableWordTimeOffsets")) + object.enableWordTimeOffsets = message.enableWordTimeOffsets; + if (message.enableWordConfidence != null && message.hasOwnProperty("enableWordConfidence")) + object.enableWordConfidence = message.enableWordConfidence; + if (message.enableAutomaticPunctuation != null && message.hasOwnProperty("enableAutomaticPunctuation")) + object.enableAutomaticPunctuation = message.enableAutomaticPunctuation; + if (message.diarizationConfig != null && message.hasOwnProperty("diarizationConfig")) + object.diarizationConfig = $root.google.cloud.speech.v2.SpeakerDiarizationConfig.toObject(message.diarizationConfig, options); + if (message.enableSpokenPunctuation != null && message.hasOwnProperty("enableSpokenPunctuation")) + object.enableSpokenPunctuation = message.enableSpokenPunctuation; + if (message.enableSpokenEmojis != null && message.hasOwnProperty("enableSpokenEmojis")) + object.enableSpokenEmojis = message.enableSpokenEmojis; + if (message.maxAlternatives != null && message.hasOwnProperty("maxAlternatives")) + object.maxAlternatives = message.maxAlternatives; + if (message.multiChannelMode != null && message.hasOwnProperty("multiChannelMode")) + object.multiChannelMode = options.enums === String ? $root.google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode[message.multiChannelMode] : message.multiChannelMode; + return object; + }; + + /** + * Converts this RecognitionFeatures to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @instance + * @returns {Object.} JSON object + */ + RecognitionFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecognitionFeatures + * @function getTypeUrl + * @memberof google.cloud.speech.v2.RecognitionFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecognitionFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.RecognitionFeatures"; + }; + + /** + * MultiChannelMode enum. + * @name google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode + * @enum {number} + * @property {number} MULTI_CHANNEL_MODE_UNSPECIFIED=0 MULTI_CHANNEL_MODE_UNSPECIFIED value + * @property {number} SEPARATE_RECOGNITION_PER_CHANNEL=1 SEPARATE_RECOGNITION_PER_CHANNEL value + */ + RecognitionFeatures.MultiChannelMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MULTI_CHANNEL_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEPARATE_RECOGNITION_PER_CHANNEL"] = 1; + return values; + })(); + + return RecognitionFeatures; + })(); + + v2.SpeechAdaptation = (function() { + + /** + * Properties of a SpeechAdaptation. + * @memberof google.cloud.speech.v2 + * @interface ISpeechAdaptation + * @property {Array.|null} [phraseSets] SpeechAdaptation phraseSets + * @property {Array.|null} [customClasses] SpeechAdaptation customClasses + */ + + /** + * Constructs a new SpeechAdaptation. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a SpeechAdaptation. + * @implements ISpeechAdaptation + * @constructor + * @param {google.cloud.speech.v2.ISpeechAdaptation=} [properties] Properties to set + */ + function SpeechAdaptation(properties) { + this.phraseSets = []; + 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.v2.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.phraseSets = $util.emptyArray; + + /** + * SpeechAdaptation customClasses. + * @member {Array.} customClasses + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.customClasses = $util.emptyArray; + + /** + * Creates a new SpeechAdaptation instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @static + * @param {google.cloud.speech.v2.ISpeechAdaptation=} [properties] Properties to set + * @returns {google.cloud.speech.v2.SpeechAdaptation} SpeechAdaptation instance + */ + SpeechAdaptation.create = function create(properties) { + return new SpeechAdaptation(properties); + }; + + /** + * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @static + * @param {google.cloud.speech.v2.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.v2.SpeechAdaptation.AdaptationPhraseSet.encode(message.phraseSets[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.customClasses != null && message.customClasses.length) + for (var i = 0; i < message.customClasses.length; ++i) + $root.google.cloud.speech.v2.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @static + * @param {google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.SpeechAdaptation.AdaptationPhraseSet.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.customClasses && message.customClasses.length)) + message.customClasses = []; + message.customClasses.push($root.google.cloud.speech.v2.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.v2.SpeechAdaptation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.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.v2.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.v2.SpeechAdaptation.AdaptationPhraseSet.verify(message.phraseSets[i]); + if (error) + return "phraseSets." + error; + } + } + 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.v2.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.v2.SpeechAdaptation + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.SpeechAdaptation} SpeechAdaptation + */ + SpeechAdaptation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.SpeechAdaptation) + return object; + var message = new $root.google.cloud.speech.v2.SpeechAdaptation(); + if (object.phraseSets) { + if (!Array.isArray(object.phraseSets)) + throw TypeError(".google.cloud.speech.v2.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.v2.SpeechAdaptation.phraseSets: object expected"); + message.phraseSets[i] = $root.google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.fromObject(object.phraseSets[i]); + } + } + if (object.customClasses) { + if (!Array.isArray(object.customClasses)) + throw TypeError(".google.cloud.speech.v2.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.v2.SpeechAdaptation.customClasses: object expected"); + message.customClasses[i] = $root.google.cloud.speech.v2.CustomClass.fromObject(object.customClasses[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @static + * @param {google.cloud.speech.v2.SpeechAdaptation} message SpeechAdaptation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechAdaptation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.phraseSets = []; + 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.v2.SpeechAdaptation.AdaptationPhraseSet.toObject(message.phraseSets[j], options); + } + if (message.customClasses && message.customClasses.length) { + object.customClasses = []; + for (var j = 0; j < message.customClasses.length; ++j) + object.customClasses[j] = $root.google.cloud.speech.v2.CustomClass.toObject(message.customClasses[j], options); + } + return object; + }; + + /** + * Converts this SpeechAdaptation to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @instance + * @returns {Object.} JSON object + */ + SpeechAdaptation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeechAdaptation + * @function getTypeUrl + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeechAdaptation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.SpeechAdaptation"; + }; + + SpeechAdaptation.AdaptationPhraseSet = (function() { + + /** + * Properties of an AdaptationPhraseSet. + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @interface IAdaptationPhraseSet + * @property {string|null} [phraseSet] AdaptationPhraseSet phraseSet + * @property {google.cloud.speech.v2.IPhraseSet|null} [inlinePhraseSet] AdaptationPhraseSet inlinePhraseSet + */ + + /** + * Constructs a new AdaptationPhraseSet. + * @memberof google.cloud.speech.v2.SpeechAdaptation + * @classdesc Represents an AdaptationPhraseSet. + * @implements IAdaptationPhraseSet + * @constructor + * @param {google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet=} [properties] Properties to set + */ + function AdaptationPhraseSet(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]]; + } + + /** + * AdaptationPhraseSet phraseSet. + * @member {string|null|undefined} phraseSet + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @instance + */ + AdaptationPhraseSet.prototype.phraseSet = null; + + /** + * AdaptationPhraseSet inlinePhraseSet. + * @member {google.cloud.speech.v2.IPhraseSet|null|undefined} inlinePhraseSet + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @instance + */ + AdaptationPhraseSet.prototype.inlinePhraseSet = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * AdaptationPhraseSet value. + * @member {"phraseSet"|"inlinePhraseSet"|undefined} value + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @instance + */ + Object.defineProperty(AdaptationPhraseSet.prototype, "value", { + get: $util.oneOfGetter($oneOfFields = ["phraseSet", "inlinePhraseSet"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new AdaptationPhraseSet instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet=} [properties] Properties to set + * @returns {google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet} AdaptationPhraseSet instance + */ + AdaptationPhraseSet.create = function create(properties) { + return new AdaptationPhraseSet(properties); + }; + + /** + * Encodes the specified AdaptationPhraseSet message. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet} message AdaptationPhraseSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AdaptationPhraseSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSet != null && Object.hasOwnProperty.call(message, "phraseSet")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.phraseSet); + if (message.inlinePhraseSet != null && Object.hasOwnProperty.call(message, "inlinePhraseSet")) + $root.google.cloud.speech.v2.PhraseSet.encode(message.inlinePhraseSet, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AdaptationPhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {google.cloud.speech.v2.SpeechAdaptation.IAdaptationPhraseSet} message AdaptationPhraseSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AdaptationPhraseSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AdaptationPhraseSet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet} AdaptationPhraseSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AdaptationPhraseSet.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.v2.SpeechAdaptation.AdaptationPhraseSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.phraseSet = reader.string(); + break; + } + case 2: { + message.inlinePhraseSet = $root.google.cloud.speech.v2.PhraseSet.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AdaptationPhraseSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet} AdaptationPhraseSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AdaptationPhraseSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AdaptationPhraseSet message. + * @function verify + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AdaptationPhraseSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + properties.value = 1; + if (!$util.isString(message.phraseSet)) + return "phraseSet: string expected"; + } + if (message.inlinePhraseSet != null && message.hasOwnProperty("inlinePhraseSet")) { + if (properties.value === 1) + return "value: multiple values"; + properties.value = 1; + { + var error = $root.google.cloud.speech.v2.PhraseSet.verify(message.inlinePhraseSet); + if (error) + return "inlinePhraseSet." + error; + } + } + return null; + }; + + /** + * Creates an AdaptationPhraseSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet} AdaptationPhraseSet + */ + AdaptationPhraseSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet) + return object; + var message = new $root.google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet(); + if (object.phraseSet != null) + message.phraseSet = String(object.phraseSet); + if (object.inlinePhraseSet != null) { + if (typeof object.inlinePhraseSet !== "object") + throw TypeError(".google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet.inlinePhraseSet: object expected"); + message.inlinePhraseSet = $root.google.cloud.speech.v2.PhraseSet.fromObject(object.inlinePhraseSet); + } + return message; + }; + + /** + * Creates a plain object from an AdaptationPhraseSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet} message AdaptationPhraseSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AdaptationPhraseSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + object.phraseSet = message.phraseSet; + if (options.oneofs) + object.value = "phraseSet"; + } + if (message.inlinePhraseSet != null && message.hasOwnProperty("inlinePhraseSet")) { + object.inlinePhraseSet = $root.google.cloud.speech.v2.PhraseSet.toObject(message.inlinePhraseSet, options); + if (options.oneofs) + object.value = "inlinePhraseSet"; + } + return object; + }; + + /** + * Converts this AdaptationPhraseSet to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @instance + * @returns {Object.} JSON object + */ + AdaptationPhraseSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AdaptationPhraseSet + * @function getTypeUrl + * @memberof google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AdaptationPhraseSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet"; + }; + + return AdaptationPhraseSet; + })(); + + return SpeechAdaptation; + })(); + + v2.RecognitionConfig = (function() { + + /** + * Properties of a RecognitionConfig. + * @memberof google.cloud.speech.v2 + * @interface IRecognitionConfig + * @property {google.cloud.speech.v2.IAutoDetectDecodingConfig|null} [autoDecodingConfig] RecognitionConfig autoDecodingConfig + * @property {google.cloud.speech.v2.IExplicitDecodingConfig|null} [explicitDecodingConfig] RecognitionConfig explicitDecodingConfig + * @property {google.cloud.speech.v2.IRecognitionFeatures|null} [features] RecognitionConfig features + * @property {google.cloud.speech.v2.ISpeechAdaptation|null} [adaptation] RecognitionConfig adaptation + */ + + /** + * Constructs a new RecognitionConfig. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a RecognitionConfig. + * @implements IRecognitionConfig + * @constructor + * @param {google.cloud.speech.v2.IRecognitionConfig=} [properties] Properties to set + */ + function RecognitionConfig(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]]; + } + + /** + * RecognitionConfig autoDecodingConfig. + * @member {google.cloud.speech.v2.IAutoDetectDecodingConfig|null|undefined} autoDecodingConfig + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.autoDecodingConfig = null; + + /** + * RecognitionConfig explicitDecodingConfig. + * @member {google.cloud.speech.v2.IExplicitDecodingConfig|null|undefined} explicitDecodingConfig + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.explicitDecodingConfig = null; + + /** + * RecognitionConfig features. + * @member {google.cloud.speech.v2.IRecognitionFeatures|null|undefined} features + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.features = null; + + /** + * RecognitionConfig adaptation. + * @member {google.cloud.speech.v2.ISpeechAdaptation|null|undefined} adaptation + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + */ + RecognitionConfig.prototype.adaptation = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RecognitionConfig decodingConfig. + * @member {"autoDecodingConfig"|"explicitDecodingConfig"|undefined} decodingConfig + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + */ + Object.defineProperty(RecognitionConfig.prototype, "decodingConfig", { + get: $util.oneOfGetter($oneOfFields = ["autoDecodingConfig", "explicitDecodingConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new RecognitionConfig instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {google.cloud.speech.v2.IRecognitionConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.RecognitionConfig} RecognitionConfig instance + */ + RecognitionConfig.create = function create(properties) { + return new RecognitionConfig(properties); + }; + + /** + * Encodes the specified RecognitionConfig message. Does not implicitly {@link google.cloud.speech.v2.RecognitionConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {google.cloud.speech.v2.IRecognitionConfig} message RecognitionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.cloud.speech.v2.RecognitionFeatures.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.adaptation != null && Object.hasOwnProperty.call(message, "adaptation")) + $root.google.cloud.speech.v2.SpeechAdaptation.encode(message.adaptation, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.autoDecodingConfig != null && Object.hasOwnProperty.call(message, "autoDecodingConfig")) + $root.google.cloud.speech.v2.AutoDetectDecodingConfig.encode(message.autoDecodingConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.explicitDecodingConfig != null && Object.hasOwnProperty.call(message, "explicitDecodingConfig")) + $root.google.cloud.speech.v2.ExplicitDecodingConfig.encode(message.explicitDecodingConfig, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecognitionConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {google.cloud.speech.v2.IRecognitionConfig} message RecognitionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecognitionConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.RecognitionConfig} RecognitionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionConfig.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.v2.RecognitionConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 7: { + message.autoDecodingConfig = $root.google.cloud.speech.v2.AutoDetectDecodingConfig.decode(reader, reader.uint32()); + break; + } + case 8: { + message.explicitDecodingConfig = $root.google.cloud.speech.v2.ExplicitDecodingConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.features = $root.google.cloud.speech.v2.RecognitionFeatures.decode(reader, reader.uint32()); + break; + } + case 6: { + message.adaptation = $root.google.cloud.speech.v2.SpeechAdaptation.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecognitionConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.RecognitionConfig} RecognitionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecognitionConfig message. + * @function verify + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecognitionConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.autoDecodingConfig != null && message.hasOwnProperty("autoDecodingConfig")) { + properties.decodingConfig = 1; + { + var error = $root.google.cloud.speech.v2.AutoDetectDecodingConfig.verify(message.autoDecodingConfig); + if (error) + return "autoDecodingConfig." + error; + } + } + if (message.explicitDecodingConfig != null && message.hasOwnProperty("explicitDecodingConfig")) { + if (properties.decodingConfig === 1) + return "decodingConfig: multiple values"; + properties.decodingConfig = 1; + { + var error = $root.google.cloud.speech.v2.ExplicitDecodingConfig.verify(message.explicitDecodingConfig); + if (error) + return "explicitDecodingConfig." + error; + } + } + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.cloud.speech.v2.RecognitionFeatures.verify(message.features); + if (error) + return "features." + error; + } + if (message.adaptation != null && message.hasOwnProperty("adaptation")) { + var error = $root.google.cloud.speech.v2.SpeechAdaptation.verify(message.adaptation); + if (error) + return "adaptation." + error; + } + return null; + }; + + /** + * Creates a RecognitionConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.RecognitionConfig} RecognitionConfig + */ + RecognitionConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.RecognitionConfig) + return object; + var message = new $root.google.cloud.speech.v2.RecognitionConfig(); + if (object.autoDecodingConfig != null) { + if (typeof object.autoDecodingConfig !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionConfig.autoDecodingConfig: object expected"); + message.autoDecodingConfig = $root.google.cloud.speech.v2.AutoDetectDecodingConfig.fromObject(object.autoDecodingConfig); + } + if (object.explicitDecodingConfig != null) { + if (typeof object.explicitDecodingConfig !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionConfig.explicitDecodingConfig: object expected"); + message.explicitDecodingConfig = $root.google.cloud.speech.v2.ExplicitDecodingConfig.fromObject(object.explicitDecodingConfig); + } + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionConfig.features: object expected"); + message.features = $root.google.cloud.speech.v2.RecognitionFeatures.fromObject(object.features); + } + if (object.adaptation != null) { + if (typeof object.adaptation !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionConfig.adaptation: object expected"); + message.adaptation = $root.google.cloud.speech.v2.SpeechAdaptation.fromObject(object.adaptation); + } + return message; + }; + + /** + * Creates a plain object from a RecognitionConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {google.cloud.speech.v2.RecognitionConfig} message RecognitionConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecognitionConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.features = null; + object.adaptation = null; + } + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.cloud.speech.v2.RecognitionFeatures.toObject(message.features, options); + if (message.adaptation != null && message.hasOwnProperty("adaptation")) + object.adaptation = $root.google.cloud.speech.v2.SpeechAdaptation.toObject(message.adaptation, options); + if (message.autoDecodingConfig != null && message.hasOwnProperty("autoDecodingConfig")) { + object.autoDecodingConfig = $root.google.cloud.speech.v2.AutoDetectDecodingConfig.toObject(message.autoDecodingConfig, options); + if (options.oneofs) + object.decodingConfig = "autoDecodingConfig"; + } + if (message.explicitDecodingConfig != null && message.hasOwnProperty("explicitDecodingConfig")) { + object.explicitDecodingConfig = $root.google.cloud.speech.v2.ExplicitDecodingConfig.toObject(message.explicitDecodingConfig, options); + if (options.oneofs) + object.decodingConfig = "explicitDecodingConfig"; + } + return object; + }; + + /** + * Converts this RecognitionConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.RecognitionConfig + * @instance + * @returns {Object.} JSON object + */ + RecognitionConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecognitionConfig + * @function getTypeUrl + * @memberof google.cloud.speech.v2.RecognitionConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecognitionConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.RecognitionConfig"; + }; + + return RecognitionConfig; + })(); + + v2.RecognizeRequest = (function() { + + /** + * Properties of a RecognizeRequest. + * @memberof google.cloud.speech.v2 + * @interface IRecognizeRequest + * @property {string|null} [recognizer] RecognizeRequest recognizer + * @property {google.cloud.speech.v2.IRecognitionConfig|null} [config] RecognizeRequest config + * @property {google.protobuf.IFieldMask|null} [configMask] RecognizeRequest configMask + * @property {Uint8Array|null} [content] RecognizeRequest content + * @property {string|null} [uri] RecognizeRequest uri + */ + + /** + * Constructs a new RecognizeRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a RecognizeRequest. + * @implements IRecognizeRequest + * @constructor + * @param {google.cloud.speech.v2.IRecognizeRequest=} [properties] Properties to set + */ + function RecognizeRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecognizeRequest recognizer. + * @member {string} recognizer + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + RecognizeRequest.prototype.recognizer = ""; + + /** + * RecognizeRequest config. + * @member {google.cloud.speech.v2.IRecognitionConfig|null|undefined} config + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + RecognizeRequest.prototype.config = null; + + /** + * RecognizeRequest configMask. + * @member {google.protobuf.IFieldMask|null|undefined} configMask + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + RecognizeRequest.prototype.configMask = null; + + /** + * RecognizeRequest content. + * @member {Uint8Array|null|undefined} content + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + RecognizeRequest.prototype.content = null; + + /** + * RecognizeRequest uri. + * @member {string|null|undefined} uri + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + RecognizeRequest.prototype.uri = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RecognizeRequest audioSource. + * @member {"content"|"uri"|undefined} audioSource + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + */ + Object.defineProperty(RecognizeRequest.prototype, "audioSource", { + get: $util.oneOfGetter($oneOfFields = ["content", "uri"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new RecognizeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {google.cloud.speech.v2.IRecognizeRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.RecognizeRequest} RecognizeRequest instance + */ + RecognizeRequest.create = function create(properties) { + return new RecognizeRequest(properties); + }; + + /** + * Encodes the specified RecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.RecognizeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {google.cloud.speech.v2.IRecognizeRequest} message RecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognizeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.cloud.speech.v2.RecognitionConfig.encode(message.config, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.recognizer != null && Object.hasOwnProperty.call(message, "recognizer")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.recognizer); + if (message.content != null && Object.hasOwnProperty.call(message, "content")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.content); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.uri); + if (message.configMask != null && Object.hasOwnProperty.call(message, "configMask")) + $root.google.protobuf.FieldMask.encode(message.configMask, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognizeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {google.cloud.speech.v2.IRecognizeRequest} message RecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognizeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecognizeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.RecognizeRequest} RecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognizeRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v2.RecognizeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.recognizer = reader.string(); + break; + } + case 1: { + message.config = $root.google.cloud.speech.v2.RecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 8: { + message.configMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.content = reader.bytes(); + break; + } + case 6: { + message.uri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecognizeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.RecognizeRequest} RecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognizeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecognizeRequest message. + * @function verify + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecognizeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + if (!$util.isString(message.recognizer)) + return "recognizer: string expected"; + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.cloud.speech.v2.RecognitionConfig.verify(message.config); + if (error) + return "config." + error; + } + if (message.configMask != null && message.hasOwnProperty("configMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.configMask); + if (error) + return "configMask." + error; + } + if (message.content != null && message.hasOwnProperty("content")) { + properties.audioSource = 1; + if (!(message.content && typeof message.content.length === "number" || $util.isString(message.content))) + return "content: buffer expected"; + } + if (message.uri != null && message.hasOwnProperty("uri")) { + if (properties.audioSource === 1) + return "audioSource: multiple values"; + properties.audioSource = 1; + if (!$util.isString(message.uri)) + return "uri: string expected"; + } + return null; + }; + + /** + * Creates a RecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.RecognizeRequest} RecognizeRequest + */ + RecognizeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.RecognizeRequest) + return object; + var message = new $root.google.cloud.speech.v2.RecognizeRequest(); + if (object.recognizer != null) + message.recognizer = String(object.recognizer); + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.cloud.speech.v2.RecognizeRequest.config: object expected"); + message.config = $root.google.cloud.speech.v2.RecognitionConfig.fromObject(object.config); + } + if (object.configMask != null) { + if (typeof object.configMask !== "object") + throw TypeError(".google.cloud.speech.v2.RecognizeRequest.configMask: object expected"); + message.configMask = $root.google.protobuf.FieldMask.fromObject(object.configMask); + } + if (object.content != null) + if (typeof object.content === "string") + $util.base64.decode(object.content, message.content = $util.newBuffer($util.base64.length(object.content)), 0); + else if (object.content.length >= 0) + message.content = object.content; + if (object.uri != null) + message.uri = String(object.uri); + return message; + }; + + /** + * Creates a plain object from a RecognizeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {google.cloud.speech.v2.RecognizeRequest} message RecognizeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecognizeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.config = null; + object.recognizer = ""; + object.configMask = null; + } + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.cloud.speech.v2.RecognitionConfig.toObject(message.config, options); + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + object.recognizer = message.recognizer; + if (message.content != null && message.hasOwnProperty("content")) { + object.content = options.bytes === String ? $util.base64.encode(message.content, 0, message.content.length) : options.bytes === Array ? Array.prototype.slice.call(message.content) : message.content; + if (options.oneofs) + object.audioSource = "content"; + } + if (message.uri != null && message.hasOwnProperty("uri")) { + object.uri = message.uri; + if (options.oneofs) + object.audioSource = "uri"; + } + if (message.configMask != null && message.hasOwnProperty("configMask")) + object.configMask = $root.google.protobuf.FieldMask.toObject(message.configMask, options); + return object; + }; + + /** + * Converts this RecognizeRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.RecognizeRequest + * @instance + * @returns {Object.} JSON object + */ + RecognizeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecognizeRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.RecognizeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecognizeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.RecognizeRequest"; + }; + + return RecognizeRequest; + })(); + + v2.RecognitionResponseMetadata = (function() { + + /** + * Properties of a RecognitionResponseMetadata. + * @memberof google.cloud.speech.v2 + * @interface IRecognitionResponseMetadata + * @property {google.protobuf.IDuration|null} [totalBilledDuration] RecognitionResponseMetadata totalBilledDuration + */ + + /** + * Constructs a new RecognitionResponseMetadata. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a RecognitionResponseMetadata. + * @implements IRecognitionResponseMetadata + * @constructor + * @param {google.cloud.speech.v2.IRecognitionResponseMetadata=} [properties] Properties to set + */ + function RecognitionResponseMetadata(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]]; + } + + /** + * RecognitionResponseMetadata totalBilledDuration. + * @member {google.protobuf.IDuration|null|undefined} totalBilledDuration + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @instance + */ + RecognitionResponseMetadata.prototype.totalBilledDuration = null; + + /** + * Creates a new RecognitionResponseMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {google.cloud.speech.v2.IRecognitionResponseMetadata=} [properties] Properties to set + * @returns {google.cloud.speech.v2.RecognitionResponseMetadata} RecognitionResponseMetadata instance + */ + RecognitionResponseMetadata.create = function create(properties) { + return new RecognitionResponseMetadata(properties); + }; + + /** + * Encodes the specified RecognitionResponseMetadata message. Does not implicitly {@link google.cloud.speech.v2.RecognitionResponseMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {google.cloud.speech.v2.IRecognitionResponseMetadata} message RecognitionResponseMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionResponseMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.totalBilledDuration != null && Object.hasOwnProperty.call(message, "totalBilledDuration")) + $root.google.protobuf.Duration.encode(message.totalBilledDuration, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecognitionResponseMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognitionResponseMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {google.cloud.speech.v2.IRecognitionResponseMetadata} message RecognitionResponseMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognitionResponseMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecognitionResponseMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.RecognitionResponseMetadata} RecognitionResponseMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionResponseMetadata.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.v2.RecognitionResponseMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + message.totalBilledDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecognitionResponseMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.RecognitionResponseMetadata} RecognitionResponseMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognitionResponseMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecognitionResponseMetadata message. + * @function verify + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecognitionResponseMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.totalBilledDuration != null && message.hasOwnProperty("totalBilledDuration")) { + var error = $root.google.protobuf.Duration.verify(message.totalBilledDuration); + if (error) + return "totalBilledDuration." + error; + } + return null; + }; + + /** + * Creates a RecognitionResponseMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.RecognitionResponseMetadata} RecognitionResponseMetadata + */ + RecognitionResponseMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.RecognitionResponseMetadata) + return object; + var message = new $root.google.cloud.speech.v2.RecognitionResponseMetadata(); + if (object.totalBilledDuration != null) { + if (typeof object.totalBilledDuration !== "object") + throw TypeError(".google.cloud.speech.v2.RecognitionResponseMetadata.totalBilledDuration: object expected"); + message.totalBilledDuration = $root.google.protobuf.Duration.fromObject(object.totalBilledDuration); + } + return message; + }; + + /** + * Creates a plain object from a RecognitionResponseMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {google.cloud.speech.v2.RecognitionResponseMetadata} message RecognitionResponseMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecognitionResponseMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.totalBilledDuration = null; + if (message.totalBilledDuration != null && message.hasOwnProperty("totalBilledDuration")) + object.totalBilledDuration = $root.google.protobuf.Duration.toObject(message.totalBilledDuration, options); + return object; + }; + + /** + * Converts this RecognitionResponseMetadata to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @instance + * @returns {Object.} JSON object + */ + RecognitionResponseMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecognitionResponseMetadata + * @function getTypeUrl + * @memberof google.cloud.speech.v2.RecognitionResponseMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecognitionResponseMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.RecognitionResponseMetadata"; + }; + + return RecognitionResponseMetadata; + })(); + + v2.SpeechRecognitionAlternative = (function() { + + /** + * Properties of a SpeechRecognitionAlternative. + * @memberof google.cloud.speech.v2 + * @interface ISpeechRecognitionAlternative + * @property {string|null} [transcript] SpeechRecognitionAlternative transcript + * @property {number|null} [confidence] SpeechRecognitionAlternative confidence + * @property {Array.|null} [words] SpeechRecognitionAlternative words + */ + + /** + * Constructs a new SpeechRecognitionAlternative. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a SpeechRecognitionAlternative. + * @implements ISpeechRecognitionAlternative + * @constructor + * @param {google.cloud.speech.v2.ISpeechRecognitionAlternative=} [properties] Properties to set + */ + function SpeechRecognitionAlternative(properties) { + this.words = []; + 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]]; + } + + /** + * SpeechRecognitionAlternative transcript. + * @member {string} transcript + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @instance + */ + SpeechRecognitionAlternative.prototype.transcript = ""; + + /** + * SpeechRecognitionAlternative confidence. + * @member {number} confidence + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @instance + */ + SpeechRecognitionAlternative.prototype.confidence = 0; + + /** + * SpeechRecognitionAlternative words. + * @member {Array.} words + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @instance + */ + SpeechRecognitionAlternative.prototype.words = $util.emptyArray; + + /** + * Creates a new SpeechRecognitionAlternative instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionAlternative=} [properties] Properties to set + * @returns {google.cloud.speech.v2.SpeechRecognitionAlternative} SpeechRecognitionAlternative instance + */ + SpeechRecognitionAlternative.create = function create(properties) { + return new SpeechRecognitionAlternative(properties); + }; + + /** + * Encodes the specified SpeechRecognitionAlternative message. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionAlternative.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionAlternative} message SpeechRecognitionAlternative message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechRecognitionAlternative.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transcript != null && Object.hasOwnProperty.call(message, "transcript")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.transcript); + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.confidence); + if (message.words != null && message.words.length) + for (var i = 0; i < message.words.length; ++i) + $root.google.cloud.speech.v2.WordInfo.encode(message.words[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SpeechRecognitionAlternative message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionAlternative.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionAlternative} message SpeechRecognitionAlternative message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechRecognitionAlternative.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeechRecognitionAlternative message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.SpeechRecognitionAlternative} SpeechRecognitionAlternative + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechRecognitionAlternative.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.v2.SpeechRecognitionAlternative(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.transcript = reader.string(); + break; + } + case 2: { + message.confidence = reader.float(); + break; + } + case 3: { + if (!(message.words && message.words.length)) + message.words = []; + message.words.push($root.google.cloud.speech.v2.WordInfo.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeechRecognitionAlternative message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.SpeechRecognitionAlternative} SpeechRecognitionAlternative + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechRecognitionAlternative.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechRecognitionAlternative message. + * @function verify + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechRecognitionAlternative.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.transcript != null && message.hasOwnProperty("transcript")) + if (!$util.isString(message.transcript)) + return "transcript: string expected"; + if (message.confidence != null && message.hasOwnProperty("confidence")) + if (typeof message.confidence !== "number") + return "confidence: number expected"; + if (message.words != null && message.hasOwnProperty("words")) { + if (!Array.isArray(message.words)) + return "words: array expected"; + for (var i = 0; i < message.words.length; ++i) { + var error = $root.google.cloud.speech.v2.WordInfo.verify(message.words[i]); + if (error) + return "words." + error; + } + } + return null; + }; + + /** + * Creates a SpeechRecognitionAlternative message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.SpeechRecognitionAlternative} SpeechRecognitionAlternative + */ + SpeechRecognitionAlternative.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.SpeechRecognitionAlternative) + return object; + var message = new $root.google.cloud.speech.v2.SpeechRecognitionAlternative(); + if (object.transcript != null) + message.transcript = String(object.transcript); + if (object.confidence != null) + message.confidence = Number(object.confidence); + if (object.words) { + if (!Array.isArray(object.words)) + throw TypeError(".google.cloud.speech.v2.SpeechRecognitionAlternative.words: array expected"); + message.words = []; + for (var i = 0; i < object.words.length; ++i) { + if (typeof object.words[i] !== "object") + throw TypeError(".google.cloud.speech.v2.SpeechRecognitionAlternative.words: object expected"); + message.words[i] = $root.google.cloud.speech.v2.WordInfo.fromObject(object.words[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SpeechRecognitionAlternative message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {google.cloud.speech.v2.SpeechRecognitionAlternative} message SpeechRecognitionAlternative + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechRecognitionAlternative.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.words = []; + if (options.defaults) { + object.transcript = ""; + object.confidence = 0; + } + if (message.transcript != null && message.hasOwnProperty("transcript")) + object.transcript = message.transcript; + if (message.confidence != null && message.hasOwnProperty("confidence")) + object.confidence = options.json && !isFinite(message.confidence) ? String(message.confidence) : message.confidence; + if (message.words && message.words.length) { + object.words = []; + for (var j = 0; j < message.words.length; ++j) + object.words[j] = $root.google.cloud.speech.v2.WordInfo.toObject(message.words[j], options); + } + return object; + }; + + /** + * Converts this SpeechRecognitionAlternative to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @instance + * @returns {Object.} JSON object + */ + SpeechRecognitionAlternative.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeechRecognitionAlternative + * @function getTypeUrl + * @memberof google.cloud.speech.v2.SpeechRecognitionAlternative + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeechRecognitionAlternative.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.SpeechRecognitionAlternative"; + }; + + return SpeechRecognitionAlternative; + })(); + + v2.WordInfo = (function() { + + /** + * Properties of a WordInfo. + * @memberof google.cloud.speech.v2 + * @interface IWordInfo + * @property {google.protobuf.IDuration|null} [startOffset] WordInfo startOffset + * @property {google.protobuf.IDuration|null} [endOffset] WordInfo endOffset + * @property {string|null} [word] WordInfo word + * @property {number|null} [confidence] WordInfo confidence + * @property {string|null} [speakerLabel] WordInfo speakerLabel + */ + + /** + * Constructs a new WordInfo. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a WordInfo. + * @implements IWordInfo + * @constructor + * @param {google.cloud.speech.v2.IWordInfo=} [properties] Properties to set + */ + function WordInfo(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]]; + } + + /** + * WordInfo startOffset. + * @member {google.protobuf.IDuration|null|undefined} startOffset + * @memberof google.cloud.speech.v2.WordInfo + * @instance + */ + WordInfo.prototype.startOffset = null; + + /** + * WordInfo endOffset. + * @member {google.protobuf.IDuration|null|undefined} endOffset + * @memberof google.cloud.speech.v2.WordInfo + * @instance + */ + WordInfo.prototype.endOffset = null; + + /** + * WordInfo word. + * @member {string} word + * @memberof google.cloud.speech.v2.WordInfo + * @instance + */ + WordInfo.prototype.word = ""; + + /** + * WordInfo confidence. + * @member {number} confidence + * @memberof google.cloud.speech.v2.WordInfo + * @instance + */ + WordInfo.prototype.confidence = 0; + + /** + * WordInfo speakerLabel. + * @member {string} speakerLabel + * @memberof google.cloud.speech.v2.WordInfo + * @instance + */ + WordInfo.prototype.speakerLabel = ""; + + /** + * Creates a new WordInfo instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {google.cloud.speech.v2.IWordInfo=} [properties] Properties to set + * @returns {google.cloud.speech.v2.WordInfo} WordInfo instance + */ + WordInfo.create = function create(properties) { + return new WordInfo(properties); + }; + + /** + * Encodes the specified WordInfo message. Does not implicitly {@link google.cloud.speech.v2.WordInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {google.cloud.speech.v2.IWordInfo} message WordInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WordInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.startOffset != null && Object.hasOwnProperty.call(message, "startOffset")) + $root.google.protobuf.Duration.encode(message.startOffset, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.endOffset != null && Object.hasOwnProperty.call(message, "endOffset")) + $root.google.protobuf.Duration.encode(message.endOffset, 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.speakerLabel != null && Object.hasOwnProperty.call(message, "speakerLabel")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.speakerLabel); + return writer; + }; + + /** + * Encodes the specified WordInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v2.WordInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {google.cloud.speech.v2.IWordInfo} message WordInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WordInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WordInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.WordInfo} WordInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WordInfo.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.v2.WordInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.startOffset = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 2: { + message.endOffset = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 3: { + message.word = reader.string(); + break; + } + case 4: { + message.confidence = reader.float(); + break; + } + case 6: { + message.speakerLabel = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WordInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.WordInfo} WordInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WordInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WordInfo message. + * @function verify + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WordInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.startOffset != null && message.hasOwnProperty("startOffset")) { + var error = $root.google.protobuf.Duration.verify(message.startOffset); + if (error) + return "startOffset." + error; + } + if (message.endOffset != null && message.hasOwnProperty("endOffset")) { + var error = $root.google.protobuf.Duration.verify(message.endOffset); + if (error) + return "endOffset." + error; + } + 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.speakerLabel != null && message.hasOwnProperty("speakerLabel")) + if (!$util.isString(message.speakerLabel)) + return "speakerLabel: string expected"; + return null; + }; + + /** + * Creates a WordInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.WordInfo} WordInfo + */ + WordInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.WordInfo) + return object; + var message = new $root.google.cloud.speech.v2.WordInfo(); + if (object.startOffset != null) { + if (typeof object.startOffset !== "object") + throw TypeError(".google.cloud.speech.v2.WordInfo.startOffset: object expected"); + message.startOffset = $root.google.protobuf.Duration.fromObject(object.startOffset); + } + if (object.endOffset != null) { + if (typeof object.endOffset !== "object") + throw TypeError(".google.cloud.speech.v2.WordInfo.endOffset: object expected"); + message.endOffset = $root.google.protobuf.Duration.fromObject(object.endOffset); + } + if (object.word != null) + message.word = String(object.word); + if (object.confidence != null) + message.confidence = Number(object.confidence); + if (object.speakerLabel != null) + message.speakerLabel = String(object.speakerLabel); + return message; + }; + + /** + * Creates a plain object from a WordInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {google.cloud.speech.v2.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.startOffset = null; + object.endOffset = null; + object.word = ""; + object.confidence = 0; + object.speakerLabel = ""; + } + if (message.startOffset != null && message.hasOwnProperty("startOffset")) + object.startOffset = $root.google.protobuf.Duration.toObject(message.startOffset, options); + if (message.endOffset != null && message.hasOwnProperty("endOffset")) + object.endOffset = $root.google.protobuf.Duration.toObject(message.endOffset, 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.speakerLabel != null && message.hasOwnProperty("speakerLabel")) + object.speakerLabel = message.speakerLabel; + return object; + }; + + /** + * Converts this WordInfo to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.WordInfo + * @instance + * @returns {Object.} JSON object + */ + WordInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WordInfo + * @function getTypeUrl + * @memberof google.cloud.speech.v2.WordInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WordInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.WordInfo"; + }; + + return WordInfo; + })(); + + v2.SpeechRecognitionResult = (function() { + + /** + * Properties of a SpeechRecognitionResult. + * @memberof google.cloud.speech.v2 + * @interface ISpeechRecognitionResult + * @property {Array.|null} [alternatives] SpeechRecognitionResult alternatives + * @property {number|null} [channelTag] SpeechRecognitionResult channelTag + * @property {google.protobuf.IDuration|null} [resultEndOffset] SpeechRecognitionResult resultEndOffset + * @property {string|null} [languageCode] SpeechRecognitionResult languageCode + */ + + /** + * Constructs a new SpeechRecognitionResult. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a SpeechRecognitionResult. + * @implements ISpeechRecognitionResult + * @constructor + * @param {google.cloud.speech.v2.ISpeechRecognitionResult=} [properties] Properties to set + */ + function SpeechRecognitionResult(properties) { + this.alternatives = []; + 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]]; + } + + /** + * SpeechRecognitionResult alternatives. + * @member {Array.} alternatives + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.alternatives = $util.emptyArray; + + /** + * SpeechRecognitionResult channelTag. + * @member {number} channelTag + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.channelTag = 0; + + /** + * SpeechRecognitionResult resultEndOffset. + * @member {google.protobuf.IDuration|null|undefined} resultEndOffset + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.resultEndOffset = null; + + /** + * SpeechRecognitionResult languageCode. + * @member {string} languageCode + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @instance + */ + SpeechRecognitionResult.prototype.languageCode = ""; + + /** + * Creates a new SpeechRecognitionResult instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionResult=} [properties] Properties to set + * @returns {google.cloud.speech.v2.SpeechRecognitionResult} SpeechRecognitionResult instance + */ + SpeechRecognitionResult.create = function create(properties) { + return new SpeechRecognitionResult(properties); + }; + + /** + * Encodes the specified SpeechRecognitionResult message. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionResult} message SpeechRecognitionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechRecognitionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.alternatives != null && message.alternatives.length) + for (var i = 0; i < message.alternatives.length; ++i) + $root.google.cloud.speech.v2.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.resultEndOffset != null && Object.hasOwnProperty.call(message, "resultEndOffset")) + $root.google.protobuf.Duration.encode(message.resultEndOffset, 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; + }; + + /** + * Encodes the specified SpeechRecognitionResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.SpeechRecognitionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {google.cloud.speech.v2.ISpeechRecognitionResult} message SpeechRecognitionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechRecognitionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeechRecognitionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.SpeechRecognitionResult} SpeechRecognitionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechRecognitionResult.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.v2.SpeechRecognitionResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.alternatives && message.alternatives.length)) + message.alternatives = []; + message.alternatives.push($root.google.cloud.speech.v2.SpeechRecognitionAlternative.decode(reader, reader.uint32())); + break; + } + case 2: { + message.channelTag = reader.int32(); + break; + } + case 4: { + message.resultEndOffset = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 5: { + message.languageCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeechRecognitionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.SpeechRecognitionResult} SpeechRecognitionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechRecognitionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechRecognitionResult message. + * @function verify + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechRecognitionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.alternatives != null && message.hasOwnProperty("alternatives")) { + if (!Array.isArray(message.alternatives)) + return "alternatives: array expected"; + for (var i = 0; i < message.alternatives.length; ++i) { + var error = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.verify(message.alternatives[i]); + if (error) + return "alternatives." + error; + } + } + if (message.channelTag != null && message.hasOwnProperty("channelTag")) + if (!$util.isInteger(message.channelTag)) + return "channelTag: integer expected"; + if (message.resultEndOffset != null && message.hasOwnProperty("resultEndOffset")) { + var error = $root.google.protobuf.Duration.verify(message.resultEndOffset); + if (error) + return "resultEndOffset." + error; + } + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + return null; + }; + + /** + * Creates a SpeechRecognitionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.SpeechRecognitionResult} SpeechRecognitionResult + */ + SpeechRecognitionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.SpeechRecognitionResult) + return object; + var message = new $root.google.cloud.speech.v2.SpeechRecognitionResult(); + if (object.alternatives) { + if (!Array.isArray(object.alternatives)) + throw TypeError(".google.cloud.speech.v2.SpeechRecognitionResult.alternatives: array expected"); + message.alternatives = []; + for (var i = 0; i < object.alternatives.length; ++i) { + if (typeof object.alternatives[i] !== "object") + throw TypeError(".google.cloud.speech.v2.SpeechRecognitionResult.alternatives: object expected"); + message.alternatives[i] = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.fromObject(object.alternatives[i]); + } + } + if (object.channelTag != null) + message.channelTag = object.channelTag | 0; + if (object.resultEndOffset != null) { + if (typeof object.resultEndOffset !== "object") + throw TypeError(".google.cloud.speech.v2.SpeechRecognitionResult.resultEndOffset: object expected"); + message.resultEndOffset = $root.google.protobuf.Duration.fromObject(object.resultEndOffset); + } + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + return message; + }; + + /** + * Creates a plain object from a SpeechRecognitionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {google.cloud.speech.v2.SpeechRecognitionResult} message SpeechRecognitionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechRecognitionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.alternatives = []; + if (options.defaults) { + object.channelTag = 0; + object.resultEndOffset = null; + object.languageCode = ""; + } + if (message.alternatives && message.alternatives.length) { + object.alternatives = []; + for (var j = 0; j < message.alternatives.length; ++j) + object.alternatives[j] = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.toObject(message.alternatives[j], options); + } + if (message.channelTag != null && message.hasOwnProperty("channelTag")) + object.channelTag = message.channelTag; + if (message.resultEndOffset != null && message.hasOwnProperty("resultEndOffset")) + object.resultEndOffset = $root.google.protobuf.Duration.toObject(message.resultEndOffset, options); + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + return object; + }; + + /** + * Converts this SpeechRecognitionResult to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @instance + * @returns {Object.} JSON object + */ + SpeechRecognitionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeechRecognitionResult + * @function getTypeUrl + * @memberof google.cloud.speech.v2.SpeechRecognitionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeechRecognitionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.SpeechRecognitionResult"; + }; + + return SpeechRecognitionResult; + })(); + + v2.RecognizeResponse = (function() { + + /** + * Properties of a RecognizeResponse. + * @memberof google.cloud.speech.v2 + * @interface IRecognizeResponse + * @property {Array.|null} [results] RecognizeResponse results + * @property {google.cloud.speech.v2.IRecognitionResponseMetadata|null} [metadata] RecognizeResponse metadata + */ + + /** + * Constructs a new RecognizeResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a RecognizeResponse. + * @implements IRecognizeResponse + * @constructor + * @param {google.cloud.speech.v2.IRecognizeResponse=} [properties] Properties to set + */ + function RecognizeResponse(properties) { + this.results = []; + 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]]; + } + + /** + * RecognizeResponse results. + * @member {Array.} results + * @memberof google.cloud.speech.v2.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.results = $util.emptyArray; + + /** + * RecognizeResponse metadata. + * @member {google.cloud.speech.v2.IRecognitionResponseMetadata|null|undefined} metadata + * @memberof google.cloud.speech.v2.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.metadata = null; + + /** + * Creates a new RecognizeResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {google.cloud.speech.v2.IRecognizeResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.RecognizeResponse} RecognizeResponse instance + */ + RecognizeResponse.create = function create(properties) { + return new RecognizeResponse(properties); + }; + + /** + * Encodes the specified RecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.RecognizeResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {google.cloud.speech.v2.IRecognizeResponse} message RecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognizeResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.google.cloud.speech.v2.RecognitionResponseMetadata.encode(message.metadata, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.speech.v2.SpeechRecognitionResult.encode(message.results[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.RecognizeResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {google.cloud.speech.v2.IRecognizeResponse} message RecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecognizeResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecognizeResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.RecognizeResponse} RecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognizeResponse.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.v2.RecognizeResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.speech.v2.SpeechRecognitionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecognizeResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.RecognizeResponse} RecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecognizeResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecognizeResponse message. + * @function verify + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecognizeResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.speech.v2.SpeechRecognitionResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.google.cloud.speech.v2.RecognitionResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a RecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.RecognizeResponse} RecognizeResponse + */ + RecognizeResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.RecognizeResponse) + return object; + var message = new $root.google.cloud.speech.v2.RecognizeResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.speech.v2.RecognizeResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.speech.v2.RecognizeResponse.results: object expected"); + message.results[i] = $root.google.cloud.speech.v2.SpeechRecognitionResult.fromObject(object.results[i]); + } + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.speech.v2.RecognizeResponse.metadata: object expected"); + message.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a RecognizeResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {google.cloud.speech.v2.RecognizeResponse} message RecognizeResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecognizeResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.results = []; + if (options.defaults) + object.metadata = null; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.toObject(message.metadata, options); + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.speech.v2.SpeechRecognitionResult.toObject(message.results[j], options); + } + return object; + }; + + /** + * Converts this RecognizeResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.RecognizeResponse + * @instance + * @returns {Object.} JSON object + */ + RecognizeResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecognizeResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.RecognizeResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecognizeResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.RecognizeResponse"; + }; + + return RecognizeResponse; + })(); + + v2.StreamingRecognitionFeatures = (function() { + + /** + * Properties of a StreamingRecognitionFeatures. + * @memberof google.cloud.speech.v2 + * @interface IStreamingRecognitionFeatures + * @property {boolean|null} [enableVoiceActivityEvents] StreamingRecognitionFeatures enableVoiceActivityEvents + * @property {boolean|null} [interimResults] StreamingRecognitionFeatures interimResults + * @property {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout|null} [voiceActivityTimeout] StreamingRecognitionFeatures voiceActivityTimeout + */ + + /** + * Constructs a new StreamingRecognitionFeatures. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a StreamingRecognitionFeatures. + * @implements IStreamingRecognitionFeatures + * @constructor + * @param {google.cloud.speech.v2.IStreamingRecognitionFeatures=} [properties] Properties to set + */ + function StreamingRecognitionFeatures(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]]; + } + + /** + * StreamingRecognitionFeatures enableVoiceActivityEvents. + * @member {boolean} enableVoiceActivityEvents + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @instance + */ + StreamingRecognitionFeatures.prototype.enableVoiceActivityEvents = false; + + /** + * StreamingRecognitionFeatures interimResults. + * @member {boolean} interimResults + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @instance + */ + StreamingRecognitionFeatures.prototype.interimResults = false; + + /** + * StreamingRecognitionFeatures voiceActivityTimeout. + * @member {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout|null|undefined} voiceActivityTimeout + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @instance + */ + StreamingRecognitionFeatures.prototype.voiceActivityTimeout = null; + + /** + * Creates a new StreamingRecognitionFeatures instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionFeatures=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures} StreamingRecognitionFeatures instance + */ + StreamingRecognitionFeatures.create = function create(properties) { + return new StreamingRecognitionFeatures(properties); + }; + + /** + * Encodes the specified StreamingRecognitionFeatures message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionFeatures} message StreamingRecognitionFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.enableVoiceActivityEvents != null && Object.hasOwnProperty.call(message, "enableVoiceActivityEvents")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.enableVoiceActivityEvents); + if (message.interimResults != null && Object.hasOwnProperty.call(message, "interimResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.interimResults); + if (message.voiceActivityTimeout != null && Object.hasOwnProperty.call(message, "voiceActivityTimeout")) + $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.encode(message.voiceActivityTimeout, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingRecognitionFeatures message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionFeatures} message StreamingRecognitionFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingRecognitionFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures} StreamingRecognitionFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionFeatures.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.v2.StreamingRecognitionFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.enableVoiceActivityEvents = reader.bool(); + break; + } + case 2: { + message.interimResults = reader.bool(); + break; + } + case 3: { + message.voiceActivityTimeout = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingRecognitionFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures} StreamingRecognitionFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingRecognitionFeatures message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingRecognitionFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.enableVoiceActivityEvents != null && message.hasOwnProperty("enableVoiceActivityEvents")) + if (typeof message.enableVoiceActivityEvents !== "boolean") + return "enableVoiceActivityEvents: boolean expected"; + if (message.interimResults != null && message.hasOwnProperty("interimResults")) + if (typeof message.interimResults !== "boolean") + return "interimResults: boolean expected"; + if (message.voiceActivityTimeout != null && message.hasOwnProperty("voiceActivityTimeout")) { + var error = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.verify(message.voiceActivityTimeout); + if (error) + return "voiceActivityTimeout." + error; + } + return null; + }; + + /** + * Creates a StreamingRecognitionFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures} StreamingRecognitionFeatures + */ + StreamingRecognitionFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognitionFeatures) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognitionFeatures(); + if (object.enableVoiceActivityEvents != null) + message.enableVoiceActivityEvents = Boolean(object.enableVoiceActivityEvents); + if (object.interimResults != null) + message.interimResults = Boolean(object.interimResults); + if (object.voiceActivityTimeout != null) { + if (typeof object.voiceActivityTimeout !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionFeatures.voiceActivityTimeout: object expected"); + message.voiceActivityTimeout = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.fromObject(object.voiceActivityTimeout); + } + return message; + }; + + /** + * Creates a plain object from a StreamingRecognitionFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures} message StreamingRecognitionFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamingRecognitionFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.enableVoiceActivityEvents = false; + object.interimResults = false; + object.voiceActivityTimeout = null; + } + if (message.enableVoiceActivityEvents != null && message.hasOwnProperty("enableVoiceActivityEvents")) + object.enableVoiceActivityEvents = message.enableVoiceActivityEvents; + if (message.interimResults != null && message.hasOwnProperty("interimResults")) + object.interimResults = message.interimResults; + if (message.voiceActivityTimeout != null && message.hasOwnProperty("voiceActivityTimeout")) + object.voiceActivityTimeout = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.toObject(message.voiceActivityTimeout, options); + return object; + }; + + /** + * Converts this StreamingRecognitionFeatures to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @instance + * @returns {Object.} JSON object + */ + StreamingRecognitionFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamingRecognitionFeatures + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamingRecognitionFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognitionFeatures"; + }; + + StreamingRecognitionFeatures.VoiceActivityTimeout = (function() { + + /** + * Properties of a VoiceActivityTimeout. + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @interface IVoiceActivityTimeout + * @property {google.protobuf.IDuration|null} [speechStartTimeout] VoiceActivityTimeout speechStartTimeout + * @property {google.protobuf.IDuration|null} [speechEndTimeout] VoiceActivityTimeout speechEndTimeout + */ + + /** + * Constructs a new VoiceActivityTimeout. + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures + * @classdesc Represents a VoiceActivityTimeout. + * @implements IVoiceActivityTimeout + * @constructor + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout=} [properties] Properties to set + */ + function VoiceActivityTimeout(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]]; + } + + /** + * VoiceActivityTimeout speechStartTimeout. + * @member {google.protobuf.IDuration|null|undefined} speechStartTimeout + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @instance + */ + VoiceActivityTimeout.prototype.speechStartTimeout = null; + + /** + * VoiceActivityTimeout speechEndTimeout. + * @member {google.protobuf.IDuration|null|undefined} speechEndTimeout + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @instance + */ + VoiceActivityTimeout.prototype.speechEndTimeout = null; + + /** + * Creates a new VoiceActivityTimeout instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout} VoiceActivityTimeout instance + */ + VoiceActivityTimeout.create = function create(properties) { + return new VoiceActivityTimeout(properties); + }; + + /** + * Encodes the specified VoiceActivityTimeout message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout} message VoiceActivityTimeout message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VoiceActivityTimeout.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.speechStartTimeout != null && Object.hasOwnProperty.call(message, "speechStartTimeout")) + $root.google.protobuf.Duration.encode(message.speechStartTimeout, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.speechEndTimeout != null && Object.hasOwnProperty.call(message, "speechEndTimeout")) + $root.google.protobuf.Duration.encode(message.speechEndTimeout, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified VoiceActivityTimeout message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures.IVoiceActivityTimeout} message VoiceActivityTimeout message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VoiceActivityTimeout.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VoiceActivityTimeout message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout} VoiceActivityTimeout + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VoiceActivityTimeout.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.v2.StreamingRecognitionFeatures.VoiceActivityTimeout(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.speechStartTimeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 2: { + message.speechEndTimeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VoiceActivityTimeout message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout} VoiceActivityTimeout + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VoiceActivityTimeout.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VoiceActivityTimeout message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VoiceActivityTimeout.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.speechStartTimeout != null && message.hasOwnProperty("speechStartTimeout")) { + var error = $root.google.protobuf.Duration.verify(message.speechStartTimeout); + if (error) + return "speechStartTimeout." + error; + } + if (message.speechEndTimeout != null && message.hasOwnProperty("speechEndTimeout")) { + var error = $root.google.protobuf.Duration.verify(message.speechEndTimeout); + if (error) + return "speechEndTimeout." + error; + } + return null; + }; + + /** + * Creates a VoiceActivityTimeout message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout} VoiceActivityTimeout + */ + VoiceActivityTimeout.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout(); + if (object.speechStartTimeout != null) { + if (typeof object.speechStartTimeout !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.speechStartTimeout: object expected"); + message.speechStartTimeout = $root.google.protobuf.Duration.fromObject(object.speechStartTimeout); + } + if (object.speechEndTimeout != null) { + if (typeof object.speechEndTimeout !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout.speechEndTimeout: object expected"); + message.speechEndTimeout = $root.google.protobuf.Duration.fromObject(object.speechEndTimeout); + } + return message; + }; + + /** + * Creates a plain object from a VoiceActivityTimeout message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout} message VoiceActivityTimeout + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VoiceActivityTimeout.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.speechStartTimeout = null; + object.speechEndTimeout = null; + } + if (message.speechStartTimeout != null && message.hasOwnProperty("speechStartTimeout")) + object.speechStartTimeout = $root.google.protobuf.Duration.toObject(message.speechStartTimeout, options); + if (message.speechEndTimeout != null && message.hasOwnProperty("speechEndTimeout")) + object.speechEndTimeout = $root.google.protobuf.Duration.toObject(message.speechEndTimeout, options); + return object; + }; + + /** + * Converts this VoiceActivityTimeout to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @instance + * @returns {Object.} JSON object + */ + VoiceActivityTimeout.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VoiceActivityTimeout + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VoiceActivityTimeout.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout"; + }; + + return VoiceActivityTimeout; + })(); + + return StreamingRecognitionFeatures; + })(); + + v2.StreamingRecognitionConfig = (function() { + + /** + * Properties of a StreamingRecognitionConfig. + * @memberof google.cloud.speech.v2 + * @interface IStreamingRecognitionConfig + * @property {google.cloud.speech.v2.IRecognitionConfig|null} [config] StreamingRecognitionConfig config + * @property {google.protobuf.IFieldMask|null} [configMask] StreamingRecognitionConfig configMask + * @property {google.cloud.speech.v2.IStreamingRecognitionFeatures|null} [streamingFeatures] StreamingRecognitionConfig streamingFeatures + */ + + /** + * Constructs a new StreamingRecognitionConfig. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a StreamingRecognitionConfig. + * @implements IStreamingRecognitionConfig + * @constructor + * @param {google.cloud.speech.v2.IStreamingRecognitionConfig=} [properties] Properties to set + */ + function StreamingRecognitionConfig(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]]; + } + + /** + * StreamingRecognitionConfig config. + * @member {google.cloud.speech.v2.IRecognitionConfig|null|undefined} config + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @instance + */ + StreamingRecognitionConfig.prototype.config = null; + + /** + * StreamingRecognitionConfig configMask. + * @member {google.protobuf.IFieldMask|null|undefined} configMask + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @instance + */ + StreamingRecognitionConfig.prototype.configMask = null; + + /** + * StreamingRecognitionConfig streamingFeatures. + * @member {google.cloud.speech.v2.IStreamingRecognitionFeatures|null|undefined} streamingFeatures + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @instance + */ + StreamingRecognitionConfig.prototype.streamingFeatures = null; + + /** + * Creates a new StreamingRecognitionConfig instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognitionConfig} StreamingRecognitionConfig instance + */ + StreamingRecognitionConfig.create = function create(properties) { + return new StreamingRecognitionConfig(properties); + }; + + /** + * Encodes the specified StreamingRecognitionConfig message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionConfig} message StreamingRecognitionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.cloud.speech.v2.RecognitionConfig.encode(message.config, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.streamingFeatures != null && Object.hasOwnProperty.call(message, "streamingFeatures")) + $root.google.cloud.speech.v2.StreamingRecognitionFeatures.encode(message.streamingFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.configMask != null && Object.hasOwnProperty.call(message, "configMask")) + $root.google.protobuf.FieldMask.encode(message.configMask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingRecognitionConfig message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionConfig} message StreamingRecognitionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingRecognitionConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognitionConfig} StreamingRecognitionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionConfig.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.v2.StreamingRecognitionConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.config = $root.google.cloud.speech.v2.RecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.configMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 2: { + message.streamingFeatures = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingRecognitionConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognitionConfig} StreamingRecognitionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingRecognitionConfig message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingRecognitionConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.cloud.speech.v2.RecognitionConfig.verify(message.config); + if (error) + return "config." + error; + } + if (message.configMask != null && message.hasOwnProperty("configMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.configMask); + if (error) + return "configMask." + error; + } + if (message.streamingFeatures != null && message.hasOwnProperty("streamingFeatures")) { + var error = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.verify(message.streamingFeatures); + if (error) + return "streamingFeatures." + error; + } + return null; + }; + + /** + * Creates a StreamingRecognitionConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognitionConfig} StreamingRecognitionConfig + */ + StreamingRecognitionConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognitionConfig) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognitionConfig(); + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionConfig.config: object expected"); + message.config = $root.google.cloud.speech.v2.RecognitionConfig.fromObject(object.config); + } + if (object.configMask != null) { + if (typeof object.configMask !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionConfig.configMask: object expected"); + message.configMask = $root.google.protobuf.FieldMask.fromObject(object.configMask); + } + if (object.streamingFeatures != null) { + if (typeof object.streamingFeatures !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionConfig.streamingFeatures: object expected"); + message.streamingFeatures = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.fromObject(object.streamingFeatures); + } + return message; + }; + + /** + * Creates a plain object from a StreamingRecognitionConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionConfig} message StreamingRecognitionConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamingRecognitionConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.config = null; + object.streamingFeatures = null; + object.configMask = null; + } + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.cloud.speech.v2.RecognitionConfig.toObject(message.config, options); + if (message.streamingFeatures != null && message.hasOwnProperty("streamingFeatures")) + object.streamingFeatures = $root.google.cloud.speech.v2.StreamingRecognitionFeatures.toObject(message.streamingFeatures, options); + if (message.configMask != null && message.hasOwnProperty("configMask")) + object.configMask = $root.google.protobuf.FieldMask.toObject(message.configMask, options); + return object; + }; + + /** + * Converts this StreamingRecognitionConfig to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @instance + * @returns {Object.} JSON object + */ + StreamingRecognitionConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamingRecognitionConfig + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognitionConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamingRecognitionConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognitionConfig"; + }; + + return StreamingRecognitionConfig; + })(); + + v2.StreamingRecognizeRequest = (function() { + + /** + * Properties of a StreamingRecognizeRequest. + * @memberof google.cloud.speech.v2 + * @interface IStreamingRecognizeRequest + * @property {string|null} [recognizer] StreamingRecognizeRequest recognizer + * @property {google.cloud.speech.v2.IStreamingRecognitionConfig|null} [streamingConfig] StreamingRecognizeRequest streamingConfig + * @property {Uint8Array|null} [audio] StreamingRecognizeRequest audio + */ + + /** + * Constructs a new StreamingRecognizeRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a StreamingRecognizeRequest. + * @implements IStreamingRecognizeRequest + * @constructor + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest=} [properties] Properties to set + */ + function StreamingRecognizeRequest(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]]; + } + + /** + * StreamingRecognizeRequest recognizer. + * @member {string} recognizer + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @instance + */ + StreamingRecognizeRequest.prototype.recognizer = ""; + + /** + * StreamingRecognizeRequest streamingConfig. + * @member {google.cloud.speech.v2.IStreamingRecognitionConfig|null|undefined} streamingConfig + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @instance + */ + StreamingRecognizeRequest.prototype.streamingConfig = null; + + /** + * StreamingRecognizeRequest audio. + * @member {Uint8Array|null|undefined} audio + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @instance + */ + StreamingRecognizeRequest.prototype.audio = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * StreamingRecognizeRequest streamingRequest. + * @member {"streamingConfig"|"audio"|undefined} streamingRequest + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @instance + */ + Object.defineProperty(StreamingRecognizeRequest.prototype, "streamingRequest", { + get: $util.oneOfGetter($oneOfFields = ["streamingConfig", "audio"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new StreamingRecognizeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognizeRequest} StreamingRecognizeRequest instance + */ + StreamingRecognizeRequest.create = function create(properties) { + return new StreamingRecognizeRequest(properties); + }; + + /** + * Encodes the specified StreamingRecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest} message StreamingRecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognizeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recognizer != null && Object.hasOwnProperty.call(message, "recognizer")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.recognizer); + if (message.audio != null && Object.hasOwnProperty.call(message, "audio")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.audio); + if (message.streamingConfig != null && Object.hasOwnProperty.call(message, "streamingConfig")) + $root.google.cloud.speech.v2.StreamingRecognitionConfig.encode(message.streamingConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingRecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeRequest} message StreamingRecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognizeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingRecognizeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognizeRequest} StreamingRecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognizeRequest.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.v2.StreamingRecognizeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.recognizer = reader.string(); + break; + } + case 6: { + message.streamingConfig = $root.google.cloud.speech.v2.StreamingRecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 5: { + message.audio = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingRecognizeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognizeRequest} StreamingRecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognizeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingRecognizeRequest message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingRecognizeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + if (!$util.isString(message.recognizer)) + return "recognizer: string expected"; + if (message.streamingConfig != null && message.hasOwnProperty("streamingConfig")) { + properties.streamingRequest = 1; + { + var error = $root.google.cloud.speech.v2.StreamingRecognitionConfig.verify(message.streamingConfig); + if (error) + return "streamingConfig." + error; + } + } + if (message.audio != null && message.hasOwnProperty("audio")) { + if (properties.streamingRequest === 1) + return "streamingRequest: multiple values"; + properties.streamingRequest = 1; + if (!(message.audio && typeof message.audio.length === "number" || $util.isString(message.audio))) + return "audio: buffer expected"; + } + return null; + }; + + /** + * Creates a StreamingRecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognizeRequest} StreamingRecognizeRequest + */ + StreamingRecognizeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognizeRequest) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognizeRequest(); + if (object.recognizer != null) + message.recognizer = String(object.recognizer); + if (object.streamingConfig != null) { + if (typeof object.streamingConfig !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognizeRequest.streamingConfig: object expected"); + message.streamingConfig = $root.google.cloud.speech.v2.StreamingRecognitionConfig.fromObject(object.streamingConfig); + } + if (object.audio != null) + if (typeof object.audio === "string") + $util.base64.decode(object.audio, message.audio = $util.newBuffer($util.base64.length(object.audio)), 0); + else if (object.audio.length >= 0) + message.audio = object.audio; + return message; + }; + + /** + * Creates a plain object from a StreamingRecognizeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {google.cloud.speech.v2.StreamingRecognizeRequest} message StreamingRecognizeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamingRecognizeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.recognizer = ""; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + object.recognizer = message.recognizer; + if (message.audio != null && message.hasOwnProperty("audio")) { + object.audio = options.bytes === String ? $util.base64.encode(message.audio, 0, message.audio.length) : options.bytes === Array ? Array.prototype.slice.call(message.audio) : message.audio; + if (options.oneofs) + object.streamingRequest = "audio"; + } + if (message.streamingConfig != null && message.hasOwnProperty("streamingConfig")) { + object.streamingConfig = $root.google.cloud.speech.v2.StreamingRecognitionConfig.toObject(message.streamingConfig, options); + if (options.oneofs) + object.streamingRequest = "streamingConfig"; + } + return object; + }; + + /** + * Converts this StreamingRecognizeRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @instance + * @returns {Object.} JSON object + */ + StreamingRecognizeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamingRecognizeRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognizeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamingRecognizeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognizeRequest"; + }; + + return StreamingRecognizeRequest; + })(); + + v2.BatchRecognizeRequest = (function() { + + /** + * Properties of a BatchRecognizeRequest. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeRequest + * @property {string|null} [recognizer] BatchRecognizeRequest recognizer + * @property {google.cloud.speech.v2.IRecognitionConfig|null} [config] BatchRecognizeRequest config + * @property {google.protobuf.IFieldMask|null} [configMask] BatchRecognizeRequest configMask + * @property {Array.|null} [files] BatchRecognizeRequest files + */ + + /** + * Constructs a new BatchRecognizeRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeRequest. + * @implements IBatchRecognizeRequest + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeRequest=} [properties] Properties to set + */ + function BatchRecognizeRequest(properties) { + this.files = []; + 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]]; + } + + /** + * BatchRecognizeRequest recognizer. + * @member {string} recognizer + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @instance + */ + BatchRecognizeRequest.prototype.recognizer = ""; + + /** + * BatchRecognizeRequest config. + * @member {google.cloud.speech.v2.IRecognitionConfig|null|undefined} config + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @instance + */ + BatchRecognizeRequest.prototype.config = null; + + /** + * BatchRecognizeRequest configMask. + * @member {google.protobuf.IFieldMask|null|undefined} configMask + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @instance + */ + BatchRecognizeRequest.prototype.configMask = null; + + /** + * BatchRecognizeRequest files. + * @member {Array.} files + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @instance + */ + BatchRecognizeRequest.prototype.files = $util.emptyArray; + + /** + * Creates a new BatchRecognizeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeRequest} BatchRecognizeRequest instance + */ + BatchRecognizeRequest.create = function create(properties) { + return new BatchRecognizeRequest(properties); + }; + + /** + * Encodes the specified BatchRecognizeRequest message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeRequest} message BatchRecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recognizer != null && Object.hasOwnProperty.call(message, "recognizer")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.recognizer); + if (message.files != null && message.files.length) + for (var i = 0; i < message.files.length; ++i) + $root.google.cloud.speech.v2.BatchRecognizeFileMetadata.encode(message.files[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.cloud.speech.v2.RecognitionConfig.encode(message.config, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.configMask != null && Object.hasOwnProperty.call(message, "configMask")) + $root.google.protobuf.FieldMask.encode(message.configMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchRecognizeRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeRequest} message BatchRecognizeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeRequest} BatchRecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeRequest.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.v2.BatchRecognizeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recognizer = reader.string(); + break; + } + case 4: { + message.config = $root.google.cloud.speech.v2.RecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 5: { + message.configMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.files && message.files.length)) + message.files = []; + message.files.push($root.google.cloud.speech.v2.BatchRecognizeFileMetadata.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeRequest} BatchRecognizeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeRequest message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + if (!$util.isString(message.recognizer)) + return "recognizer: string expected"; + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.cloud.speech.v2.RecognitionConfig.verify(message.config); + if (error) + return "config." + error; + } + if (message.configMask != null && message.hasOwnProperty("configMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.configMask); + if (error) + return "configMask." + error; + } + if (message.files != null && message.hasOwnProperty("files")) { + if (!Array.isArray(message.files)) + return "files: array expected"; + for (var i = 0; i < message.files.length; ++i) { + var error = $root.google.cloud.speech.v2.BatchRecognizeFileMetadata.verify(message.files[i]); + if (error) + return "files." + error; + } + } + return null; + }; + + /** + * Creates a BatchRecognizeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeRequest} BatchRecognizeRequest + */ + BatchRecognizeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeRequest) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeRequest(); + if (object.recognizer != null) + message.recognizer = String(object.recognizer); + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeRequest.config: object expected"); + message.config = $root.google.cloud.speech.v2.RecognitionConfig.fromObject(object.config); + } + if (object.configMask != null) { + if (typeof object.configMask !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeRequest.configMask: object expected"); + message.configMask = $root.google.protobuf.FieldMask.fromObject(object.configMask); + } + if (object.files) { + if (!Array.isArray(object.files)) + throw TypeError(".google.cloud.speech.v2.BatchRecognizeRequest.files: array expected"); + message.files = []; + for (var i = 0; i < object.files.length; ++i) { + if (typeof object.files[i] !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeRequest.files: object expected"); + message.files[i] = $root.google.cloud.speech.v2.BatchRecognizeFileMetadata.fromObject(object.files[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {google.cloud.speech.v2.BatchRecognizeRequest} message BatchRecognizeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.files = []; + if (options.defaults) { + object.recognizer = ""; + object.config = null; + object.configMask = null; + } + if (message.recognizer != null && message.hasOwnProperty("recognizer")) + object.recognizer = message.recognizer; + if (message.files && message.files.length) { + object.files = []; + for (var j = 0; j < message.files.length; ++j) + object.files[j] = $root.google.cloud.speech.v2.BatchRecognizeFileMetadata.toObject(message.files[j], options); + } + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.cloud.speech.v2.RecognitionConfig.toObject(message.config, options); + if (message.configMask != null && message.hasOwnProperty("configMask")) + object.configMask = $root.google.protobuf.FieldMask.toObject(message.configMask, options); + return object; + }; + + /** + * Converts this BatchRecognizeRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeRequest"; + }; + + return BatchRecognizeRequest; + })(); + + v2.BatchRecognizeResponse = (function() { + + /** + * Properties of a BatchRecognizeResponse. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeResponse + * @property {Object.|null} [results] BatchRecognizeResponse results + */ + + /** + * Constructs a new BatchRecognizeResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeResponse. + * @implements IBatchRecognizeResponse + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeResponse=} [properties] Properties to set + */ + function BatchRecognizeResponse(properties) { + this.results = {}; + 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]]; + } + + /** + * BatchRecognizeResponse results. + * @member {Object.} results + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @instance + */ + BatchRecognizeResponse.prototype.results = $util.emptyObject; + + /** + * Creates a new BatchRecognizeResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeResponse} BatchRecognizeResponse instance + */ + BatchRecognizeResponse.create = function create(properties) { + return new BatchRecognizeResponse(properties); + }; + + /** + * Encodes the specified BatchRecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeResponse} message BatchRecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && Object.hasOwnProperty.call(message, "results")) + for (var keys = Object.keys(message.results), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.speech.v2.BatchRecognizeFileResult.encode(message.results[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified BatchRecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeResponse} message BatchRecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeResponse} BatchRecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeResponse.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.v2.BatchRecognizeResponse(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (message.results === $util.emptyObject) + message.results = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.cloud.speech.v2.BatchRecognizeFileResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.results[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeResponse} BatchRecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeResponse message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!$util.isObject(message.results)) + return "results: object expected"; + var key = Object.keys(message.results); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.speech.v2.BatchRecognizeFileResult.verify(message.results[key[i]]); + if (error) + return "results." + error; + } + } + return null; + }; + + /** + * Creates a BatchRecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeResponse} BatchRecognizeResponse + */ + BatchRecognizeResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeResponse) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeResponse(); + if (object.results) { + if (typeof object.results !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeResponse.results: object expected"); + message.results = {}; + for (var keys = Object.keys(object.results), i = 0; i < keys.length; ++i) { + if (typeof object.results[keys[i]] !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeResponse.results: object expected"); + message.results[keys[i]] = $root.google.cloud.speech.v2.BatchRecognizeFileResult.fromObject(object.results[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {google.cloud.speech.v2.BatchRecognizeResponse} message BatchRecognizeResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.results = {}; + var keys2; + if (message.results && (keys2 = Object.keys(message.results)).length) { + object.results = {}; + for (var j = 0; j < keys2.length; ++j) + object.results[keys2[j]] = $root.google.cloud.speech.v2.BatchRecognizeFileResult.toObject(message.results[keys2[j]], options); + } + return object; + }; + + /** + * Converts this BatchRecognizeResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeResponse"; + }; + + return BatchRecognizeResponse; + })(); + + v2.BatchRecognizeFileResult = (function() { + + /** + * Properties of a BatchRecognizeFileResult. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeFileResult + * @property {string|null} [uri] BatchRecognizeFileResult uri + * @property {google.rpc.IStatus|null} [error] BatchRecognizeFileResult error + */ + + /** + * Constructs a new BatchRecognizeFileResult. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeFileResult. + * @implements IBatchRecognizeFileResult + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeFileResult=} [properties] Properties to set + */ + function BatchRecognizeFileResult(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]]; + } + + /** + * BatchRecognizeFileResult uri. + * @member {string} uri + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @instance + */ + BatchRecognizeFileResult.prototype.uri = ""; + + /** + * BatchRecognizeFileResult error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @instance + */ + BatchRecognizeFileResult.prototype.error = null; + + /** + * Creates a new BatchRecognizeFileResult instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileResult=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeFileResult} BatchRecognizeFileResult instance + */ + BatchRecognizeFileResult.create = function create(properties) { + return new BatchRecognizeFileResult(properties); + }; + + /** + * Encodes the specified BatchRecognizeFileResult message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileResult} message BatchRecognizeFileResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeFileResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri); + if (message.error != null && Object.hasOwnProperty.call(message, "error")) + $root.google.rpc.Status.encode(message.error, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchRecognizeFileResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileResult} message BatchRecognizeFileResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeFileResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeFileResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeFileResult} BatchRecognizeFileResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeFileResult.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.v2.BatchRecognizeFileResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.uri = reader.string(); + break; + } + case 2: { + message.error = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeFileResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeFileResult} BatchRecognizeFileResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeFileResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeFileResult message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeFileResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.error != null && message.hasOwnProperty("error")) { + var error = $root.google.rpc.Status.verify(message.error); + if (error) + return "error." + error; + } + return null; + }; + + /** + * Creates a BatchRecognizeFileResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeFileResult} BatchRecognizeFileResult + */ + BatchRecognizeFileResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeFileResult) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeFileResult(); + if (object.uri != null) + message.uri = String(object.uri); + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeFileResult.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeFileResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {google.cloud.speech.v2.BatchRecognizeFileResult} message BatchRecognizeFileResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeFileResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.uri = ""; + object.error = null; + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.error != null && message.hasOwnProperty("error")) + object.error = $root.google.rpc.Status.toObject(message.error, options); + return object; + }; + + /** + * Converts this BatchRecognizeFileResult to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeFileResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeFileResult + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeFileResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeFileResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeFileResult"; + }; + + return BatchRecognizeFileResult; + })(); + + v2.BatchRecognizeTranscriptionMetadata = (function() { + + /** + * Properties of a BatchRecognizeTranscriptionMetadata. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeTranscriptionMetadata + * @property {number|null} [progressPercent] BatchRecognizeTranscriptionMetadata progressPercent + * @property {google.rpc.IStatus|null} [error] BatchRecognizeTranscriptionMetadata error + * @property {string|null} [uri] BatchRecognizeTranscriptionMetadata uri + */ + + /** + * Constructs a new BatchRecognizeTranscriptionMetadata. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeTranscriptionMetadata. + * @implements IBatchRecognizeTranscriptionMetadata + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata=} [properties] Properties to set + */ + function BatchRecognizeTranscriptionMetadata(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]]; + } + + /** + * BatchRecognizeTranscriptionMetadata progressPercent. + * @member {number} progressPercent + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @instance + */ + BatchRecognizeTranscriptionMetadata.prototype.progressPercent = 0; + + /** + * BatchRecognizeTranscriptionMetadata error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @instance + */ + BatchRecognizeTranscriptionMetadata.prototype.error = null; + + /** + * BatchRecognizeTranscriptionMetadata uri. + * @member {string} uri + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @instance + */ + BatchRecognizeTranscriptionMetadata.prototype.uri = ""; + + /** + * Creates a new BatchRecognizeTranscriptionMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata} BatchRecognizeTranscriptionMetadata instance + */ + BatchRecognizeTranscriptionMetadata.create = function create(properties) { + return new BatchRecognizeTranscriptionMetadata(properties); + }; + + /** + * Encodes the specified BatchRecognizeTranscriptionMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata} message BatchRecognizeTranscriptionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeTranscriptionMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.progressPercent != null && Object.hasOwnProperty.call(message, "progressPercent")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.progressPercent); + if (message.error != null && Object.hasOwnProperty.call(message, "error")) + $root.google.rpc.Status.encode(message.error, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); + return writer; + }; + + /** + * Encodes the specified BatchRecognizeTranscriptionMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeTranscriptionMetadata} message BatchRecognizeTranscriptionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeTranscriptionMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeTranscriptionMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata} BatchRecognizeTranscriptionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeTranscriptionMetadata.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.v2.BatchRecognizeTranscriptionMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.progressPercent = reader.int32(); + break; + } + case 2: { + message.error = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; + } + case 3: { + message.uri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeTranscriptionMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata} BatchRecognizeTranscriptionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeTranscriptionMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeTranscriptionMetadata message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeTranscriptionMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + if (!$util.isInteger(message.progressPercent)) + return "progressPercent: integer expected"; + if (message.error != null && message.hasOwnProperty("error")) { + var error = $root.google.rpc.Status.verify(message.error); + if (error) + return "error." + error; + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + return null; + }; + + /** + * Creates a BatchRecognizeTranscriptionMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata} BatchRecognizeTranscriptionMetadata + */ + BatchRecognizeTranscriptionMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata(); + if (object.progressPercent != null) + message.progressPercent = object.progressPercent | 0; + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + if (object.uri != null) + message.uri = String(object.uri); + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeTranscriptionMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata} message BatchRecognizeTranscriptionMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeTranscriptionMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.progressPercent = 0; + object.error = null; + object.uri = ""; + } + if (message.progressPercent != null && message.hasOwnProperty("progressPercent")) + object.progressPercent = message.progressPercent; + if (message.error != null && message.hasOwnProperty("error")) + object.error = $root.google.rpc.Status.toObject(message.error, options); + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + return object; + }; + + /** + * Converts this BatchRecognizeTranscriptionMetadata to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeTranscriptionMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeTranscriptionMetadata + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeTranscriptionMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata"; + }; + + return BatchRecognizeTranscriptionMetadata; + })(); + + v2.BatchRecognizeMetadata = (function() { + + /** + * Properties of a BatchRecognizeMetadata. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeMetadata + * @property {Object.|null} [transcriptionMetadata] BatchRecognizeMetadata transcriptionMetadata + */ + + /** + * Constructs a new BatchRecognizeMetadata. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeMetadata. + * @implements IBatchRecognizeMetadata + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeMetadata=} [properties] Properties to set + */ + function BatchRecognizeMetadata(properties) { + this.transcriptionMetadata = {}; + 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]]; + } + + /** + * BatchRecognizeMetadata transcriptionMetadata. + * @member {Object.} transcriptionMetadata + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @instance + */ + BatchRecognizeMetadata.prototype.transcriptionMetadata = $util.emptyObject; + + /** + * Creates a new BatchRecognizeMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeMetadata=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeMetadata} BatchRecognizeMetadata instance + */ + BatchRecognizeMetadata.create = function create(properties) { + return new BatchRecognizeMetadata(properties); + }; + + /** + * Encodes the specified BatchRecognizeMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeMetadata} message BatchRecognizeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transcriptionMetadata != null && Object.hasOwnProperty.call(message, "transcriptionMetadata")) + for (var keys = Object.keys(message.transcriptionMetadata), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.encode(message.transcriptionMetadata[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified BatchRecognizeMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeMetadata} message BatchRecognizeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeMetadata} BatchRecognizeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeMetadata.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.v2.BatchRecognizeMetadata(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (message.transcriptionMetadata === $util.emptyObject) + message.transcriptionMetadata = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.transcriptionMetadata[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeMetadata} BatchRecognizeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeMetadata message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.transcriptionMetadata != null && message.hasOwnProperty("transcriptionMetadata")) { + if (!$util.isObject(message.transcriptionMetadata)) + return "transcriptionMetadata: object expected"; + var key = Object.keys(message.transcriptionMetadata); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.verify(message.transcriptionMetadata[key[i]]); + if (error) + return "transcriptionMetadata." + error; + } + } + return null; + }; + + /** + * Creates a BatchRecognizeMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeMetadata} BatchRecognizeMetadata + */ + BatchRecognizeMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeMetadata) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeMetadata(); + if (object.transcriptionMetadata) { + if (typeof object.transcriptionMetadata !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeMetadata.transcriptionMetadata: object expected"); + message.transcriptionMetadata = {}; + for (var keys = Object.keys(object.transcriptionMetadata), i = 0; i < keys.length; ++i) { + if (typeof object.transcriptionMetadata[keys[i]] !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeMetadata.transcriptionMetadata: object expected"); + message.transcriptionMetadata[keys[i]] = $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.fromObject(object.transcriptionMetadata[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {google.cloud.speech.v2.BatchRecognizeMetadata} message BatchRecognizeMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.transcriptionMetadata = {}; + var keys2; + if (message.transcriptionMetadata && (keys2 = Object.keys(message.transcriptionMetadata)).length) { + object.transcriptionMetadata = {}; + for (var j = 0; j < keys2.length; ++j) + object.transcriptionMetadata[keys2[j]] = $root.google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata.toObject(message.transcriptionMetadata[keys2[j]], options); + } + return object; + }; + + /** + * Converts this BatchRecognizeMetadata to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeMetadata + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeMetadata"; + }; + + return BatchRecognizeMetadata; + })(); + + v2.BatchRecognizeFileMetadata = (function() { + + /** + * Properties of a BatchRecognizeFileMetadata. + * @memberof google.cloud.speech.v2 + * @interface IBatchRecognizeFileMetadata + * @property {string|null} [uri] BatchRecognizeFileMetadata uri + * @property {google.cloud.speech.v2.IRecognitionConfig|null} [config] BatchRecognizeFileMetadata config + * @property {google.protobuf.IFieldMask|null} [configMask] BatchRecognizeFileMetadata configMask + */ + + /** + * Constructs a new BatchRecognizeFileMetadata. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a BatchRecognizeFileMetadata. + * @implements IBatchRecognizeFileMetadata + * @constructor + * @param {google.cloud.speech.v2.IBatchRecognizeFileMetadata=} [properties] Properties to set + */ + function BatchRecognizeFileMetadata(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]]; + } + + /** + * BatchRecognizeFileMetadata uri. + * @member {string|null|undefined} uri + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @instance + */ + BatchRecognizeFileMetadata.prototype.uri = null; + + /** + * BatchRecognizeFileMetadata config. + * @member {google.cloud.speech.v2.IRecognitionConfig|null|undefined} config + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @instance + */ + BatchRecognizeFileMetadata.prototype.config = null; + + /** + * BatchRecognizeFileMetadata configMask. + * @member {google.protobuf.IFieldMask|null|undefined} configMask + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @instance + */ + BatchRecognizeFileMetadata.prototype.configMask = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchRecognizeFileMetadata audioSource. + * @member {"uri"|undefined} audioSource + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @instance + */ + Object.defineProperty(BatchRecognizeFileMetadata.prototype, "audioSource", { + get: $util.oneOfGetter($oneOfFields = ["uri"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BatchRecognizeFileMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileMetadata=} [properties] Properties to set + * @returns {google.cloud.speech.v2.BatchRecognizeFileMetadata} BatchRecognizeFileMetadata instance + */ + BatchRecognizeFileMetadata.create = function create(properties) { + return new BatchRecognizeFileMetadata(properties); + }; + + /** + * Encodes the specified BatchRecognizeFileMetadata message. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileMetadata} message BatchRecognizeFileMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeFileMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.cloud.speech.v2.RecognitionConfig.encode(message.config, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.configMask != null && Object.hasOwnProperty.call(message, "configMask")) + $root.google.protobuf.FieldMask.encode(message.configMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchRecognizeFileMetadata message, length delimited. Does not implicitly {@link google.cloud.speech.v2.BatchRecognizeFileMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {google.cloud.speech.v2.IBatchRecognizeFileMetadata} message BatchRecognizeFileMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRecognizeFileMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRecognizeFileMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.BatchRecognizeFileMetadata} BatchRecognizeFileMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeFileMetadata.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.v2.BatchRecognizeFileMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.uri = reader.string(); + break; + } + case 4: { + message.config = $root.google.cloud.speech.v2.RecognitionConfig.decode(reader, reader.uint32()); + break; + } + case 5: { + message.configMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRecognizeFileMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.BatchRecognizeFileMetadata} BatchRecognizeFileMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRecognizeFileMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRecognizeFileMetadata message. + * @function verify + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRecognizeFileMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.uri != null && message.hasOwnProperty("uri")) { + properties.audioSource = 1; + if (!$util.isString(message.uri)) + return "uri: string expected"; + } + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.cloud.speech.v2.RecognitionConfig.verify(message.config); + if (error) + return "config." + error; + } + if (message.configMask != null && message.hasOwnProperty("configMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.configMask); + if (error) + return "configMask." + error; + } + return null; + }; + + /** + * Creates a BatchRecognizeFileMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.BatchRecognizeFileMetadata} BatchRecognizeFileMetadata + */ + BatchRecognizeFileMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.BatchRecognizeFileMetadata) + return object; + var message = new $root.google.cloud.speech.v2.BatchRecognizeFileMetadata(); + if (object.uri != null) + message.uri = String(object.uri); + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeFileMetadata.config: object expected"); + message.config = $root.google.cloud.speech.v2.RecognitionConfig.fromObject(object.config); + } + if (object.configMask != null) { + if (typeof object.configMask !== "object") + throw TypeError(".google.cloud.speech.v2.BatchRecognizeFileMetadata.configMask: object expected"); + message.configMask = $root.google.protobuf.FieldMask.fromObject(object.configMask); + } + return message; + }; + + /** + * Creates a plain object from a BatchRecognizeFileMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {google.cloud.speech.v2.BatchRecognizeFileMetadata} message BatchRecognizeFileMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRecognizeFileMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.config = null; + object.configMask = null; + } + if (message.uri != null && message.hasOwnProperty("uri")) { + object.uri = message.uri; + if (options.oneofs) + object.audioSource = "uri"; + } + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.cloud.speech.v2.RecognitionConfig.toObject(message.config, options); + if (message.configMask != null && message.hasOwnProperty("configMask")) + object.configMask = $root.google.protobuf.FieldMask.toObject(message.configMask, options); + return object; + }; + + /** + * Converts this BatchRecognizeFileMetadata to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @instance + * @returns {Object.} JSON object + */ + BatchRecognizeFileMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRecognizeFileMetadata + * @function getTypeUrl + * @memberof google.cloud.speech.v2.BatchRecognizeFileMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRecognizeFileMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.BatchRecognizeFileMetadata"; + }; + + return BatchRecognizeFileMetadata; + })(); + + v2.StreamingRecognitionResult = (function() { + + /** + * Properties of a StreamingRecognitionResult. + * @memberof google.cloud.speech.v2 + * @interface IStreamingRecognitionResult + * @property {Array.|null} [alternatives] StreamingRecognitionResult alternatives + * @property {boolean|null} [isFinal] StreamingRecognitionResult isFinal + * @property {number|null} [stability] StreamingRecognitionResult stability + * @property {google.protobuf.IDuration|null} [resultEndOffset] StreamingRecognitionResult resultEndOffset + * @property {number|null} [channelTag] StreamingRecognitionResult channelTag + * @property {string|null} [languageCode] StreamingRecognitionResult languageCode + */ + + /** + * Constructs a new StreamingRecognitionResult. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a StreamingRecognitionResult. + * @implements IStreamingRecognitionResult + * @constructor + * @param {google.cloud.speech.v2.IStreamingRecognitionResult=} [properties] Properties to set + */ + function StreamingRecognitionResult(properties) { + this.alternatives = []; + 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]]; + } + + /** + * StreamingRecognitionResult alternatives. + * @member {Array.} alternatives + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.alternatives = $util.emptyArray; + + /** + * StreamingRecognitionResult isFinal. + * @member {boolean} isFinal + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.isFinal = false; + + /** + * StreamingRecognitionResult stability. + * @member {number} stability + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.stability = 0; + + /** + * StreamingRecognitionResult resultEndOffset. + * @member {google.protobuf.IDuration|null|undefined} resultEndOffset + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.resultEndOffset = null; + + /** + * StreamingRecognitionResult channelTag. + * @member {number} channelTag + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.channelTag = 0; + + /** + * StreamingRecognitionResult languageCode. + * @member {string} languageCode + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + */ + StreamingRecognitionResult.prototype.languageCode = ""; + + /** + * Creates a new StreamingRecognitionResult instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionResult=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognitionResult} StreamingRecognitionResult instance + */ + StreamingRecognitionResult.create = function create(properties) { + return new StreamingRecognitionResult(properties); + }; + + /** + * Encodes the specified StreamingRecognitionResult message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionResult} message StreamingRecognitionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.alternatives != null && message.alternatives.length) + for (var i = 0; i < message.alternatives.length; ++i) + $root.google.cloud.speech.v2.SpeechRecognitionAlternative.encode(message.alternatives[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.isFinal != null && Object.hasOwnProperty.call(message, "isFinal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.isFinal); + if (message.stability != null && Object.hasOwnProperty.call(message, "stability")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.stability); + if (message.resultEndOffset != null && Object.hasOwnProperty.call(message, "resultEndOffset")) + $root.google.protobuf.Duration.encode(message.resultEndOffset, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.channelTag != null && Object.hasOwnProperty.call(message, "channelTag")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.channelTag); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.languageCode); + return writer; + }; + + /** + * Encodes the specified StreamingRecognitionResult message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognitionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {google.cloud.speech.v2.IStreamingRecognitionResult} message StreamingRecognitionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognitionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingRecognitionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognitionResult} StreamingRecognitionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionResult.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.v2.StreamingRecognitionResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.alternatives && message.alternatives.length)) + message.alternatives = []; + message.alternatives.push($root.google.cloud.speech.v2.SpeechRecognitionAlternative.decode(reader, reader.uint32())); + break; + } + case 2: { + message.isFinal = reader.bool(); + break; + } + case 3: { + message.stability = reader.float(); + break; + } + case 4: { + message.resultEndOffset = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 5: { + message.channelTag = reader.int32(); + break; + } + case 6: { + message.languageCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingRecognitionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognitionResult} StreamingRecognitionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognitionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingRecognitionResult message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingRecognitionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.alternatives != null && message.hasOwnProperty("alternatives")) { + if (!Array.isArray(message.alternatives)) + return "alternatives: array expected"; + for (var i = 0; i < message.alternatives.length; ++i) { + var error = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.verify(message.alternatives[i]); + if (error) + return "alternatives." + error; + } + } + if (message.isFinal != null && message.hasOwnProperty("isFinal")) + if (typeof message.isFinal !== "boolean") + return "isFinal: boolean expected"; + if (message.stability != null && message.hasOwnProperty("stability")) + if (typeof message.stability !== "number") + return "stability: number expected"; + if (message.resultEndOffset != null && message.hasOwnProperty("resultEndOffset")) { + var error = $root.google.protobuf.Duration.verify(message.resultEndOffset); + if (error) + return "resultEndOffset." + error; + } + if (message.channelTag != null && message.hasOwnProperty("channelTag")) + if (!$util.isInteger(message.channelTag)) + return "channelTag: integer expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + return null; + }; + + /** + * Creates a StreamingRecognitionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognitionResult} StreamingRecognitionResult + */ + StreamingRecognitionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognitionResult) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognitionResult(); + if (object.alternatives) { + if (!Array.isArray(object.alternatives)) + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionResult.alternatives: array expected"); + message.alternatives = []; + for (var i = 0; i < object.alternatives.length; ++i) { + if (typeof object.alternatives[i] !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionResult.alternatives: object expected"); + message.alternatives[i] = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.fromObject(object.alternatives[i]); + } + } + if (object.isFinal != null) + message.isFinal = Boolean(object.isFinal); + if (object.stability != null) + message.stability = Number(object.stability); + if (object.resultEndOffset != null) { + if (typeof object.resultEndOffset !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognitionResult.resultEndOffset: object expected"); + message.resultEndOffset = $root.google.protobuf.Duration.fromObject(object.resultEndOffset); + } + if (object.channelTag != null) + message.channelTag = object.channelTag | 0; + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + return message; + }; + + /** + * Creates a plain object from a StreamingRecognitionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {google.cloud.speech.v2.StreamingRecognitionResult} message StreamingRecognitionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamingRecognitionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.alternatives = []; + if (options.defaults) { + object.isFinal = false; + object.stability = 0; + object.resultEndOffset = null; + object.channelTag = 0; + object.languageCode = ""; + } + if (message.alternatives && message.alternatives.length) { + object.alternatives = []; + for (var j = 0; j < message.alternatives.length; ++j) + object.alternatives[j] = $root.google.cloud.speech.v2.SpeechRecognitionAlternative.toObject(message.alternatives[j], options); + } + if (message.isFinal != null && message.hasOwnProperty("isFinal")) + object.isFinal = message.isFinal; + if (message.stability != null && message.hasOwnProperty("stability")) + object.stability = options.json && !isFinite(message.stability) ? String(message.stability) : message.stability; + if (message.resultEndOffset != null && message.hasOwnProperty("resultEndOffset")) + object.resultEndOffset = $root.google.protobuf.Duration.toObject(message.resultEndOffset, options); + if (message.channelTag != null && message.hasOwnProperty("channelTag")) + object.channelTag = message.channelTag; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + return object; + }; + + /** + * Converts this StreamingRecognitionResult to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @instance + * @returns {Object.} JSON object + */ + StreamingRecognitionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamingRecognitionResult + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognitionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamingRecognitionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognitionResult"; + }; + + return StreamingRecognitionResult; + })(); + + v2.StreamingRecognizeResponse = (function() { + + /** + * Properties of a StreamingRecognizeResponse. + * @memberof google.cloud.speech.v2 + * @interface IStreamingRecognizeResponse + * @property {Array.|null} [results] StreamingRecognizeResponse results + * @property {google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType|null} [speechEventType] StreamingRecognizeResponse speechEventType + * @property {google.protobuf.IDuration|null} [speechEventOffset] StreamingRecognizeResponse speechEventOffset + * @property {google.cloud.speech.v2.IRecognitionResponseMetadata|null} [metadata] StreamingRecognizeResponse metadata + */ + + /** + * Constructs a new StreamingRecognizeResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a StreamingRecognizeResponse. + * @implements IStreamingRecognizeResponse + * @constructor + * @param {google.cloud.speech.v2.IStreamingRecognizeResponse=} [properties] Properties to set + */ + function StreamingRecognizeResponse(properties) { + this.results = []; + 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]]; + } + + /** + * StreamingRecognizeResponse results. + * @member {Array.} results + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.results = $util.emptyArray; + + /** + * StreamingRecognizeResponse speechEventType. + * @member {google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType} speechEventType + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.speechEventType = 0; + + /** + * StreamingRecognizeResponse speechEventOffset. + * @member {google.protobuf.IDuration|null|undefined} speechEventOffset + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.speechEventOffset = null; + + /** + * StreamingRecognizeResponse metadata. + * @member {google.cloud.speech.v2.IRecognitionResponseMetadata|null|undefined} metadata + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.metadata = null; + + /** + * Creates a new StreamingRecognizeResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.StreamingRecognizeResponse} StreamingRecognizeResponse instance + */ + StreamingRecognizeResponse.create = function create(properties) { + return new StreamingRecognizeResponse(properties); + }; + + /** + * Encodes the specified StreamingRecognizeResponse message. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeResponse} message StreamingRecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognizeResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.speechEventType != null && Object.hasOwnProperty.call(message, "speechEventType")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.speechEventType); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.google.cloud.speech.v2.RecognitionResponseMetadata.encode(message.metadata, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.speech.v2.StreamingRecognitionResult.encode(message.results[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.speechEventOffset != null && Object.hasOwnProperty.call(message, "speechEventOffset")) + $root.google.protobuf.Duration.encode(message.speechEventOffset, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingRecognizeResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.StreamingRecognizeResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {google.cloud.speech.v2.IStreamingRecognizeResponse} message StreamingRecognizeResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingRecognizeResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingRecognizeResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.StreamingRecognizeResponse} StreamingRecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognizeResponse.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.v2.StreamingRecognizeResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.speech.v2.StreamingRecognitionResult.decode(reader, reader.uint32())); + break; + } + case 3: { + message.speechEventType = reader.int32(); + break; + } + case 7: { + message.speechEventOffset = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 5: { + message.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingRecognizeResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.StreamingRecognizeResponse} StreamingRecognizeResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingRecognizeResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingRecognizeResponse message. + * @function verify + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingRecognizeResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.speech.v2.StreamingRecognitionResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.speechEventType != null && message.hasOwnProperty("speechEventType")) + switch (message.speechEventType) { + default: + return "speechEventType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.speechEventOffset != null && message.hasOwnProperty("speechEventOffset")) { + var error = $root.google.protobuf.Duration.verify(message.speechEventOffset); + if (error) + return "speechEventOffset." + error; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.google.cloud.speech.v2.RecognitionResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a StreamingRecognizeResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.StreamingRecognizeResponse} StreamingRecognizeResponse + */ + StreamingRecognizeResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.StreamingRecognizeResponse) + return object; + var message = new $root.google.cloud.speech.v2.StreamingRecognizeResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.speech.v2.StreamingRecognizeResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognizeResponse.results: object expected"); + message.results[i] = $root.google.cloud.speech.v2.StreamingRecognitionResult.fromObject(object.results[i]); + } + } + switch (object.speechEventType) { + case "SPEECH_EVENT_TYPE_UNSPECIFIED": + case 0: + message.speechEventType = 0; + break; + case "END_OF_SINGLE_UTTERANCE": + case 1: + message.speechEventType = 1; + break; + case "SPEECH_ACTIVITY_BEGIN": + case 2: + message.speechEventType = 2; + break; + case "SPEECH_ACTIVITY_END": + case 3: + message.speechEventType = 3; + break; + } + if (object.speechEventOffset != null) { + if (typeof object.speechEventOffset !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognizeResponse.speechEventOffset: object expected"); + message.speechEventOffset = $root.google.protobuf.Duration.fromObject(object.speechEventOffset); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.speech.v2.StreamingRecognizeResponse.metadata: object expected"); + message.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a StreamingRecognizeResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {google.cloud.speech.v2.StreamingRecognizeResponse} message StreamingRecognizeResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamingRecognizeResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.results = []; + if (options.defaults) { + object.speechEventType = options.enums === String ? "SPEECH_EVENT_TYPE_UNSPECIFIED" : 0; + object.metadata = null; + object.speechEventOffset = null; + } + if (message.speechEventType != null && message.hasOwnProperty("speechEventType")) + object.speechEventType = options.enums === String ? $root.google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType[message.speechEventType] : message.speechEventType; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.cloud.speech.v2.RecognitionResponseMetadata.toObject(message.metadata, options); + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.speech.v2.StreamingRecognitionResult.toObject(message.results[j], options); + } + if (message.speechEventOffset != null && message.hasOwnProperty("speechEventOffset")) + object.speechEventOffset = $root.google.protobuf.Duration.toObject(message.speechEventOffset, options); + return object; + }; + + /** + * Converts this StreamingRecognizeResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @instance + * @returns {Object.} JSON object + */ + StreamingRecognizeResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamingRecognizeResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.StreamingRecognizeResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamingRecognizeResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.StreamingRecognizeResponse"; + }; + + /** + * SpeechEventType enum. + * @name google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType + * @enum {number} + * @property {number} SPEECH_EVENT_TYPE_UNSPECIFIED=0 SPEECH_EVENT_TYPE_UNSPECIFIED value + * @property {number} END_OF_SINGLE_UTTERANCE=1 END_OF_SINGLE_UTTERANCE value + * @property {number} SPEECH_ACTIVITY_BEGIN=2 SPEECH_ACTIVITY_BEGIN value + * @property {number} SPEECH_ACTIVITY_END=3 SPEECH_ACTIVITY_END value + */ + StreamingRecognizeResponse.SpeechEventType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SPEECH_EVENT_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "END_OF_SINGLE_UTTERANCE"] = 1; + values[valuesById[2] = "SPEECH_ACTIVITY_BEGIN"] = 2; + values[valuesById[3] = "SPEECH_ACTIVITY_END"] = 3; + return values; + })(); + + return StreamingRecognizeResponse; + })(); + + v2.Config = (function() { + + /** + * Properties of a Config. + * @memberof google.cloud.speech.v2 + * @interface IConfig + * @property {string|null} [name] Config name + * @property {string|null} [kmsKeyName] Config kmsKeyName + * @property {google.protobuf.ITimestamp|null} [updateTime] Config updateTime + */ + + /** + * Constructs a new Config. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a Config. + * @implements IConfig + * @constructor + * @param {google.cloud.speech.v2.IConfig=} [properties] Properties to set + */ + function Config(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]]; + } + + /** + * Config name. + * @member {string} name + * @memberof google.cloud.speech.v2.Config + * @instance + */ + Config.prototype.name = ""; + + /** + * Config kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.speech.v2.Config + * @instance + */ + Config.prototype.kmsKeyName = ""; + + /** + * Config updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.speech.v2.Config + * @instance + */ + Config.prototype.updateTime = null; + + /** + * Creates a new Config instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.Config + * @static + * @param {google.cloud.speech.v2.IConfig=} [properties] Properties to set + * @returns {google.cloud.speech.v2.Config} Config instance + */ + Config.create = function create(properties) { + return new Config(properties); + }; + + /** + * Encodes the specified Config message. Does not implicitly {@link google.cloud.speech.v2.Config.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.Config + * @static + * @param {google.cloud.speech.v2.IConfig} message Config message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Config.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.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.kmsKeyName); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Config message, length delimited. Does not implicitly {@link google.cloud.speech.v2.Config.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.Config + * @static + * @param {google.cloud.speech.v2.IConfig} message Config message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Config.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Config message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.Config + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.Config} Config + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Config.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.v2.Config(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.kmsKeyName = reader.string(); + break; + } + case 3: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Config message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.Config + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.Config} Config + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Config.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Config message. + * @function verify + * @memberof google.cloud.speech.v2.Config + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Config.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.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + return null; + }; + + /** + * Creates a Config message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.Config + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.Config} Config + */ + Config.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.Config) + return object; + var message = new $root.google.cloud.speech.v2.Config(); + if (object.name != null) + message.name = String(object.name); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.speech.v2.Config.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from a Config message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.Config + * @static + * @param {google.cloud.speech.v2.Config} message Config + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Config.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.kmsKeyName = ""; + object.updateTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + return object; + }; + + /** + * Converts this Config to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.Config + * @instance + * @returns {Object.} JSON object + */ + Config.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Config + * @function getTypeUrl + * @memberof google.cloud.speech.v2.Config + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Config.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.Config"; + }; + + return Config; + })(); + + v2.GetConfigRequest = (function() { + + /** + * Properties of a GetConfigRequest. + * @memberof google.cloud.speech.v2 + * @interface IGetConfigRequest + * @property {string|null} [name] GetConfigRequest name + */ + + /** + * Constructs a new GetConfigRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a GetConfigRequest. + * @implements IGetConfigRequest + * @constructor + * @param {google.cloud.speech.v2.IGetConfigRequest=} [properties] Properties to set + */ + function GetConfigRequest(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]]; + } + + /** + * GetConfigRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.GetConfigRequest + * @instance + */ + GetConfigRequest.prototype.name = ""; + + /** + * Creates a new GetConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {google.cloud.speech.v2.IGetConfigRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.GetConfigRequest} GetConfigRequest instance + */ + GetConfigRequest.create = function create(properties) { + return new GetConfigRequest(properties); + }; + + /** + * Encodes the specified GetConfigRequest message. Does not implicitly {@link google.cloud.speech.v2.GetConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {google.cloud.speech.v2.IGetConfigRequest} message GetConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetConfigRequest.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); + return writer; + }; + + /** + * Encodes the specified GetConfigRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {google.cloud.speech.v2.IGetConfigRequest} message GetConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.GetConfigRequest} GetConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetConfigRequest.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.v2.GetConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.GetConfigRequest} GetConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetConfigRequest message. + * @function verify + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetConfigRequest.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"; + return null; + }; + + /** + * Creates a GetConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.GetConfigRequest} GetConfigRequest + */ + GetConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.GetConfigRequest) + return object; + var message = new $root.google.cloud.speech.v2.GetConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {google.cloud.speech.v2.GetConfigRequest} message GetConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.GetConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetConfigRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.GetConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.GetConfigRequest"; + }; + + return GetConfigRequest; + })(); + + v2.UpdateConfigRequest = (function() { + + /** + * Properties of an UpdateConfigRequest. + * @memberof google.cloud.speech.v2 + * @interface IUpdateConfigRequest + * @property {google.cloud.speech.v2.IConfig|null} [config] UpdateConfigRequest config + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateConfigRequest updateMask + */ + + /** + * Constructs a new UpdateConfigRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UpdateConfigRequest. + * @implements IUpdateConfigRequest + * @constructor + * @param {google.cloud.speech.v2.IUpdateConfigRequest=} [properties] Properties to set + */ + function UpdateConfigRequest(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]]; + } + + /** + * UpdateConfigRequest config. + * @member {google.cloud.speech.v2.IConfig|null|undefined} config + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @instance + */ + UpdateConfigRequest.prototype.config = null; + + /** + * UpdateConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @instance + */ + UpdateConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {google.cloud.speech.v2.IUpdateConfigRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UpdateConfigRequest} UpdateConfigRequest instance + */ + UpdateConfigRequest.create = function create(properties) { + return new UpdateConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateConfigRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {google.cloud.speech.v2.IUpdateConfigRequest} message UpdateConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.cloud.speech.v2.Config.encode(message.config, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateConfigRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {google.cloud.speech.v2.IUpdateConfigRequest} message UpdateConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UpdateConfigRequest} UpdateConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateConfigRequest.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.v2.UpdateConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.config = $root.google.cloud.speech.v2.Config.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UpdateConfigRequest} UpdateConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateConfigRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.cloud.speech.v2.Config.verify(message.config); + if (error) + return "config." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UpdateConfigRequest} UpdateConfigRequest + */ + UpdateConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UpdateConfigRequest) + return object; + var message = new $root.google.cloud.speech.v2.UpdateConfigRequest(); + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateConfigRequest.config: object expected"); + message.config = $root.google.cloud.speech.v2.Config.fromObject(object.config); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {google.cloud.speech.v2.UpdateConfigRequest} message UpdateConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.config = null; + object.updateMask = null; + } + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.cloud.speech.v2.Config.toObject(message.config, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateConfigRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UpdateConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UpdateConfigRequest"; + }; + + return UpdateConfigRequest; + })(); + + v2.CustomClass = (function() { + + /** + * Properties of a CustomClass. + * @memberof google.cloud.speech.v2 + * @interface ICustomClass + * @property {string|null} [name] CustomClass name + * @property {string|null} [uid] CustomClass uid + * @property {string|null} [displayName] CustomClass displayName + * @property {Array.|null} [items] CustomClass items + * @property {google.cloud.speech.v2.CustomClass.State|null} [state] CustomClass state + * @property {google.protobuf.ITimestamp|null} [createTime] CustomClass createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] CustomClass updateTime + * @property {google.protobuf.ITimestamp|null} [deleteTime] CustomClass deleteTime + * @property {google.protobuf.ITimestamp|null} [expireTime] CustomClass expireTime + * @property {Object.|null} [annotations] CustomClass annotations + * @property {string|null} [etag] CustomClass etag + * @property {boolean|null} [reconciling] CustomClass reconciling + * @property {string|null} [kmsKeyName] CustomClass kmsKeyName + * @property {string|null} [kmsKeyVersionName] CustomClass kmsKeyVersionName + */ + + /** + * Constructs a new CustomClass. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a CustomClass. + * @implements ICustomClass + * @constructor + * @param {google.cloud.speech.v2.ICustomClass=} [properties] Properties to set + */ + function CustomClass(properties) { + this.items = []; + this.annotations = {}; + 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.v2.CustomClass + * @instance + */ + CustomClass.prototype.name = ""; + + /** + * CustomClass uid. + * @member {string} uid + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.uid = ""; + + /** + * CustomClass displayName. + * @member {string} displayName + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.displayName = ""; + + /** + * CustomClass items. + * @member {Array.} items + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.items = $util.emptyArray; + + /** + * CustomClass state. + * @member {google.cloud.speech.v2.CustomClass.State} state + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.state = 0; + + /** + * CustomClass createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.createTime = null; + + /** + * CustomClass updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.updateTime = null; + + /** + * CustomClass deleteTime. + * @member {google.protobuf.ITimestamp|null|undefined} deleteTime + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.deleteTime = null; + + /** + * CustomClass expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.expireTime = null; + + /** + * CustomClass annotations. + * @member {Object.} annotations + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.annotations = $util.emptyObject; + + /** + * CustomClass etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.etag = ""; + + /** + * CustomClass reconciling. + * @member {boolean} reconciling + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.reconciling = false; + + /** + * CustomClass kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.kmsKeyName = ""; + + /** + * CustomClass kmsKeyVersionName. + * @member {string} kmsKeyVersionName + * @memberof google.cloud.speech.v2.CustomClass + * @instance + */ + CustomClass.prototype.kmsKeyVersionName = ""; + + /** + * Creates a new CustomClass instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {google.cloud.speech.v2.ICustomClass=} [properties] Properties to set + * @returns {google.cloud.speech.v2.CustomClass} CustomClass instance + */ + CustomClass.create = function create(properties) { + return new CustomClass(properties); + }; + + /** + * Encodes the specified CustomClass message. Does not implicitly {@link google.cloud.speech.v2.CustomClass.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {google.cloud.speech.v2.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.uid != null && Object.hasOwnProperty.call(message, "uid")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.uid); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.displayName); + if (message.items != null && message.items.length) + for (var i = 0; i < message.items.length; ++i) + $root.google.cloud.speech.v2.CustomClass.ClassItem.encode(message.items[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.deleteTime != null && Object.hasOwnProperty.call(message, "deleteTime")) + $root.google.protobuf.Timestamp.encode(message.deleteTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.annotations != null && Object.hasOwnProperty.call(message, "annotations")) + for (var keys = Object.keys(message.annotations), i = 0; i < keys.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.annotations[keys[i]]).ldelim(); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.etag); + if (message.reconciling != null && Object.hasOwnProperty.call(message, "reconciling")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.reconciling); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.kmsKeyName); + if (message.kmsKeyVersionName != null && Object.hasOwnProperty.call(message, "kmsKeyVersionName")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.kmsKeyVersionName); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 15, wireType 0 =*/120).int32(message.state); + return writer; + }; + + /** + * Encodes the specified CustomClass message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CustomClass.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {google.cloud.speech.v2.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.v2.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.v2.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.v2.CustomClass(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.uid = reader.string(); + break; + } + case 4: { + message.displayName = reader.string(); + break; + } + case 5: { + if (!(message.items && message.items.length)) + message.items = []; + message.items.push($root.google.cloud.speech.v2.CustomClass.ClassItem.decode(reader, reader.uint32())); + break; + } + case 15: { + message.state = reader.int32(); + break; + } + case 6: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 7: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 8: { + message.deleteTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 9: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + if (message.annotations === $util.emptyObject) + message.annotations = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.annotations[key] = value; + break; + } + case 11: { + message.etag = reader.string(); + break; + } + case 12: { + message.reconciling = reader.bool(); + break; + } + case 13: { + message.kmsKeyName = reader.string(); + break; + } + case 14: { + message.kmsKeyVersionName = reader.string(); + 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.v2.CustomClass + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.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.v2.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.uid != null && message.hasOwnProperty("uid")) + if (!$util.isString(message.uid)) + return "uid: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: 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.v2.CustomClass.ClassItem.verify(message.items[i]); + if (error) + return "items." + error; + } + } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 2: + case 4: + break; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.deleteTime); + if (error) + return "deleteTime." + error; + } + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + if (message.annotations != null && message.hasOwnProperty("annotations")) { + if (!$util.isObject(message.annotations)) + return "annotations: object expected"; + var key = Object.keys(message.annotations); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.annotations[key[i]])) + return "annotations: string{k:string} expected"; + } + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + if (typeof message.reconciling !== "boolean") + return "reconciling: boolean expected"; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + if (!$util.isString(message.kmsKeyVersionName)) + return "kmsKeyVersionName: string expected"; + return null; + }; + + /** + * Creates a CustomClass message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.CustomClass} CustomClass + */ + CustomClass.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.CustomClass) + return object; + var message = new $root.google.cloud.speech.v2.CustomClass(); + if (object.name != null) + message.name = String(object.name); + if (object.uid != null) + message.uid = String(object.uid); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.items) { + if (!Array.isArray(object.items)) + throw TypeError(".google.cloud.speech.v2.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.v2.CustomClass.items: object expected"); + message.items[i] = $root.google.cloud.speech.v2.CustomClass.ClassItem.fromObject(object.items[i]); + } + } + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 2: + message.state = 2; + break; + case "DELETED": + case 4: + message.state = 4; + break; + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.speech.v2.CustomClass.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.speech.v2.CustomClass.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.deleteTime != null) { + if (typeof object.deleteTime !== "object") + throw TypeError(".google.cloud.speech.v2.CustomClass.deleteTime: object expected"); + message.deleteTime = $root.google.protobuf.Timestamp.fromObject(object.deleteTime); + } + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.speech.v2.CustomClass.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.annotations) { + if (typeof object.annotations !== "object") + throw TypeError(".google.cloud.speech.v2.CustomClass.annotations: object expected"); + message.annotations = {}; + for (var keys = Object.keys(object.annotations), i = 0; i < keys.length; ++i) + message.annotations[keys[i]] = String(object.annotations[keys[i]]); + } + if (object.etag != null) + message.etag = String(object.etag); + if (object.reconciling != null) + message.reconciling = Boolean(object.reconciling); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.kmsKeyVersionName != null) + message.kmsKeyVersionName = String(object.kmsKeyVersionName); + return message; + }; + + /** + * Creates a plain object from a CustomClass message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {google.cloud.speech.v2.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.objects || options.defaults) + object.annotations = {}; + if (options.defaults) { + object.name = ""; + object.uid = ""; + object.displayName = ""; + object.createTime = null; + object.updateTime = null; + object.deleteTime = null; + object.expireTime = null; + object.etag = ""; + object.reconciling = false; + object.kmsKeyName = ""; + object.kmsKeyVersionName = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.uid != null && message.hasOwnProperty("uid")) + object.uid = message.uid; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.items && message.items.length) { + object.items = []; + for (var j = 0; j < message.items.length; ++j) + object.items[j] = $root.google.cloud.speech.v2.CustomClass.ClassItem.toObject(message.items[j], options); + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) + object.deleteTime = $root.google.protobuf.Timestamp.toObject(message.deleteTime, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + var keys2; + if (message.annotations && (keys2 = Object.keys(message.annotations)).length) { + object.annotations = {}; + for (var j = 0; j < keys2.length; ++j) + object.annotations[keys2[j]] = message.annotations[keys2[j]]; + } + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + object.reconciling = message.reconciling; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + object.kmsKeyVersionName = message.kmsKeyVersionName; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.speech.v2.CustomClass.State[message.state] : message.state; + return object; + }; + + /** + * Converts this CustomClass to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.CustomClass + * @instance + * @returns {Object.} JSON object + */ + CustomClass.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CustomClass + * @function getTypeUrl + * @memberof google.cloud.speech.v2.CustomClass + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomClass.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.CustomClass"; + }; + + CustomClass.ClassItem = (function() { + + /** + * Properties of a ClassItem. + * @memberof google.cloud.speech.v2.CustomClass + * @interface IClassItem + * @property {string|null} [value] ClassItem value + */ + + /** + * Constructs a new ClassItem. + * @memberof google.cloud.speech.v2.CustomClass + * @classdesc Represents a ClassItem. + * @implements IClassItem + * @constructor + * @param {google.cloud.speech.v2.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.v2.CustomClass.ClassItem + * @instance + */ + ClassItem.prototype.value = ""; + + /** + * Creates a new ClassItem instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v2.CustomClass.IClassItem=} [properties] Properties to set + * @returns {google.cloud.speech.v2.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.v2.CustomClass.ClassItem.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v2.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.v2.CustomClass.ClassItem.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.CustomClass.ClassItem + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.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.v2.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.v2.CustomClass.ClassItem + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.CustomClass.ClassItem} ClassItem + */ + ClassItem.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.CustomClass.ClassItem) + return object; + var message = new $root.google.cloud.speech.v2.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.v2.CustomClass.ClassItem + * @static + * @param {google.cloud.speech.v2.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.v2.CustomClass.ClassItem + * @instance + * @returns {Object.} JSON object + */ + ClassItem.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ClassItem + * @function getTypeUrl + * @memberof google.cloud.speech.v2.CustomClass.ClassItem + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClassItem.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.CustomClass.ClassItem"; + }; + + return ClassItem; + })(); + + /** + * State enum. + * @name google.cloud.speech.v2.CustomClass.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=2 ACTIVE value + * @property {number} DELETED=4 DELETED value + */ + CustomClass.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[2] = "ACTIVE"] = 2; + values[valuesById[4] = "DELETED"] = 4; + return values; + })(); + + return CustomClass; + })(); + + v2.PhraseSet = (function() { + + /** + * Properties of a PhraseSet. + * @memberof google.cloud.speech.v2 + * @interface IPhraseSet + * @property {string|null} [name] PhraseSet name + * @property {string|null} [uid] PhraseSet uid + * @property {Array.|null} [phrases] PhraseSet phrases + * @property {number|null} [boost] PhraseSet boost + * @property {string|null} [displayName] PhraseSet displayName + * @property {google.cloud.speech.v2.PhraseSet.State|null} [state] PhraseSet state + * @property {google.protobuf.ITimestamp|null} [createTime] PhraseSet createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] PhraseSet updateTime + * @property {google.protobuf.ITimestamp|null} [deleteTime] PhraseSet deleteTime + * @property {google.protobuf.ITimestamp|null} [expireTime] PhraseSet expireTime + * @property {Object.|null} [annotations] PhraseSet annotations + * @property {string|null} [etag] PhraseSet etag + * @property {boolean|null} [reconciling] PhraseSet reconciling + * @property {string|null} [kmsKeyName] PhraseSet kmsKeyName + * @property {string|null} [kmsKeyVersionName] PhraseSet kmsKeyVersionName + */ + + /** + * Constructs a new PhraseSet. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a PhraseSet. + * @implements IPhraseSet + * @constructor + * @param {google.cloud.speech.v2.IPhraseSet=} [properties] Properties to set + */ + function PhraseSet(properties) { + this.phrases = []; + this.annotations = {}; + 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.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.name = ""; + + /** + * PhraseSet uid. + * @member {string} uid + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.uid = ""; + + /** + * PhraseSet phrases. + * @member {Array.} phrases + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.phrases = $util.emptyArray; + + /** + * PhraseSet boost. + * @member {number} boost + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.boost = 0; + + /** + * PhraseSet displayName. + * @member {string} displayName + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.displayName = ""; + + /** + * PhraseSet state. + * @member {google.cloud.speech.v2.PhraseSet.State} state + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.state = 0; + + /** + * PhraseSet createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.createTime = null; + + /** + * PhraseSet updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.updateTime = null; + + /** + * PhraseSet deleteTime. + * @member {google.protobuf.ITimestamp|null|undefined} deleteTime + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.deleteTime = null; + + /** + * PhraseSet expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.expireTime = null; + + /** + * PhraseSet annotations. + * @member {Object.} annotations + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.annotations = $util.emptyObject; + + /** + * PhraseSet etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.etag = ""; + + /** + * PhraseSet reconciling. + * @member {boolean} reconciling + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.reconciling = false; + + /** + * PhraseSet kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.kmsKeyName = ""; + + /** + * PhraseSet kmsKeyVersionName. + * @member {string} kmsKeyVersionName + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + */ + PhraseSet.prototype.kmsKeyVersionName = ""; + + /** + * Creates a new PhraseSet instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.PhraseSet + * @static + * @param {google.cloud.speech.v2.IPhraseSet=} [properties] Properties to set + * @returns {google.cloud.speech.v2.PhraseSet} PhraseSet instance + */ + PhraseSet.create = function create(properties) { + return new PhraseSet(properties); + }; + + /** + * Encodes the specified PhraseSet message. Does not implicitly {@link google.cloud.speech.v2.PhraseSet.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.PhraseSet + * @static + * @param {google.cloud.speech.v2.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.uid != null && Object.hasOwnProperty.call(message, "uid")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.uid); + if (message.phrases != null && message.phrases.length) + for (var i = 0; i < message.phrases.length; ++i) + $root.google.cloud.speech.v2.PhraseSet.Phrase.encode(message.phrases[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.boost); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.displayName); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.deleteTime != null && Object.hasOwnProperty.call(message, "deleteTime")) + $root.google.protobuf.Timestamp.encode(message.deleteTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.annotations != null && Object.hasOwnProperty.call(message, "annotations")) + for (var keys = Object.keys(message.annotations), i = 0; i < keys.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.annotations[keys[i]]).ldelim(); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.etag); + if (message.reconciling != null && Object.hasOwnProperty.call(message, "reconciling")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.reconciling); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.kmsKeyName); + if (message.kmsKeyVersionName != null && Object.hasOwnProperty.call(message, "kmsKeyVersionName")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.kmsKeyVersionName); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 15, wireType 0 =*/120).int32(message.state); + return writer; + }; + + /** + * Encodes the specified PhraseSet message, length delimited. Does not implicitly {@link google.cloud.speech.v2.PhraseSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.PhraseSet + * @static + * @param {google.cloud.speech.v2.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.v2.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.v2.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.v2.PhraseSet(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.uid = reader.string(); + break; + } + case 3: { + if (!(message.phrases && message.phrases.length)) + message.phrases = []; + message.phrases.push($root.google.cloud.speech.v2.PhraseSet.Phrase.decode(reader, reader.uint32())); + break; + } + case 4: { + message.boost = reader.float(); + break; + } + case 5: { + message.displayName = reader.string(); + break; + } + case 15: { + message.state = reader.int32(); + break; + } + case 6: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 7: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 8: { + message.deleteTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 9: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + if (message.annotations === $util.emptyObject) + message.annotations = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.annotations[key] = value; + break; + } + case 11: { + message.etag = reader.string(); + break; + } + case 12: { + message.reconciling = reader.bool(); + break; + } + case 13: { + message.kmsKeyName = reader.string(); + break; + } + case 14: { + message.kmsKeyVersionName = reader.string(); + 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.v2.PhraseSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.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.v2.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.uid != null && message.hasOwnProperty("uid")) + if (!$util.isString(message.uid)) + return "uid: 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.v2.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"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 2: + case 4: + break; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.deleteTime); + if (error) + return "deleteTime." + error; + } + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + if (message.annotations != null && message.hasOwnProperty("annotations")) { + if (!$util.isObject(message.annotations)) + return "annotations: object expected"; + var key = Object.keys(message.annotations); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.annotations[key[i]])) + return "annotations: string{k:string} expected"; + } + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + if (typeof message.reconciling !== "boolean") + return "reconciling: boolean expected"; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + if (!$util.isString(message.kmsKeyVersionName)) + return "kmsKeyVersionName: string 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.v2.PhraseSet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.PhraseSet} PhraseSet + */ + PhraseSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.PhraseSet) + return object; + var message = new $root.google.cloud.speech.v2.PhraseSet(); + if (object.name != null) + message.name = String(object.name); + if (object.uid != null) + message.uid = String(object.uid); + if (object.phrases) { + if (!Array.isArray(object.phrases)) + throw TypeError(".google.cloud.speech.v2.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.v2.PhraseSet.phrases: object expected"); + message.phrases[i] = $root.google.cloud.speech.v2.PhraseSet.Phrase.fromObject(object.phrases[i]); + } + } + if (object.boost != null) + message.boost = Number(object.boost); + if (object.displayName != null) + message.displayName = String(object.displayName); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 2: + message.state = 2; + break; + case "DELETED": + case 4: + message.state = 4; + break; + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.speech.v2.PhraseSet.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.speech.v2.PhraseSet.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.deleteTime != null) { + if (typeof object.deleteTime !== "object") + throw TypeError(".google.cloud.speech.v2.PhraseSet.deleteTime: object expected"); + message.deleteTime = $root.google.protobuf.Timestamp.fromObject(object.deleteTime); + } + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.speech.v2.PhraseSet.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.annotations) { + if (typeof object.annotations !== "object") + throw TypeError(".google.cloud.speech.v2.PhraseSet.annotations: object expected"); + message.annotations = {}; + for (var keys = Object.keys(object.annotations), i = 0; i < keys.length; ++i) + message.annotations[keys[i]] = String(object.annotations[keys[i]]); + } + if (object.etag != null) + message.etag = String(object.etag); + if (object.reconciling != null) + message.reconciling = Boolean(object.reconciling); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.kmsKeyVersionName != null) + message.kmsKeyVersionName = String(object.kmsKeyVersionName); + return message; + }; + + /** + * Creates a plain object from a PhraseSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.PhraseSet + * @static + * @param {google.cloud.speech.v2.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.objects || options.defaults) + object.annotations = {}; + if (options.defaults) { + object.name = ""; + object.uid = ""; + object.boost = 0; + object.displayName = ""; + object.createTime = null; + object.updateTime = null; + object.deleteTime = null; + object.expireTime = null; + object.etag = ""; + object.reconciling = false; + object.kmsKeyName = ""; + object.kmsKeyVersionName = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.uid != null && message.hasOwnProperty("uid")) + object.uid = message.uid; + if (message.phrases && message.phrases.length) { + object.phrases = []; + for (var j = 0; j < message.phrases.length; ++j) + object.phrases[j] = $root.google.cloud.speech.v2.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; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.deleteTime != null && message.hasOwnProperty("deleteTime")) + object.deleteTime = $root.google.protobuf.Timestamp.toObject(message.deleteTime, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + var keys2; + if (message.annotations && (keys2 = Object.keys(message.annotations)).length) { + object.annotations = {}; + for (var j = 0; j < keys2.length; ++j) + object.annotations[keys2[j]] = message.annotations[keys2[j]]; + } + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.reconciling != null && message.hasOwnProperty("reconciling")) + object.reconciling = message.reconciling; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + object.kmsKeyVersionName = message.kmsKeyVersionName; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.speech.v2.PhraseSet.State[message.state] : message.state; + return object; + }; + + /** + * Converts this PhraseSet to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.PhraseSet + * @instance + * @returns {Object.} JSON object + */ + PhraseSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PhraseSet + * @function getTypeUrl + * @memberof google.cloud.speech.v2.PhraseSet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PhraseSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.PhraseSet"; + }; + + PhraseSet.Phrase = (function() { + + /** + * Properties of a Phrase. + * @memberof google.cloud.speech.v2.PhraseSet + * @interface IPhrase + * @property {string|null} [value] Phrase value + * @property {number|null} [boost] Phrase boost + */ + + /** + * Constructs a new Phrase. + * @memberof google.cloud.speech.v2.PhraseSet + * @classdesc Represents a Phrase. + * @implements IPhrase + * @constructor + * @param {google.cloud.speech.v2.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.v2.PhraseSet.Phrase + * @instance + */ + Phrase.prototype.value = ""; + + /** + * Phrase boost. + * @member {number} boost + * @memberof google.cloud.speech.v2.PhraseSet.Phrase + * @instance + */ + Phrase.prototype.boost = 0; + + /** + * Creates a new Phrase instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v2.PhraseSet.IPhrase=} [properties] Properties to set + * @returns {google.cloud.speech.v2.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.v2.PhraseSet.Phrase.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v2.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.v2.PhraseSet.Phrase.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v2.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.v2.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.v2.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.v2.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.v2.PhraseSet.Phrase + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.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.v2.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.v2.PhraseSet.Phrase + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.PhraseSet.Phrase} Phrase + */ + Phrase.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.PhraseSet.Phrase) + return object; + var message = new $root.google.cloud.speech.v2.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.v2.PhraseSet.Phrase + * @static + * @param {google.cloud.speech.v2.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.v2.PhraseSet.Phrase + * @instance + * @returns {Object.} JSON object + */ + Phrase.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Phrase + * @function getTypeUrl + * @memberof google.cloud.speech.v2.PhraseSet.Phrase + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Phrase.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.PhraseSet.Phrase"; + }; + + return Phrase; + })(); + + /** + * State enum. + * @name google.cloud.speech.v2.PhraseSet.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=2 ACTIVE value + * @property {number} DELETED=4 DELETED value + */ + PhraseSet.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[2] = "ACTIVE"] = 2; + values[valuesById[4] = "DELETED"] = 4; + return values; + })(); + + return PhraseSet; + })(); + + v2.CreateCustomClassRequest = (function() { + + /** + * Properties of a CreateCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @interface ICreateCustomClassRequest + * @property {google.cloud.speech.v2.ICustomClass|null} [customClass] CreateCustomClassRequest customClass + * @property {boolean|null} [validateOnly] CreateCustomClassRequest validateOnly + * @property {string|null} [customClassId] CreateCustomClassRequest customClassId + * @property {string|null} [parent] CreateCustomClassRequest parent + */ + + /** + * Constructs a new CreateCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a CreateCustomClassRequest. + * @implements ICreateCustomClassRequest + * @constructor + * @param {google.cloud.speech.v2.ICreateCustomClassRequest=} [properties] Properties to set + */ + function CreateCustomClassRequest(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]]; + } + + /** + * CreateCustomClassRequest customClass. + * @member {google.cloud.speech.v2.ICustomClass|null|undefined} customClass + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.customClass = null; + + /** + * CreateCustomClassRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.validateOnly = false; + + /** + * CreateCustomClassRequest customClassId. + * @member {string} customClassId + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.customClassId = ""; + + /** + * CreateCustomClassRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.parent = ""; + + /** + * Creates a new CreateCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.ICreateCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.CreateCustomClassRequest} CreateCustomClassRequest instance + */ + CreateCustomClassRequest.create = function create(properties) { + return new CreateCustomClassRequest(properties); + }; + + /** + * Encodes the specified CreateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.CreateCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.ICreateCustomClassRequest} message CreateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.customClass != null && Object.hasOwnProperty.call(message, "customClass")) + $root.google.cloud.speech.v2.CustomClass.encode(message.customClass, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.customClassId != null && Object.hasOwnProperty.call(message, "customClassId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.customClassId); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.parent); + return writer; + }; + + /** + * Encodes the specified CreateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreateCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.ICreateCustomClassRequest} message CreateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.CreateCustomClassRequest} CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCustomClassRequest.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.v2.CreateCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.customClass = $root.google.cloud.speech.v2.CustomClass.decode(reader, reader.uint32()); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.customClassId = reader.string(); + break; + } + case 4: { + message.parent = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.CreateCustomClassRequest} CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateCustomClassRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.customClass != null && message.hasOwnProperty("customClass")) { + var error = $root.google.cloud.speech.v2.CustomClass.verify(message.customClass); + if (error) + return "customClass." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + if (!$util.isString(message.customClassId)) + return "customClassId: string expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + return null; + }; + + /** + * Creates a CreateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.CreateCustomClassRequest} CreateCustomClassRequest + */ + CreateCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.CreateCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v2.CreateCustomClassRequest(); + if (object.customClass != null) { + if (typeof object.customClass !== "object") + throw TypeError(".google.cloud.speech.v2.CreateCustomClassRequest.customClass: object expected"); + message.customClass = $root.google.cloud.speech.v2.CustomClass.fromObject(object.customClass); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.customClassId != null) + message.customClassId = String(object.customClassId); + if (object.parent != null) + message.parent = String(object.parent); + return message; + }; + + /** + * Creates a plain object from a CreateCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.CreateCustomClassRequest} message CreateCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.customClass = null; + object.validateOnly = false; + object.customClassId = ""; + object.parent = ""; + } + if (message.customClass != null && message.hasOwnProperty("customClass")) + object.customClass = $root.google.cloud.speech.v2.CustomClass.toObject(message.customClass, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + object.customClassId = message.customClassId; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + return object; + }; + + /** + * Converts this CreateCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + CreateCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateCustomClassRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.CreateCustomClassRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateCustomClassRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.CreateCustomClassRequest"; + }; + + return CreateCustomClassRequest; + })(); + + v2.ListCustomClassesRequest = (function() { + + /** + * Properties of a ListCustomClassesRequest. + * @memberof google.cloud.speech.v2 + * @interface IListCustomClassesRequest + * @property {string|null} [parent] ListCustomClassesRequest parent + * @property {number|null} [pageSize] ListCustomClassesRequest pageSize + * @property {string|null} [pageToken] ListCustomClassesRequest pageToken + * @property {boolean|null} [showDeleted] ListCustomClassesRequest showDeleted + */ + + /** + * Constructs a new ListCustomClassesRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListCustomClassesRequest. + * @implements IListCustomClassesRequest + * @constructor + * @param {google.cloud.speech.v2.IListCustomClassesRequest=} [properties] Properties to set + */ + function ListCustomClassesRequest(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]]; + } + + /** + * ListCustomClassesRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.parent = ""; + + /** + * ListCustomClassesRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.pageSize = 0; + + /** + * ListCustomClassesRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.pageToken = ""; + + /** + * ListCustomClassesRequest showDeleted. + * @member {boolean} showDeleted + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.showDeleted = false; + + /** + * Creates a new ListCustomClassesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v2.IListCustomClassesRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListCustomClassesRequest} ListCustomClassesRequest instance + */ + ListCustomClassesRequest.create = function create(properties) { + return new ListCustomClassesRequest(properties); + }; + + /** + * Encodes the specified ListCustomClassesRequest message. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v2.IListCustomClassesRequest} message ListCustomClassesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.showDeleted != null && Object.hasOwnProperty.call(message, "showDeleted")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.showDeleted); + return writer; + }; + + /** + * Encodes the specified ListCustomClassesRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v2.IListCustomClassesRequest} message ListCustomClassesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListCustomClassesRequest} ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesRequest.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.v2.ListCustomClassesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.showDeleted = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListCustomClassesRequest} ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCustomClassesRequest message. + * @function verify + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCustomClassesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + if (typeof message.showDeleted !== "boolean") + return "showDeleted: boolean expected"; + return null; + }; + + /** + * Creates a ListCustomClassesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListCustomClassesRequest} ListCustomClassesRequest + */ + ListCustomClassesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListCustomClassesRequest) + return object; + var message = new $root.google.cloud.speech.v2.ListCustomClassesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.showDeleted != null) + message.showDeleted = Boolean(object.showDeleted); + return message; + }; + + /** + * Creates a plain object from a ListCustomClassesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v2.ListCustomClassesRequest} message ListCustomClassesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCustomClassesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.showDeleted = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + object.showDeleted = message.showDeleted; + return object; + }; + + /** + * Converts this ListCustomClassesRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @instance + * @returns {Object.} JSON object + */ + ListCustomClassesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCustomClassesRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListCustomClassesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCustomClassesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListCustomClassesRequest"; + }; + + return ListCustomClassesRequest; + })(); + + v2.ListCustomClassesResponse = (function() { + + /** + * Properties of a ListCustomClassesResponse. + * @memberof google.cloud.speech.v2 + * @interface IListCustomClassesResponse + * @property {Array.|null} [customClasses] ListCustomClassesResponse customClasses + * @property {string|null} [nextPageToken] ListCustomClassesResponse nextPageToken + */ + + /** + * Constructs a new ListCustomClassesResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListCustomClassesResponse. + * @implements IListCustomClassesResponse + * @constructor + * @param {google.cloud.speech.v2.IListCustomClassesResponse=} [properties] Properties to set + */ + function ListCustomClassesResponse(properties) { + 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]]; + } + + /** + * ListCustomClassesResponse customClasses. + * @member {Array.} customClasses + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @instance + */ + ListCustomClassesResponse.prototype.customClasses = $util.emptyArray; + + /** + * ListCustomClassesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @instance + */ + ListCustomClassesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListCustomClassesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v2.IListCustomClassesResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListCustomClassesResponse} ListCustomClassesResponse instance + */ + ListCustomClassesResponse.create = function create(properties) { + return new ListCustomClassesResponse(properties); + }; + + /** + * Encodes the specified ListCustomClassesResponse message. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v2.IListCustomClassesResponse} message ListCustomClassesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.customClasses != null && message.customClasses.length) + for (var i = 0; i < message.customClasses.length; ++i) + $root.google.cloud.speech.v2.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListCustomClassesResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListCustomClassesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v2.IListCustomClassesResponse} message ListCustomClassesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListCustomClassesResponse} ListCustomClassesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesResponse.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.v2.ListCustomClassesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.customClasses && message.customClasses.length)) + message.customClasses = []; + message.customClasses.push($root.google.cloud.speech.v2.CustomClass.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListCustomClassesResponse} ListCustomClassesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCustomClassesResponse message. + * @function verify + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCustomClassesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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.v2.CustomClass.verify(message.customClasses[i]); + if (error) + return "customClasses." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListCustomClassesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListCustomClassesResponse} ListCustomClassesResponse + */ + ListCustomClassesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListCustomClassesResponse) + return object; + var message = new $root.google.cloud.speech.v2.ListCustomClassesResponse(); + if (object.customClasses) { + if (!Array.isArray(object.customClasses)) + throw TypeError(".google.cloud.speech.v2.ListCustomClassesResponse.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.v2.ListCustomClassesResponse.customClasses: object expected"); + message.customClasses[i] = $root.google.cloud.speech.v2.CustomClass.fromObject(object.customClasses[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCustomClassesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v2.ListCustomClassesResponse} message ListCustomClassesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCustomClassesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.customClasses = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.customClasses && message.customClasses.length) { + object.customClasses = []; + for (var j = 0; j < message.customClasses.length; ++j) + object.customClasses[j] = $root.google.cloud.speech.v2.CustomClass.toObject(message.customClasses[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCustomClassesResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @instance + * @returns {Object.} JSON object + */ + ListCustomClassesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCustomClassesResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListCustomClassesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCustomClassesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListCustomClassesResponse"; + }; + + return ListCustomClassesResponse; + })(); + + v2.GetCustomClassRequest = (function() { + + /** + * Properties of a GetCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @interface IGetCustomClassRequest + * @property {string|null} [name] GetCustomClassRequest name + */ + + /** + * Constructs a new GetCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a GetCustomClassRequest. + * @implements IGetCustomClassRequest + * @constructor + * @param {google.cloud.speech.v2.IGetCustomClassRequest=} [properties] Properties to set + */ + function GetCustomClassRequest(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]]; + } + + /** + * GetCustomClassRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @instance + */ + GetCustomClassRequest.prototype.name = ""; + + /** + * Creates a new GetCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IGetCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.GetCustomClassRequest} GetCustomClassRequest instance + */ + GetCustomClassRequest.create = function create(properties) { + return new GetCustomClassRequest(properties); + }; + + /** + * Encodes the specified GetCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.GetCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IGetCustomClassRequest} message GetCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCustomClassRequest.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); + return writer; + }; + + /** + * Encodes the specified GetCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IGetCustomClassRequest} message GetCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.GetCustomClassRequest} GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCustomClassRequest.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.v2.GetCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.GetCustomClassRequest} GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCustomClassRequest.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"; + return null; + }; + + /** + * Creates a GetCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.GetCustomClassRequest} GetCustomClassRequest + */ + GetCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.GetCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v2.GetCustomClassRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v2.GetCustomClassRequest} message GetCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + GetCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCustomClassRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.GetCustomClassRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCustomClassRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.GetCustomClassRequest"; + }; + + return GetCustomClassRequest; + })(); + + v2.UpdateCustomClassRequest = (function() { + + /** + * Properties of an UpdateCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @interface IUpdateCustomClassRequest + * @property {google.cloud.speech.v2.ICustomClass|null} [customClass] UpdateCustomClassRequest customClass + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCustomClassRequest updateMask + * @property {boolean|null} [validateOnly] UpdateCustomClassRequest validateOnly + */ + + /** + * Constructs a new UpdateCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UpdateCustomClassRequest. + * @implements IUpdateCustomClassRequest + * @constructor + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest=} [properties] Properties to set + */ + function UpdateCustomClassRequest(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]]; + } + + /** + * UpdateCustomClassRequest customClass. + * @member {google.cloud.speech.v2.ICustomClass|null|undefined} customClass + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @instance + */ + UpdateCustomClassRequest.prototype.customClass = null; + + /** + * UpdateCustomClassRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @instance + */ + UpdateCustomClassRequest.prototype.updateMask = null; + + /** + * UpdateCustomClassRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @instance + */ + UpdateCustomClassRequest.prototype.validateOnly = false; + + /** + * Creates a new UpdateCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UpdateCustomClassRequest} UpdateCustomClassRequest instance + */ + UpdateCustomClassRequest.create = function create(properties) { + return new UpdateCustomClassRequest(properties); + }; + + /** + * Encodes the specified UpdateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdateCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest} message UpdateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.customClass != null && Object.hasOwnProperty.call(message, "customClass")) + $root.google.cloud.speech.v2.CustomClass.encode(message.customClass, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified UpdateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdateCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUpdateCustomClassRequest} message UpdateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UpdateCustomClassRequest} UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCustomClassRequest.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.v2.UpdateCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.customClass = $root.google.cloud.speech.v2.CustomClass.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UpdateCustomClassRequest} UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCustomClassRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.customClass != null && message.hasOwnProperty("customClass")) { + var error = $root.google.cloud.speech.v2.CustomClass.verify(message.customClass); + if (error) + return "customClass." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates an UpdateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UpdateCustomClassRequest} UpdateCustomClassRequest + */ + UpdateCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UpdateCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v2.UpdateCustomClassRequest(); + if (object.customClass != null) { + if (typeof object.customClass !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateCustomClassRequest.customClass: object expected"); + message.customClass = $root.google.cloud.speech.v2.CustomClass.fromObject(object.customClass); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v2.UpdateCustomClassRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from an UpdateCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v2.UpdateCustomClassRequest} message UpdateCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.customClass = null; + object.updateMask = null; + object.validateOnly = false; + } + if (message.customClass != null && message.hasOwnProperty("customClass")) + object.customClass = $root.google.cloud.speech.v2.CustomClass.toObject(message.customClass, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this UpdateCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCustomClassRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UpdateCustomClassRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCustomClassRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UpdateCustomClassRequest"; + }; + + return UpdateCustomClassRequest; + })(); + + v2.DeleteCustomClassRequest = (function() { + + /** + * Properties of a DeleteCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @interface IDeleteCustomClassRequest + * @property {string|null} [name] DeleteCustomClassRequest name + * @property {boolean|null} [validateOnly] DeleteCustomClassRequest validateOnly + * @property {boolean|null} [allowMissing] DeleteCustomClassRequest allowMissing + * @property {string|null} [etag] DeleteCustomClassRequest etag + */ + + /** + * Constructs a new DeleteCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a DeleteCustomClassRequest. + * @implements IDeleteCustomClassRequest + * @constructor + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest=} [properties] Properties to set + */ + function DeleteCustomClassRequest(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]]; + } + + /** + * DeleteCustomClassRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @instance + */ + DeleteCustomClassRequest.prototype.name = ""; + + /** + * DeleteCustomClassRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @instance + */ + DeleteCustomClassRequest.prototype.validateOnly = false; + + /** + * DeleteCustomClassRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @instance + */ + DeleteCustomClassRequest.prototype.allowMissing = false; + + /** + * DeleteCustomClassRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @instance + */ + DeleteCustomClassRequest.prototype.etag = ""; + + /** + * Creates a new DeleteCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.DeleteCustomClassRequest} DeleteCustomClassRequest instance + */ + DeleteCustomClassRequest.create = function create(properties) { + return new DeleteCustomClassRequest(properties); + }; + + /** + * Encodes the specified DeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.DeleteCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest} message DeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCustomClassRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified DeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeleteCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IDeleteCustomClassRequest} message DeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.DeleteCustomClassRequest} DeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteCustomClassRequest.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.v2.DeleteCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.DeleteCustomClassRequest} DeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteCustomClassRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a DeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.DeleteCustomClassRequest} DeleteCustomClassRequest + */ + DeleteCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.DeleteCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v2.DeleteCustomClassRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a DeleteCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.DeleteCustomClassRequest} message DeleteCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + object.allowMissing = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this DeleteCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteCustomClassRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.DeleteCustomClassRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteCustomClassRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.DeleteCustomClassRequest"; + }; + + return DeleteCustomClassRequest; + })(); + + v2.UndeleteCustomClassRequest = (function() { + + /** + * Properties of an UndeleteCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @interface IUndeleteCustomClassRequest + * @property {string|null} [name] UndeleteCustomClassRequest name + * @property {boolean|null} [validateOnly] UndeleteCustomClassRequest validateOnly + * @property {string|null} [etag] UndeleteCustomClassRequest etag + */ + + /** + * Constructs a new UndeleteCustomClassRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UndeleteCustomClassRequest. + * @implements IUndeleteCustomClassRequest + * @constructor + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest=} [properties] Properties to set + */ + function UndeleteCustomClassRequest(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]]; + } + + /** + * UndeleteCustomClassRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @instance + */ + UndeleteCustomClassRequest.prototype.name = ""; + + /** + * UndeleteCustomClassRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @instance + */ + UndeleteCustomClassRequest.prototype.validateOnly = false; + + /** + * UndeleteCustomClassRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @instance + */ + UndeleteCustomClassRequest.prototype.etag = ""; + + /** + * Creates a new UndeleteCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UndeleteCustomClassRequest} UndeleteCustomClassRequest instance + */ + UndeleteCustomClassRequest.create = function create(properties) { + return new UndeleteCustomClassRequest(properties); + }; + + /** + * Encodes the specified UndeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeleteCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest} message UndeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeleteCustomClassRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.etag); + return writer; + }; + + /** + * Encodes the specified UndeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeleteCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.IUndeleteCustomClassRequest} message UndeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeleteCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UndeleteCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UndeleteCustomClassRequest} UndeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeleteCustomClassRequest.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.v2.UndeleteCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UndeleteCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UndeleteCustomClassRequest} UndeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeleteCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UndeleteCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UndeleteCustomClassRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates an UndeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UndeleteCustomClassRequest} UndeleteCustomClassRequest + */ + UndeleteCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UndeleteCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v2.UndeleteCustomClassRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from an UndeleteCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v2.UndeleteCustomClassRequest} message UndeleteCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UndeleteCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this UndeleteCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + UndeleteCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UndeleteCustomClassRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UndeleteCustomClassRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UndeleteCustomClassRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UndeleteCustomClassRequest"; + }; + + return UndeleteCustomClassRequest; + })(); + + v2.CreatePhraseSetRequest = (function() { + + /** + * Properties of a CreatePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @interface ICreatePhraseSetRequest + * @property {google.cloud.speech.v2.IPhraseSet|null} [phraseSet] CreatePhraseSetRequest phraseSet + * @property {boolean|null} [validateOnly] CreatePhraseSetRequest validateOnly + * @property {string|null} [phraseSetId] CreatePhraseSetRequest phraseSetId + * @property {string|null} [parent] CreatePhraseSetRequest parent + */ + + /** + * Constructs a new CreatePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a CreatePhraseSetRequest. + * @implements ICreatePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest=} [properties] Properties to set + */ + function CreatePhraseSetRequest(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]]; + } + + /** + * CreatePhraseSetRequest phraseSet. + * @member {google.cloud.speech.v2.IPhraseSet|null|undefined} phraseSet + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.phraseSet = null; + + /** + * CreatePhraseSetRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.validateOnly = false; + + /** + * CreatePhraseSetRequest phraseSetId. + * @member {string} phraseSetId + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.phraseSetId = ""; + + /** + * CreatePhraseSetRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.parent = ""; + + /** + * Creates a new CreatePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.CreatePhraseSetRequest} CreatePhraseSetRequest instance + */ + CreatePhraseSetRequest.create = function create(properties) { + return new CreatePhraseSetRequest(properties); + }; + + /** + * Encodes the specified CreatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.CreatePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest} message CreatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreatePhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSet != null && Object.hasOwnProperty.call(message, "phraseSet")) + $root.google.cloud.speech.v2.PhraseSet.encode(message.phraseSet, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.phraseSetId != null && Object.hasOwnProperty.call(message, "phraseSetId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.phraseSetId); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.parent); + return writer; + }; + + /** + * Encodes the specified CreatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.CreatePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.ICreatePhraseSetRequest} message CreatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreatePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.CreatePhraseSetRequest} CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreatePhraseSetRequest.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.v2.CreatePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.phraseSet = $root.google.cloud.speech.v2.PhraseSet.decode(reader, reader.uint32()); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 3: { + message.phraseSetId = reader.string(); + break; + } + case 4: { + message.parent = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.CreatePhraseSetRequest} CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreatePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreatePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreatePhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + var error = $root.google.cloud.speech.v2.PhraseSet.verify(message.phraseSet); + if (error) + return "phraseSet." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.phraseSetId != null && message.hasOwnProperty("phraseSetId")) + if (!$util.isString(message.phraseSetId)) + return "phraseSetId: string expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + return null; + }; + + /** + * Creates a CreatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.CreatePhraseSetRequest} CreatePhraseSetRequest + */ + CreatePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.CreatePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v2.CreatePhraseSetRequest(); + if (object.phraseSet != null) { + if (typeof object.phraseSet !== "object") + throw TypeError(".google.cloud.speech.v2.CreatePhraseSetRequest.phraseSet: object expected"); + message.phraseSet = $root.google.cloud.speech.v2.PhraseSet.fromObject(object.phraseSet); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.phraseSetId != null) + message.phraseSetId = String(object.phraseSetId); + if (object.parent != null) + message.parent = String(object.parent); + return message; + }; + + /** + * Creates a plain object from a CreatePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.CreatePhraseSetRequest} message CreatePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreatePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.phraseSet = null; + object.validateOnly = false; + object.phraseSetId = ""; + object.parent = ""; + } + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) + object.phraseSet = $root.google.cloud.speech.v2.PhraseSet.toObject(message.phraseSet, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.phraseSetId != null && message.hasOwnProperty("phraseSetId")) + object.phraseSetId = message.phraseSetId; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + return object; + }; + + /** + * Converts this CreatePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + CreatePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreatePhraseSetRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.CreatePhraseSetRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreatePhraseSetRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.CreatePhraseSetRequest"; + }; + + return CreatePhraseSetRequest; + })(); + + v2.ListPhraseSetsRequest = (function() { + + /** + * Properties of a ListPhraseSetsRequest. + * @memberof google.cloud.speech.v2 + * @interface IListPhraseSetsRequest + * @property {string|null} [parent] ListPhraseSetsRequest parent + * @property {number|null} [pageSize] ListPhraseSetsRequest pageSize + * @property {string|null} [pageToken] ListPhraseSetsRequest pageToken + * @property {boolean|null} [showDeleted] ListPhraseSetsRequest showDeleted + */ + + /** + * Constructs a new ListPhraseSetsRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListPhraseSetsRequest. + * @implements IListPhraseSetsRequest + * @constructor + * @param {google.cloud.speech.v2.IListPhraseSetsRequest=} [properties] Properties to set + */ + function ListPhraseSetsRequest(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]]; + } + + /** + * ListPhraseSetsRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @instance + */ + ListPhraseSetsRequest.prototype.parent = ""; + + /** + * ListPhraseSetsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @instance + */ + ListPhraseSetsRequest.prototype.pageSize = 0; + + /** + * ListPhraseSetsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @instance + */ + ListPhraseSetsRequest.prototype.pageToken = ""; + + /** + * ListPhraseSetsRequest showDeleted. + * @member {boolean} showDeleted + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @instance + */ + ListPhraseSetsRequest.prototype.showDeleted = false; + + /** + * Creates a new ListPhraseSetsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListPhraseSetsRequest} ListPhraseSetsRequest instance + */ + ListPhraseSetsRequest.create = function create(properties) { + return new ListPhraseSetsRequest(properties); + }; + + /** + * Encodes the specified ListPhraseSetsRequest message. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsRequest} message ListPhraseSetsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.showDeleted != null && Object.hasOwnProperty.call(message, "showDeleted")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.showDeleted); + return writer; + }; + + /** + * Encodes the specified ListPhraseSetsRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsRequest} message ListPhraseSetsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListPhraseSetsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListPhraseSetsRequest} ListPhraseSetsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetsRequest.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.v2.ListPhraseSetsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.showDeleted = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListPhraseSetsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListPhraseSetsRequest} ListPhraseSetsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListPhraseSetsRequest message. + * @function verify + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListPhraseSetsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + if (typeof message.showDeleted !== "boolean") + return "showDeleted: boolean expected"; + return null; + }; + + /** + * Creates a ListPhraseSetsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListPhraseSetsRequest} ListPhraseSetsRequest + */ + ListPhraseSetsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListPhraseSetsRequest) + return object; + var message = new $root.google.cloud.speech.v2.ListPhraseSetsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.showDeleted != null) + message.showDeleted = Boolean(object.showDeleted); + return message; + }; + + /** + * Creates a plain object from a ListPhraseSetsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {google.cloud.speech.v2.ListPhraseSetsRequest} message ListPhraseSetsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListPhraseSetsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.showDeleted = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.showDeleted != null && message.hasOwnProperty("showDeleted")) + object.showDeleted = message.showDeleted; + return object; + }; + + /** + * Converts this ListPhraseSetsRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @instance + * @returns {Object.} JSON object + */ + ListPhraseSetsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListPhraseSetsRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListPhraseSetsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListPhraseSetsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListPhraseSetsRequest"; + }; + + return ListPhraseSetsRequest; + })(); + + v2.ListPhraseSetsResponse = (function() { + + /** + * Properties of a ListPhraseSetsResponse. + * @memberof google.cloud.speech.v2 + * @interface IListPhraseSetsResponse + * @property {Array.|null} [phraseSets] ListPhraseSetsResponse phraseSets + * @property {string|null} [nextPageToken] ListPhraseSetsResponse nextPageToken + */ + + /** + * Constructs a new ListPhraseSetsResponse. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a ListPhraseSetsResponse. + * @implements IListPhraseSetsResponse + * @constructor + * @param {google.cloud.speech.v2.IListPhraseSetsResponse=} [properties] Properties to set + */ + function ListPhraseSetsResponse(properties) { + this.phraseSets = []; + 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]]; + } + + /** + * ListPhraseSetsResponse phraseSets. + * @member {Array.} phraseSets + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @instance + */ + ListPhraseSetsResponse.prototype.phraseSets = $util.emptyArray; + + /** + * ListPhraseSetsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @instance + */ + ListPhraseSetsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListPhraseSetsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v2.ListPhraseSetsResponse} ListPhraseSetsResponse instance + */ + ListPhraseSetsResponse.create = function create(properties) { + return new ListPhraseSetsResponse(properties); + }; + + /** + * Encodes the specified ListPhraseSetsResponse message. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsResponse} message ListPhraseSetsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetsResponse.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.v2.PhraseSet.encode(message.phraseSets[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListPhraseSetsResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v2.ListPhraseSetsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {google.cloud.speech.v2.IListPhraseSetsResponse} message ListPhraseSetsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListPhraseSetsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.ListPhraseSetsResponse} ListPhraseSetsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetsResponse.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.v2.ListPhraseSetsResponse(); + 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.v2.PhraseSet.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListPhraseSetsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.ListPhraseSetsResponse} ListPhraseSetsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListPhraseSetsResponse message. + * @function verify + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListPhraseSetsResponse.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.v2.PhraseSet.verify(message.phraseSets[i]); + if (error) + return "phraseSets." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListPhraseSetsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.ListPhraseSetsResponse} ListPhraseSetsResponse + */ + ListPhraseSetsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.ListPhraseSetsResponse) + return object; + var message = new $root.google.cloud.speech.v2.ListPhraseSetsResponse(); + if (object.phraseSets) { + if (!Array.isArray(object.phraseSets)) + throw TypeError(".google.cloud.speech.v2.ListPhraseSetsResponse.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.v2.ListPhraseSetsResponse.phraseSets: object expected"); + message.phraseSets[i] = $root.google.cloud.speech.v2.PhraseSet.fromObject(object.phraseSets[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListPhraseSetsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {google.cloud.speech.v2.ListPhraseSetsResponse} message ListPhraseSetsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListPhraseSetsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.phraseSets = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.phraseSets && message.phraseSets.length) { + object.phraseSets = []; + for (var j = 0; j < message.phraseSets.length; ++j) + object.phraseSets[j] = $root.google.cloud.speech.v2.PhraseSet.toObject(message.phraseSets[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListPhraseSetsResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @instance + * @returns {Object.} JSON object + */ + ListPhraseSetsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListPhraseSetsResponse + * @function getTypeUrl + * @memberof google.cloud.speech.v2.ListPhraseSetsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListPhraseSetsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.ListPhraseSetsResponse"; + }; + + return ListPhraseSetsResponse; + })(); + + v2.GetPhraseSetRequest = (function() { + + /** + * Properties of a GetPhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @interface IGetPhraseSetRequest + * @property {string|null} [name] GetPhraseSetRequest name + */ + + /** + * Constructs a new GetPhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a GetPhraseSetRequest. + * @implements IGetPhraseSetRequest + * @constructor + * @param {google.cloud.speech.v2.IGetPhraseSetRequest=} [properties] Properties to set + */ + function GetPhraseSetRequest(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]]; + } + + /** + * GetPhraseSetRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @instance + */ + GetPhraseSetRequest.prototype.name = ""; + + /** + * Creates a new GetPhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IGetPhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.GetPhraseSetRequest} GetPhraseSetRequest instance + */ + GetPhraseSetRequest.create = function create(properties) { + return new GetPhraseSetRequest(properties); + }; + + /** + * Encodes the specified GetPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.GetPhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IGetPhraseSetRequest} message GetPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPhraseSetRequest.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); + return writer; + }; + + /** + * Encodes the specified GetPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.GetPhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IGetPhraseSetRequest} message GetPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.GetPhraseSetRequest} GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPhraseSetRequest.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.v2.GetPhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.GetPhraseSetRequest} GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetPhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetPhraseSetRequest.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"; + return null; + }; + + /** + * Creates a GetPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.GetPhraseSetRequest} GetPhraseSetRequest + */ + GetPhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.GetPhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v2.GetPhraseSetRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetPhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v2.GetPhraseSetRequest} message GetPhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetPhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetPhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + GetPhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetPhraseSetRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.GetPhraseSetRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetPhraseSetRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.GetPhraseSetRequest"; + }; + + return GetPhraseSetRequest; + })(); + + v2.UpdatePhraseSetRequest = (function() { + + /** + * Properties of an UpdatePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @interface IUpdatePhraseSetRequest + * @property {google.cloud.speech.v2.IPhraseSet|null} [phraseSet] UpdatePhraseSetRequest phraseSet + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdatePhraseSetRequest updateMask + * @property {boolean|null} [validateOnly] UpdatePhraseSetRequest validateOnly + */ + + /** + * Constructs a new UpdatePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UpdatePhraseSetRequest. + * @implements IUpdatePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest=} [properties] Properties to set + */ + function UpdatePhraseSetRequest(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]]; + } + + /** + * UpdatePhraseSetRequest phraseSet. + * @member {google.cloud.speech.v2.IPhraseSet|null|undefined} phraseSet + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @instance + */ + UpdatePhraseSetRequest.prototype.phraseSet = null; + + /** + * UpdatePhraseSetRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @instance + */ + UpdatePhraseSetRequest.prototype.updateMask = null; + + /** + * UpdatePhraseSetRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @instance + */ + UpdatePhraseSetRequest.prototype.validateOnly = false; + + /** + * Creates a new UpdatePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UpdatePhraseSetRequest} UpdatePhraseSetRequest instance + */ + UpdatePhraseSetRequest.create = function create(properties) { + return new UpdatePhraseSetRequest(properties); + }; + + /** + * Encodes the specified UpdatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.UpdatePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest} message UpdatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdatePhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSet != null && Object.hasOwnProperty.call(message, "phraseSet")) + $root.google.cloud.speech.v2.PhraseSet.encode(message.phraseSet, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified UpdatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UpdatePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUpdatePhraseSetRequest} message UpdatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdatePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UpdatePhraseSetRequest} UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdatePhraseSetRequest.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.v2.UpdatePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.phraseSet = $root.google.cloud.speech.v2.PhraseSet.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UpdatePhraseSetRequest} UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdatePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdatePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdatePhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + var error = $root.google.cloud.speech.v2.PhraseSet.verify(message.phraseSet); + if (error) + return "phraseSet." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates an UpdatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UpdatePhraseSetRequest} UpdatePhraseSetRequest + */ + UpdatePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UpdatePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v2.UpdatePhraseSetRequest(); + if (object.phraseSet != null) { + if (typeof object.phraseSet !== "object") + throw TypeError(".google.cloud.speech.v2.UpdatePhraseSetRequest.phraseSet: object expected"); + message.phraseSet = $root.google.cloud.speech.v2.PhraseSet.fromObject(object.phraseSet); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v2.UpdatePhraseSetRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from an UpdatePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.UpdatePhraseSetRequest} message UpdatePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdatePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.phraseSet = null; + object.updateMask = null; + object.validateOnly = false; + } + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) + object.phraseSet = $root.google.cloud.speech.v2.PhraseSet.toObject(message.phraseSet, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this UpdatePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + UpdatePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdatePhraseSetRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UpdatePhraseSetRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdatePhraseSetRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UpdatePhraseSetRequest"; + }; + + return UpdatePhraseSetRequest; + })(); + + v2.DeletePhraseSetRequest = (function() { + + /** + * Properties of a DeletePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @interface IDeletePhraseSetRequest + * @property {string|null} [name] DeletePhraseSetRequest name + * @property {boolean|null} [validateOnly] DeletePhraseSetRequest validateOnly + * @property {boolean|null} [allowMissing] DeletePhraseSetRequest allowMissing + * @property {string|null} [etag] DeletePhraseSetRequest etag + */ + + /** + * Constructs a new DeletePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents a DeletePhraseSetRequest. + * @implements IDeletePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest=} [properties] Properties to set + */ + function DeletePhraseSetRequest(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]]; + } + + /** + * DeletePhraseSetRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @instance + */ + DeletePhraseSetRequest.prototype.name = ""; + + /** + * DeletePhraseSetRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @instance + */ + DeletePhraseSetRequest.prototype.validateOnly = false; + + /** + * DeletePhraseSetRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @instance + */ + DeletePhraseSetRequest.prototype.allowMissing = false; + + /** + * DeletePhraseSetRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @instance + */ + DeletePhraseSetRequest.prototype.etag = ""; + + /** + * Creates a new DeletePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.DeletePhraseSetRequest} DeletePhraseSetRequest instance + */ + DeletePhraseSetRequest.create = function create(properties) { + return new DeletePhraseSetRequest(properties); + }; + + /** + * Encodes the specified DeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.DeletePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest} message DeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeletePhraseSetRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.etag); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified DeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.DeletePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IDeletePhraseSetRequest} message DeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeletePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.DeletePhraseSetRequest} DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeletePhraseSetRequest.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.v2.DeletePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + case 3: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.DeletePhraseSetRequest} DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeletePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeletePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeletePhraseSetRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates a DeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.DeletePhraseSetRequest} DeletePhraseSetRequest + */ + DeletePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.DeletePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v2.DeletePhraseSetRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from a DeletePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.DeletePhraseSetRequest} message DeletePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeletePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + object.allowMissing = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this DeletePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + DeletePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeletePhraseSetRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.DeletePhraseSetRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeletePhraseSetRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.DeletePhraseSetRequest"; + }; + + return DeletePhraseSetRequest; + })(); + + v2.UndeletePhraseSetRequest = (function() { + + /** + * Properties of an UndeletePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @interface IUndeletePhraseSetRequest + * @property {string|null} [name] UndeletePhraseSetRequest name + * @property {boolean|null} [validateOnly] UndeletePhraseSetRequest validateOnly + * @property {string|null} [etag] UndeletePhraseSetRequest etag + */ + + /** + * Constructs a new UndeletePhraseSetRequest. + * @memberof google.cloud.speech.v2 + * @classdesc Represents an UndeletePhraseSetRequest. + * @implements IUndeletePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest=} [properties] Properties to set + */ + function UndeletePhraseSetRequest(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]]; + } + + /** + * UndeletePhraseSetRequest name. + * @member {string} name + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @instance + */ + UndeletePhraseSetRequest.prototype.name = ""; + + /** + * UndeletePhraseSetRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @instance + */ + UndeletePhraseSetRequest.prototype.validateOnly = false; + + /** + * UndeletePhraseSetRequest etag. + * @member {string} etag + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @instance + */ + UndeletePhraseSetRequest.prototype.etag = ""; + + /** + * Creates a new UndeletePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v2.UndeletePhraseSetRequest} UndeletePhraseSetRequest instance + */ + UndeletePhraseSetRequest.create = function create(properties) { + return new UndeletePhraseSetRequest(properties); + }; + + /** + * Encodes the specified UndeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v2.UndeletePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest} message UndeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeletePhraseSetRequest.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.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.validateOnly); + if (message.etag != null && Object.hasOwnProperty.call(message, "etag")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.etag); + return writer; + }; + + /** + * Encodes the specified UndeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v2.UndeletePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.IUndeletePhraseSetRequest} message UndeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UndeletePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UndeletePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v2.UndeletePhraseSetRequest} UndeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeletePhraseSetRequest.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.v2.UndeletePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.validateOnly = reader.bool(); + break; + } + case 4: { + message.etag = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UndeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v2.UndeletePhraseSetRequest} UndeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UndeletePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UndeletePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UndeletePhraseSetRequest.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.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.etag != null && message.hasOwnProperty("etag")) + if (!$util.isString(message.etag)) + return "etag: string expected"; + return null; + }; + + /** + * Creates an UndeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v2.UndeletePhraseSetRequest} UndeletePhraseSetRequest + */ + UndeletePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v2.UndeletePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v2.UndeletePhraseSetRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.etag != null) + message.etag = String(object.etag); + return message; + }; + + /** + * Creates a plain object from an UndeletePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v2.UndeletePhraseSetRequest} message UndeletePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UndeletePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.validateOnly = false; + object.etag = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + if (message.etag != null && message.hasOwnProperty("etag")) + object.etag = message.etag; + return object; + }; + + /** + * Converts this UndeletePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + UndeletePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UndeletePhraseSetRequest + * @function getTypeUrl + * @memberof google.cloud.speech.v2.UndeletePhraseSetRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UndeletePhraseSetRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v2.UndeletePhraseSetRequest"; + }; + + return UndeletePhraseSetRequest; + })(); + + return v2; + })(); + return speech; })(); diff --git a/packages/google-cloud-speech/protos/protos.json b/packages/google-cloud-speech/protos/protos.json index 8e494916420..8a11a1b381d 100644 --- a/packages/google-cloud-speech/protos/protos.json +++ b/packages/google-cloud-speech/protos/protos.json @@ -2213,6 +2213,2048 @@ } } } + }, + "v2": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/cloud/speech/v2;speech", + "java_multiple_files": true, + "java_outer_classname": "CloudSpeechProto", + "java_package": "com.google.cloud.speech.v2", + "(google.api.resource_definition).type": "cloudkms.googleapis.com/CryptoKeyVersion", + "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" + }, + "nested": { + "Speech": { + "options": { + "(google.api.default_host)": "speech.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateRecognizer": { + "requestType": "CreateRecognizerRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*}/recognizers", + "(google.api.http).body": "recognizer", + "(google.api.method_signature)": "parent,recognizer,recognizer_id", + "(google.longrunning.operation_info).response_type": "Recognizer", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*}/recognizers", + "body": "recognizer" + } + }, + { + "(google.api.method_signature)": "parent,recognizer,recognizer_id" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Recognizer", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "ListRecognizers": { + "requestType": "ListRecognizersRequest", + "responseType": "ListRecognizersResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*}/recognizers", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*}/recognizers" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "GetRecognizer": { + "requestType": "GetRecognizerRequest", + "responseType": "Recognizer", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/recognizers/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/recognizers/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateRecognizer": { + "requestType": "UpdateRecognizerRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).patch": "/v2/{recognizer.name=projects/*/locations/*/recognizers/*}", + "(google.api.http).body": "recognizer", + "(google.api.method_signature)": "recognizer,update_mask", + "(google.longrunning.operation_info).response_type": "Recognizer", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{recognizer.name=projects/*/locations/*/recognizers/*}", + "body": "recognizer" + } + }, + { + "(google.api.method_signature)": "recognizer,update_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Recognizer", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "DeleteRecognizer": { + "requestType": "DeleteRecognizerRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/recognizers/*}", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "Recognizer", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/recognizers/*}" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Recognizer", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "UndeleteRecognizer": { + "requestType": "UndeleteRecognizerRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{name=projects/*/locations/*/recognizers/*}:undelete", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "Recognizer", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{name=projects/*/locations/*/recognizers/*}:undelete", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Recognizer", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "Recognize": { + "requestType": "RecognizeRequest", + "responseType": "RecognizeResponse", + "options": { + "(google.api.http).post": "/v2/{recognizer=projects/*/locations/*/recognizers/*}:recognize", + "(google.api.http).body": "*", + "(google.api.method_signature)": "recognizer,config,config_mask,uri" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{recognizer=projects/*/locations/*/recognizers/*}:recognize", + "body": "*" + } + }, + { + "(google.api.method_signature)": "recognizer,config,config_mask,content" + }, + { + "(google.api.method_signature)": "recognizer,config,config_mask,uri" + } + ] + }, + "StreamingRecognize": { + "requestType": "StreamingRecognizeRequest", + "requestStream": true, + "responseType": "StreamingRecognizeResponse", + "responseStream": true + }, + "BatchRecognize": { + "requestType": "BatchRecognizeRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{recognizer=projects/*/locations/*/recognizers/*}:batchRecognize", + "(google.api.http).body": "*", + "(google.api.method_signature)": "recognizer,config,config_mask,files", + "(google.longrunning.operation_info).response_type": "BatchRecognizeResponse", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{recognizer=projects/*/locations/*/recognizers/*}:batchRecognize", + "body": "*" + } + }, + { + "(google.api.method_signature)": "recognizer,config,config_mask,files" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "BatchRecognizeResponse", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "GetConfig": { + "requestType": "GetConfigRequest", + "responseType": "Config", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/config}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/config}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateConfig": { + "requestType": "UpdateConfigRequest", + "responseType": "Config", + "options": { + "(google.api.http).patch": "/v2/{config.name=projects/*/locations/*/config}", + "(google.api.http).body": "config", + "(google.api.method_signature)": "config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{config.name=projects/*/locations/*/config}", + "body": "config" + } + }, + { + "(google.api.method_signature)": "config,update_mask" + } + ] + }, + "CreateCustomClass": { + "requestType": "CreateCustomClassRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*}/customClasses", + "(google.api.http).body": "custom_class", + "(google.api.method_signature)": "parent,custom_class,custom_class_id", + "(google.longrunning.operation_info).response_type": "CustomClass", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*}/customClasses", + "body": "custom_class" + } + }, + { + "(google.api.method_signature)": "parent,custom_class,custom_class_id" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "CustomClass", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "ListCustomClasses": { + "requestType": "ListCustomClassesRequest", + "responseType": "ListCustomClassesResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*}/customClasses", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*}/customClasses" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "GetCustomClass": { + "requestType": "GetCustomClassRequest", + "responseType": "CustomClass", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/customClasses/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/customClasses/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateCustomClass": { + "requestType": "UpdateCustomClassRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).patch": "/v2/{custom_class.name=projects/*/locations/*/customClasses/*}", + "(google.api.http).body": "custom_class", + "(google.api.method_signature)": "custom_class,update_mask", + "(google.longrunning.operation_info).response_type": "CustomClass", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{custom_class.name=projects/*/locations/*/customClasses/*}", + "body": "custom_class" + } + }, + { + "(google.api.method_signature)": "custom_class,update_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "CustomClass", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "DeleteCustomClass": { + "requestType": "DeleteCustomClassRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/customClasses/*}", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "CustomClass", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/customClasses/*}" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "CustomClass", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "UndeleteCustomClass": { + "requestType": "UndeleteCustomClassRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{name=projects/*/locations/*/customClasses/*}:undelete", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "CustomClass", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{name=projects/*/locations/*/customClasses/*}:undelete", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "CustomClass", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "CreatePhraseSet": { + "requestType": "CreatePhraseSetRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*}/phraseSets", + "(google.api.http).body": "phrase_set", + "(google.api.method_signature)": "parent,phrase_set,phrase_set_id", + "(google.longrunning.operation_info).response_type": "PhraseSet", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*}/phraseSets", + "body": "phrase_set" + } + }, + { + "(google.api.method_signature)": "parent,phrase_set,phrase_set_id" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "PhraseSet", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "ListPhraseSets": { + "requestType": "ListPhraseSetsRequest", + "responseType": "ListPhraseSetsResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*}/phraseSets", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*}/phraseSets" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "GetPhraseSet": { + "requestType": "GetPhraseSetRequest", + "responseType": "PhraseSet", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/phraseSets/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/phraseSets/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdatePhraseSet": { + "requestType": "UpdatePhraseSetRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).patch": "/v2/{phrase_set.name=projects/*/locations/*/phraseSets/*}", + "(google.api.http).body": "phrase_set", + "(google.api.method_signature)": "phrase_set,update_mask", + "(google.longrunning.operation_info).response_type": "PhraseSet", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{phrase_set.name=projects/*/locations/*/phraseSets/*}", + "body": "phrase_set" + } + }, + { + "(google.api.method_signature)": "phrase_set,update_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "PhraseSet", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "DeletePhraseSet": { + "requestType": "DeletePhraseSetRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/phraseSets/*}", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "PhraseSet", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/phraseSets/*}" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "PhraseSet", + "metadata_type": "OperationMetadata" + } + } + ] + }, + "UndeletePhraseSet": { + "requestType": "UndeletePhraseSetRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{name=projects/*/locations/*/phraseSets/*}:undelete", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "PhraseSet", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{name=projects/*/locations/*/phraseSets/*}:undelete", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "PhraseSet", + "metadata_type": "OperationMetadata" + } + } + ] + } + } + }, + "CreateRecognizerRequest": { + "fields": { + "recognizer": { + "type": "Recognizer", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "recognizerId": { + "type": "string", + "id": 3 + }, + "parent": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/Recognizer" + } + } + } + }, + "OperationMetadata": { + "oneofs": { + "request": { + "oneof": [ + "batchRecognizeRequest", + "createRecognizerRequest", + "updateRecognizerRequest", + "deleteRecognizerRequest", + "undeleteRecognizerRequest", + "createCustomClassRequest", + "updateCustomClassRequest", + "deleteCustomClassRequest", + "undeleteCustomClassRequest", + "createPhraseSetRequest", + "updatePhraseSetRequest", + "deletePhraseSetRequest", + "undeletePhraseSetRequest", + "updateConfigRequest" + ] + }, + "metadata": { + "oneof": [ + "batchRecognizeMetadata" + ] + } + }, + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "resource": { + "type": "string", + "id": 3 + }, + "method": { + "type": "string", + "id": 4 + }, + "kmsKeyName": { + "type": "string", + "id": 6, + "options": { + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "kmsKeyVersionName": { + "type": "string", + "id": 7, + "options": { + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKeyVersion" + } + }, + "batchRecognizeRequest": { + "type": "BatchRecognizeRequest", + "id": 8 + }, + "createRecognizerRequest": { + "type": "CreateRecognizerRequest", + "id": 9 + }, + "updateRecognizerRequest": { + "type": "UpdateRecognizerRequest", + "id": 10 + }, + "deleteRecognizerRequest": { + "type": "DeleteRecognizerRequest", + "id": 11 + }, + "undeleteRecognizerRequest": { + "type": "UndeleteRecognizerRequest", + "id": 12 + }, + "createCustomClassRequest": { + "type": "CreateCustomClassRequest", + "id": 13 + }, + "updateCustomClassRequest": { + "type": "UpdateCustomClassRequest", + "id": 14 + }, + "deleteCustomClassRequest": { + "type": "DeleteCustomClassRequest", + "id": 15 + }, + "undeleteCustomClassRequest": { + "type": "UndeleteCustomClassRequest", + "id": 16 + }, + "createPhraseSetRequest": { + "type": "CreatePhraseSetRequest", + "id": 17 + }, + "updatePhraseSetRequest": { + "type": "UpdatePhraseSetRequest", + "id": 18 + }, + "deletePhraseSetRequest": { + "type": "DeletePhraseSetRequest", + "id": 19 + }, + "undeletePhraseSetRequest": { + "type": "UndeletePhraseSetRequest", + "id": 20 + }, + "updateConfigRequest": { + "type": "UpdateConfigRequest", + "id": 21 + }, + "progressPercent": { + "type": "int32", + "id": 22 + }, + "batchRecognizeMetadata": { + "type": "BatchRecognizeMetadata", + "id": 23 + } + } + }, + "ListRecognizersRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "showDeleted": { + "type": "bool", + "id": 4 + } + } + }, + "ListRecognizersResponse": { + "fields": { + "recognizers": { + "rule": "repeated", + "type": "Recognizer", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "GetRecognizerRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + } + } + }, + "UpdateRecognizerRequest": { + "fields": { + "recognizer": { + "type": "Recognizer", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + } + }, + "DeleteRecognizerRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 4 + }, + "etag": { + "type": "string", + "id": 3 + } + } + }, + "UndeleteRecognizerRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + }, + "validateOnly": { + "type": "bool", + "id": 3 + }, + "etag": { + "type": "string", + "id": 4 + } + } + }, + "Recognizer": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/Recognizer", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/recognizers/{recognizer}", + "(google.api.resource).style": "DECLARATIVE_FRIENDLY" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "uid": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "displayName": { + "type": "string", + "id": 3 + }, + "model": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "languageCodes": { + "rule": "repeated", + "type": "string", + "id": 17, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "defaultRecognitionConfig": { + "type": "RecognitionConfig", + "id": 6 + }, + "annotations": { + "keyType": "string", + "type": "string", + "id": 7 + }, + "state": { + "type": "State", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "deleteTime": { + "type": "google.protobuf.Timestamp", + "id": 11, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 14, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "etag": { + "type": "string", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "reconciling": { + "type": "bool", + "id": 13, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "kmsKeyName": { + "type": "string", + "id": 15, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "kmsKeyVersionName": { + "type": "string", + "id": 16, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKeyVersion" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 2, + "DELETED": 4 + } + } + } + }, + "AutoDetectDecodingConfig": { + "fields": {} + }, + "ExplicitDecodingConfig": { + "fields": { + "encoding": { + "type": "AudioEncoding", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "sampleRateHertz": { + "type": "int32", + "id": 2 + }, + "audioChannelCount": { + "type": "int32", + "id": 3 + } + }, + "nested": { + "AudioEncoding": { + "values": { + "AUDIO_ENCODING_UNSPECIFIED": 0, + "LINEAR16": 1, + "MULAW": 2, + "ALAW": 3 + } + } + } + }, + "SpeakerDiarizationConfig": { + "fields": { + "minSpeakerCount": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "maxSpeakerCount": { + "type": "int32", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RecognitionFeatures": { + "fields": { + "profanityFilter": { + "type": "bool", + "id": 1 + }, + "enableWordTimeOffsets": { + "type": "bool", + "id": 2 + }, + "enableWordConfidence": { + "type": "bool", + "id": 3 + }, + "enableAutomaticPunctuation": { + "type": "bool", + "id": 4 + }, + "enableSpokenPunctuation": { + "type": "bool", + "id": 14 + }, + "enableSpokenEmojis": { + "type": "bool", + "id": 15 + }, + "multiChannelMode": { + "type": "MultiChannelMode", + "id": 17 + }, + "diarizationConfig": { + "type": "SpeakerDiarizationConfig", + "id": 9 + }, + "maxAlternatives": { + "type": "int32", + "id": 16 + } + }, + "nested": { + "MultiChannelMode": { + "values": { + "MULTI_CHANNEL_MODE_UNSPECIFIED": 0, + "SEPARATE_RECOGNITION_PER_CHANNEL": 1 + } + } + } + }, + "SpeechAdaptation": { + "fields": { + "phraseSets": { + "rule": "repeated", + "type": "AdaptationPhraseSet", + "id": 1 + }, + "customClasses": { + "rule": "repeated", + "type": "CustomClass", + "id": 2 + } + }, + "nested": { + "AdaptationPhraseSet": { + "oneofs": { + "value": { + "oneof": [ + "phraseSet", + "inlinePhraseSet" + ] + } + }, + "fields": { + "phraseSet": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + }, + "inlinePhraseSet": { + "type": "PhraseSet", + "id": 2 + } + } + } + } + }, + "RecognitionConfig": { + "oneofs": { + "decodingConfig": { + "oneof": [ + "autoDecodingConfig", + "explicitDecodingConfig" + ] + } + }, + "fields": { + "autoDecodingConfig": { + "type": "AutoDetectDecodingConfig", + "id": 7 + }, + "explicitDecodingConfig": { + "type": "ExplicitDecodingConfig", + "id": 8 + }, + "features": { + "type": "RecognitionFeatures", + "id": 2 + }, + "adaptation": { + "type": "SpeechAdaptation", + "id": 6 + } + } + }, + "RecognizeRequest": { + "oneofs": { + "audioSource": { + "oneof": [ + "content", + "uri" + ] + } + }, + "fields": { + "recognizer": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + }, + "config": { + "type": "RecognitionConfig", + "id": 1 + }, + "configMask": { + "type": "google.protobuf.FieldMask", + "id": 8 + }, + "content": { + "type": "bytes", + "id": 5 + }, + "uri": { + "type": "string", + "id": 6 + } + } + }, + "RecognitionResponseMetadata": { + "fields": { + "totalBilledDuration": { + "type": "google.protobuf.Duration", + "id": 6 + } + } + }, + "SpeechRecognitionAlternative": { + "fields": { + "transcript": { + "type": "string", + "id": 1 + }, + "confidence": { + "type": "float", + "id": 2 + }, + "words": { + "rule": "repeated", + "type": "WordInfo", + "id": 3 + } + } + }, + "WordInfo": { + "fields": { + "startOffset": { + "type": "google.protobuf.Duration", + "id": 1 + }, + "endOffset": { + "type": "google.protobuf.Duration", + "id": 2 + }, + "word": { + "type": "string", + "id": 3 + }, + "confidence": { + "type": "float", + "id": 4 + }, + "speakerLabel": { + "type": "string", + "id": 6 + } + } + }, + "SpeechRecognitionResult": { + "fields": { + "alternatives": { + "rule": "repeated", + "type": "SpeechRecognitionAlternative", + "id": 1 + }, + "channelTag": { + "type": "int32", + "id": 2 + }, + "resultEndOffset": { + "type": "google.protobuf.Duration", + "id": 4 + }, + "languageCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "RecognizeResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "SpeechRecognitionResult", + "id": 3 + }, + "metadata": { + "type": "RecognitionResponseMetadata", + "id": 2 + } + } + }, + "StreamingRecognitionFeatures": { + "fields": { + "enableVoiceActivityEvents": { + "type": "bool", + "id": 1 + }, + "interimResults": { + "type": "bool", + "id": 2 + }, + "voiceActivityTimeout": { + "type": "VoiceActivityTimeout", + "id": 3 + } + }, + "nested": { + "VoiceActivityTimeout": { + "fields": { + "speechStartTimeout": { + "type": "google.protobuf.Duration", + "id": 1 + }, + "speechEndTimeout": { + "type": "google.protobuf.Duration", + "id": 2 + } + } + } + } + }, + "StreamingRecognitionConfig": { + "fields": { + "config": { + "type": "RecognitionConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "configMask": { + "type": "google.protobuf.FieldMask", + "id": 3 + }, + "streamingFeatures": { + "type": "StreamingRecognitionFeatures", + "id": 2 + } + } + }, + "StreamingRecognizeRequest": { + "oneofs": { + "streamingRequest": { + "oneof": [ + "streamingConfig", + "audio" + ] + } + }, + "fields": { + "recognizer": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + }, + "streamingConfig": { + "type": "StreamingRecognitionConfig", + "id": 6 + }, + "audio": { + "type": "bytes", + "id": 5 + } + } + }, + "BatchRecognizeRequest": { + "fields": { + "recognizer": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Recognizer" + } + }, + "config": { + "type": "RecognitionConfig", + "id": 4 + }, + "configMask": { + "type": "google.protobuf.FieldMask", + "id": 5 + }, + "files": { + "rule": "repeated", + "type": "BatchRecognizeFileMetadata", + "id": 3 + } + } + }, + "BatchRecognizeResponse": { + "fields": { + "results": { + "keyType": "string", + "type": "BatchRecognizeFileResult", + "id": 1 + } + } + }, + "BatchRecognizeFileResult": { + "fields": { + "uri": { + "type": "string", + "id": 1 + }, + "error": { + "type": "google.rpc.Status", + "id": 2 + } + } + }, + "BatchRecognizeTranscriptionMetadata": { + "fields": { + "progressPercent": { + "type": "int32", + "id": 1 + }, + "error": { + "type": "google.rpc.Status", + "id": 2 + }, + "uri": { + "type": "string", + "id": 3 + } + } + }, + "BatchRecognizeMetadata": { + "fields": { + "transcriptionMetadata": { + "keyType": "string", + "type": "BatchRecognizeTranscriptionMetadata", + "id": 1 + } + } + }, + "BatchRecognizeFileMetadata": { + "oneofs": { + "audioSource": { + "oneof": [ + "uri" + ] + } + }, + "fields": { + "uri": { + "type": "string", + "id": 1 + }, + "config": { + "type": "RecognitionConfig", + "id": 4 + }, + "configMask": { + "type": "google.protobuf.FieldMask", + "id": 5 + } + } + }, + "StreamingRecognitionResult": { + "fields": { + "alternatives": { + "rule": "repeated", + "type": "SpeechRecognitionAlternative", + "id": 1 + }, + "isFinal": { + "type": "bool", + "id": 2 + }, + "stability": { + "type": "float", + "id": 3 + }, + "resultEndOffset": { + "type": "google.protobuf.Duration", + "id": 4 + }, + "channelTag": { + "type": "int32", + "id": 5 + }, + "languageCode": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "StreamingRecognizeResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "StreamingRecognitionResult", + "id": 6 + }, + "speechEventType": { + "type": "SpeechEventType", + "id": 3 + }, + "speechEventOffset": { + "type": "google.protobuf.Duration", + "id": 7 + }, + "metadata": { + "type": "RecognitionResponseMetadata", + "id": 5 + } + }, + "nested": { + "SpeechEventType": { + "values": { + "SPEECH_EVENT_TYPE_UNSPECIFIED": 0, + "END_OF_SINGLE_UTTERANCE": 1, + "SPEECH_ACTIVITY_BEGIN": 2, + "SPEECH_ACTIVITY_END": 3 + } + } + } + }, + "Config": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/Config", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/config" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "kmsKeyName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "GetConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/Config" + } + } + } + }, + "UpdateConfigRequest": { + "fields": { + "config": { + "type": "Config", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "CustomClass": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/CustomClass", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/customClasses/{custom_class}", + "(google.api.resource).style": "DECLARATIVE_FRIENDLY" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "uid": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "displayName": { + "type": "string", + "id": 4 + }, + "items": { + "rule": "repeated", + "type": "ClassItem", + "id": 5 + }, + "state": { + "type": "State", + "id": 15, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "deleteTime": { + "type": "google.protobuf.Timestamp", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "annotations": { + "keyType": "string", + "type": "string", + "id": 10 + }, + "etag": { + "type": "string", + "id": 11, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "reconciling": { + "type": "bool", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "kmsKeyName": { + "type": "string", + "id": 13, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "kmsKeyVersionName": { + "type": "string", + "id": 14, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKeyVersion" + } + } + }, + "nested": { + "ClassItem": { + "fields": { + "value": { + "type": "string", + "id": 1 + } + } + }, + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 2, + "DELETED": 4 + } + } + } + }, + "PhraseSet": { + "options": { + "(google.api.resource).type": "speech.googleapis.com/PhraseSet", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/phraseSets/{phrase_set}", + "(google.api.resource).style": "DECLARATIVE_FRIENDLY" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "uid": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "phrases": { + "rule": "repeated", + "type": "Phrase", + "id": 3 + }, + "boost": { + "type": "float", + "id": 4 + }, + "displayName": { + "type": "string", + "id": 5 + }, + "state": { + "type": "State", + "id": 15, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "deleteTime": { + "type": "google.protobuf.Timestamp", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "annotations": { + "keyType": "string", + "type": "string", + "id": 10 + }, + "etag": { + "type": "string", + "id": 11, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "reconciling": { + "type": "bool", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "kmsKeyName": { + "type": "string", + "id": 13, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "kmsKeyVersionName": { + "type": "string", + "id": 14, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKeyVersion" + } + } + }, + "nested": { + "Phrase": { + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "boost": { + "type": "float", + "id": 2 + } + } + }, + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 2, + "DELETED": 4 + } + } + } + }, + "CreateCustomClassRequest": { + "fields": { + "customClass": { + "type": "CustomClass", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "customClassId": { + "type": "string", + "id": 3 + }, + "parent": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/CustomClass" + } + } + } + }, + "ListCustomClassesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "showDeleted": { + "type": "bool", + "id": 4 + } + } + }, + "ListCustomClassesResponse": { + "fields": { + "customClasses": { + "rule": "repeated", + "type": "CustomClass", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "GetCustomClassRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/CustomClass" + } + } + } + }, + "UpdateCustomClassRequest": { + "fields": { + "customClass": { + "type": "CustomClass", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + } + }, + "DeleteCustomClassRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/CustomClass" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 4 + }, + "etag": { + "type": "string", + "id": 3 + } + } + }, + "UndeleteCustomClassRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/CustomClass" + } + }, + "validateOnly": { + "type": "bool", + "id": 3 + }, + "etag": { + "type": "string", + "id": 4 + } + } + }, + "CreatePhraseSetRequest": { + "fields": { + "phraseSet": { + "type": "PhraseSet", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "phraseSetId": { + "type": "string", + "id": 3 + }, + "parent": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/PhraseSet" + } + } + } + }, + "ListPhraseSetsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "showDeleted": { + "type": "bool", + "id": 4 + } + } + }, + "ListPhraseSetsResponse": { + "fields": { + "phraseSets": { + "rule": "repeated", + "type": "PhraseSet", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "GetPhraseSetRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + } + } + }, + "UpdatePhraseSetRequest": { + "fields": { + "phraseSet": { + "type": "PhraseSet", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + } + }, + "DeletePhraseSetRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + }, + "validateOnly": { + "type": "bool", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 4 + }, + "etag": { + "type": "string", + "id": 3 + } + } + }, + "UndeletePhraseSetRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + }, + "validateOnly": { + "type": "bool", + "id": 3 + }, + "etag": { + "type": "string", + "id": 4 + } + } + } + } } } } diff --git a/packages/google-cloud-speech/samples/generated/v2/snippet_metadata.google.cloud.speech.v2.json b/packages/google-cloud-speech/samples/generated/v2/snippet_metadata.google.cloud.speech.v2.json new file mode 100644 index 00000000000..8ecdc170c89 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/snippet_metadata.google.cloud.speech.v2.json @@ -0,0 +1,1131 @@ +{ + "clientLibrary": { + "name": "nodejs-speech", + "version": "5.0.3", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.speech.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "speech_v2_generated_Speech_CreateRecognizer_async", + "title": "Speech createRecognizer Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Recognizer][google.cloud.speech.v2.Recognizer].", + "canonical": true, + "file": "speech.create_recognizer.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateRecognizer", + "fullName": "google.cloud.speech.v2.Speech.CreateRecognizer", + "async": true, + "parameters": [ + { + "name": "recognizer", + "type": ".google.cloud.speech.v2.Recognizer" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "recognizer_id", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "CreateRecognizer", + "fullName": "google.cloud.speech.v2.Speech.CreateRecognizer", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_ListRecognizers_async", + "title": "Speech listRecognizers Sample", + "origin": "API_DEFINITION", + "description": " Lists Recognizers.", + "canonical": true, + "file": "speech.list_recognizers.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRecognizers", + "fullName": "google.cloud.speech.v2.Speech.ListRecognizers", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.speech.v2.ListRecognizersResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "ListRecognizers", + "fullName": "google.cloud.speech.v2.Speech.ListRecognizers", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_GetRecognizer_async", + "title": "Speech getRecognizer Sample", + "origin": "API_DEFINITION", + "description": " Returns the requested [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested recognizer doesn't exist.", + "canonical": true, + "file": "speech.get_recognizer.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRecognizer", + "fullName": "google.cloud.speech.v2.Speech.GetRecognizer", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v2.Recognizer", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "GetRecognizer", + "fullName": "google.cloud.speech.v2.Speech.GetRecognizer", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UpdateRecognizer_async", + "title": "Speech updateRecognizer Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Recognizer][google.cloud.speech.v2.Recognizer].", + "canonical": true, + "file": "speech.update_recognizer.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateRecognizer", + "fullName": "google.cloud.speech.v2.Speech.UpdateRecognizer", + "async": true, + "parameters": [ + { + "name": "recognizer", + "type": ".google.cloud.speech.v2.Recognizer" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UpdateRecognizer", + "fullName": "google.cloud.speech.v2.Speech.UpdateRecognizer", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_DeleteRecognizer_async", + "title": "Speech deleteRecognizer Sample", + "origin": "API_DEFINITION", + "description": " Deletes the [Recognizer][google.cloud.speech.v2.Recognizer].", + "canonical": true, + "file": "speech.delete_recognizer.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRecognizer", + "fullName": "google.cloud.speech.v2.Speech.DeleteRecognizer", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "DeleteRecognizer", + "fullName": "google.cloud.speech.v2.Speech.DeleteRecognizer", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UndeleteRecognizer_async", + "title": "Speech undeleteRecognizer Sample", + "origin": "API_DEFINITION", + "description": " Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer].", + "canonical": true, + "file": "speech.undelete_recognizer.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteRecognizer", + "fullName": "google.cloud.speech.v2.Speech.UndeleteRecognizer", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UndeleteRecognizer", + "fullName": "google.cloud.speech.v2.Speech.UndeleteRecognizer", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_Recognize_async", + "title": "Speech recognize Sample", + "origin": "API_DEFINITION", + "description": " Performs synchronous Speech recognition: receive results after all audio has been sent and processed.", + "canonical": true, + "file": "speech.recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 98, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v2.Speech.Recognize", + "async": true, + "parameters": [ + { + "name": "recognizer", + "type": "TYPE_STRING" + }, + { + "name": "config", + "type": ".google.cloud.speech.v2.RecognitionConfig" + }, + { + "name": "config_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "content", + "type": "TYPE_BYTES" + }, + { + "name": "uri", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v2.RecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v2.Speech.Recognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_StreamingRecognize_async", + "title": "Speech streamingRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).", + "canonical": true, + "file": "speech.streaming_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v2.Speech.StreamingRecognize", + "async": true, + "parameters": [ + { + "name": "recognizer", + "type": "TYPE_STRING" + }, + { + "name": "streaming_config", + "type": ".google.cloud.speech.v2.StreamingRecognitionConfig" + }, + { + "name": "audio", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.speech.v2.StreamingRecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v2.Speech.StreamingRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_BatchRecognize_async", + "title": "Speech batchRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running operation that can be polled to see when the transcriptions are finished.", + "canonical": true, + "file": "speech.batch_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchRecognize", + "fullName": "google.cloud.speech.v2.Speech.BatchRecognize", + "async": true, + "parameters": [ + { + "name": "recognizer", + "type": "TYPE_STRING" + }, + { + "name": "config", + "type": ".google.cloud.speech.v2.RecognitionConfig" + }, + { + "name": "config_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "files", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "BatchRecognize", + "fullName": "google.cloud.speech.v2.Speech.BatchRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_GetConfig_async", + "title": "Speech getConfig Sample", + "origin": "API_DEFINITION", + "description": " Returns the requested [Config][google.cloud.speech.v2.Config].", + "canonical": true, + "file": "speech.get_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetConfig", + "fullName": "google.cloud.speech.v2.Speech.GetConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v2.Config", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "GetConfig", + "fullName": "google.cloud.speech.v2.Speech.GetConfig", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UpdateConfig_async", + "title": "Speech updateConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Config][google.cloud.speech.v2.Config].", + "canonical": true, + "file": "speech.update_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateConfig", + "fullName": "google.cloud.speech.v2.Speech.UpdateConfig", + "async": true, + "parameters": [ + { + "name": "config", + "type": ".google.cloud.speech.v2.Config" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.speech.v2.Config", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UpdateConfig", + "fullName": "google.cloud.speech.v2.Speech.UpdateConfig", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_CreateCustomClass_async", + "title": "Speech createCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Creates a [CustomClass][google.cloud.speech.v2.CustomClass].", + "canonical": true, + "file": "speech.create_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v2.Speech.CreateCustomClass", + "async": true, + "parameters": [ + { + "name": "custom_class", + "type": ".google.cloud.speech.v2.CustomClass" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "custom_class_id", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v2.Speech.CreateCustomClass", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_ListCustomClasses_async", + "title": "Speech listCustomClasses Sample", + "origin": "API_DEFINITION", + "description": " Lists CustomClasses.", + "canonical": true, + "file": "speech.list_custom_classes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v2.Speech.ListCustomClasses", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.speech.v2.ListCustomClassesResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v2.Speech.ListCustomClasses", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_GetCustomClass_async", + "title": "Speech getCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Returns the requested [CustomClass][google.cloud.speech.v2.CustomClass].", + "canonical": true, + "file": "speech.get_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v2.Speech.GetCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v2.CustomClass", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v2.Speech.GetCustomClass", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UpdateCustomClass_async", + "title": "Speech updateCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CustomClass][google.cloud.speech.v2.CustomClass].", + "canonical": true, + "file": "speech.update_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v2.Speech.UpdateCustomClass", + "async": true, + "parameters": [ + { + "name": "custom_class", + "type": ".google.cloud.speech.v2.CustomClass" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v2.Speech.UpdateCustomClass", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_DeleteCustomClass_async", + "title": "Speech deleteCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Deletes the [CustomClass][google.cloud.speech.v2.CustomClass].", + "canonical": true, + "file": "speech.delete_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v2.Speech.DeleteCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v2.Speech.DeleteCustomClass", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UndeleteCustomClass_async", + "title": "Speech undeleteCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass].", + "canonical": true, + "file": "speech.undelete_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteCustomClass", + "fullName": "google.cloud.speech.v2.Speech.UndeleteCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UndeleteCustomClass", + "fullName": "google.cloud.speech.v2.Speech.UndeleteCustomClass", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_CreatePhraseSet_async", + "title": "Speech createPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet].", + "canonical": true, + "file": "speech.create_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.CreatePhraseSet", + "async": true, + "parameters": [ + { + "name": "phrase_set", + "type": ".google.cloud.speech.v2.PhraseSet" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "phrase_set_id", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.CreatePhraseSet", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_ListPhraseSets_async", + "title": "Speech listPhraseSets Sample", + "origin": "API_DEFINITION", + "description": " Lists PhraseSets.", + "canonical": true, + "file": "speech.list_phrase_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPhraseSets", + "fullName": "google.cloud.speech.v2.Speech.ListPhraseSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.speech.v2.ListPhraseSetsResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "ListPhraseSets", + "fullName": "google.cloud.speech.v2.Speech.ListPhraseSets", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_GetPhraseSet_async", + "title": "Speech getPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Returns the requested [PhraseSet][google.cloud.speech.v2.PhraseSet].", + "canonical": true, + "file": "speech.get_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v2.Speech.GetPhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v2.PhraseSet", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v2.Speech.GetPhraseSet", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UpdatePhraseSet_async", + "title": "Speech updatePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet].", + "canonical": true, + "file": "speech.update_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.UpdatePhraseSet", + "async": true, + "parameters": [ + { + "name": "phrase_set", + "type": ".google.cloud.speech.v2.PhraseSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.UpdatePhraseSet", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_DeletePhraseSet_async", + "title": "Speech deletePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet].", + "canonical": true, + "file": "speech.delete_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.DeletePhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.DeletePhraseSet", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + }, + { + "regionTag": "speech_v2_generated_Speech_UndeletePhraseSet_async", + "title": "Speech undeletePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet].", + "canonical": true, + "file": "speech.undelete_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeletePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.UndeletePhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v2.SpeechClient" + }, + "method": { + "shortName": "UndeletePhraseSet", + "fullName": "google.cloud.speech.v2.Speech.UndeletePhraseSet", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v2.Speech" + } + } + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.batch_recognize.js b/packages/google-cloud-speech/samples/generated/v2/speech.batch_recognize.js new file mode 100644 index 00000000000..38711397344 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.batch_recognize.js @@ -0,0 +1,91 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(recognizer) { + // [START speech_v2_generated_Speech_BatchRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the recognizer to be used for ASR. + */ + // const recognizer = 'abc123' + /** + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * config_mask google.cloud.speech.v2.BatchRecognizeRequest.config_mask + * field can be used to override parts of the + * default_recognition_config google.cloud.speech.v2.Recognizer.default_recognition_config + * of the Recognizer resource. + */ + // const config = {} + /** + * The list of fields in + * config google.cloud.speech.v2.BatchRecognizeRequest.config that override + * the values in the + * default_recognition_config google.cloud.speech.v2.Recognizer.default_recognition_config + * of the recognizer during this recognition request. If no mask is provided, + * all given fields in + * config google.cloud.speech.v2.BatchRecognizeRequest.config override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * config google.cloud.speech.v2.BatchRecognizeRequest.config completely + * overrides and replaces the config in the recognizer for this recognition + * request. + */ + // const configMask = {} + /** + * Audio files with file metadata for ASR. + */ + // const files = 1234 + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callBatchRecognize() { + // Construct request + const request = { + recognizer, + }; + + // Run request + const [operation] = await speechClient.batchRecognize(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchRecognize(); + // [END speech_v2_generated_Speech_BatchRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.create_custom_class.js b/packages/google-cloud-speech/samples/generated/v2/speech.create_custom_class.js new file mode 100644 index 00000000000..9527870a700 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.create_custom_class.js @@ -0,0 +1,80 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(customClass, parent) { + // [START speech_v2_generated_Speech_CreateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The CustomClass to create. + */ + // const customClass = {} + /** + * If set, validate the request and preview the CustomClass, but do not + * actually create it. + */ + // const validateOnly = true + /** + * The ID to use for the CustomClass, which will become the final component of + * the CustomClass's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-/. + */ + // const customClassId = 'abc123' + /** + * Required. The project and location where this CustomClass will be created. + * The expected format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callCreateCustomClass() { + // Construct request + const request = { + customClass, + parent, + }; + + // Run request + const [operation] = await speechClient.createCustomClass(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateCustomClass(); + // [END speech_v2_generated_Speech_CreateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.create_phrase_set.js b/packages/google-cloud-speech/samples/generated/v2/speech.create_phrase_set.js new file mode 100644 index 00000000000..ac0043eda5e --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.create_phrase_set.js @@ -0,0 +1,80 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(phraseSet, parent) { + // [START speech_v2_generated_Speech_CreatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The PhraseSet to create. + */ + // const phraseSet = {} + /** + * If set, validate the request and preview the PhraseSet, but do not + * actually create it. + */ + // const validateOnly = true + /** + * The ID to use for the PhraseSet, which will become the final component of + * the PhraseSet's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-/. + */ + // const phraseSetId = 'abc123' + /** + * Required. The project and location where this PhraseSet will be created. + * The expected format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callCreatePhraseSet() { + // Construct request + const request = { + phraseSet, + parent, + }; + + // Run request + const [operation] = await speechClient.createPhraseSet(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreatePhraseSet(); + // [END speech_v2_generated_Speech_CreatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.create_recognizer.js b/packages/google-cloud-speech/samples/generated/v2/speech.create_recognizer.js new file mode 100644 index 00000000000..29613c7d338 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.create_recognizer.js @@ -0,0 +1,80 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(recognizer, parent) { + // [START speech_v2_generated_Speech_CreateRecognizer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Recognizer to create. + */ + // const recognizer = {} + /** + * If set, validate the request and preview the Recognizer, but do not + * actually create it. + */ + // const validateOnly = true + /** + * The ID to use for the Recognizer, which will become the final component of + * the Recognizer's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-/. + */ + // const recognizerId = 'abc123' + /** + * Required. The project and location where this Recognizer will be created. + * The expected format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callCreateRecognizer() { + // Construct request + const request = { + recognizer, + parent, + }; + + // Run request + const [operation] = await speechClient.createRecognizer(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateRecognizer(); + // [END speech_v2_generated_Speech_CreateRecognizer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.delete_custom_class.js b/packages/google-cloud-speech/samples/generated/v2/speech.delete_custom_class.js new file mode 100644 index 00000000000..273a7fb746d --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.delete_custom_class.js @@ -0,0 +1,80 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_DeleteCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the CustomClass to delete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the deleted CustomClass, but do + * not actually delete it. + */ + // const validateOnly = true + /** + * If set to true, and the CustomClass is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + */ + // const allowMissing = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callDeleteCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.deleteCustomClass(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteCustomClass(); + // [END speech_v2_generated_Speech_DeleteCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.delete_phrase_set.js b/packages/google-cloud-speech/samples/generated/v2/speech.delete_phrase_set.js new file mode 100644 index 00000000000..ceef8b27952 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.delete_phrase_set.js @@ -0,0 +1,79 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_DeletePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the PhraseSet to delete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the deleted PhraseSet, but do not + * actually delete it. + */ + // const validateOnly = true + /** + * If set to true, and the PhraseSet is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + */ + // const allowMissing = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callDeletePhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.deletePhraseSet(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeletePhraseSet(); + // [END speech_v2_generated_Speech_DeletePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.delete_recognizer.js b/packages/google-cloud-speech/samples/generated/v2/speech.delete_recognizer.js new file mode 100644 index 00000000000..bfe1e3d60f7 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.delete_recognizer.js @@ -0,0 +1,79 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_DeleteRecognizer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Recognizer to delete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the deleted Recognizer, but do not + * actually delete it. + */ + // const validateOnly = true + /** + * If set to true, and the Recognizer is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + */ + // const allowMissing = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callDeleteRecognizer() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.deleteRecognizer(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteRecognizer(); + // [END speech_v2_generated_Speech_DeleteRecognizer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.get_config.js b/packages/google-cloud-speech/samples/generated/v2/speech.get_config.js new file mode 100644 index 00000000000..99a2f0c0025 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.get_config.js @@ -0,0 +1,63 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_GetConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the config to retrieve. There is exactly one config + * resource per project per location. The expected format is + * `projects/{project}/locations/{location}/config`. + */ + // const name = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callGetConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getConfig(request); + console.log(response); + } + + callGetConfig(); + // [END speech_v2_generated_Speech_GetConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.get_custom_class.js b/packages/google-cloud-speech/samples/generated/v2/speech.get_custom_class.js new file mode 100644 index 00000000000..733eeb0171b --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.get_custom_class.js @@ -0,0 +1,62 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_GetCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the CustomClass to retrieve. The expected format is + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + */ + // const name = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callGetCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getCustomClass(request); + console.log(response); + } + + callGetCustomClass(); + // [END speech_v2_generated_Speech_GetCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.get_phrase_set.js b/packages/google-cloud-speech/samples/generated/v2/speech.get_phrase_set.js new file mode 100644 index 00000000000..abdf07d9087 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.get_phrase_set.js @@ -0,0 +1,62 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_GetPhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the PhraseSet to retrieve. The expected format is + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + */ + // const name = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callGetPhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getPhraseSet(request); + console.log(response); + } + + callGetPhraseSet(); + // [END speech_v2_generated_Speech_GetPhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.get_recognizer.js b/packages/google-cloud-speech/samples/generated/v2/speech.get_recognizer.js new file mode 100644 index 00000000000..c08c8b9496a --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.get_recognizer.js @@ -0,0 +1,62 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_GetRecognizer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Recognizer to retrieve. The expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. + */ + // const name = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callGetRecognizer() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getRecognizer(request); + console.log(response); + } + + callGetRecognizer(); + // [END speech_v2_generated_Speech_GetRecognizer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.list_custom_classes.js b/packages/google-cloud-speech/samples/generated/v2/speech.list_custom_classes.js new file mode 100644 index 00000000000..740d5ecdc1d --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.list_custom_classes.js @@ -0,0 +1,84 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v2_generated_Speech_ListCustomClasses_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Number of results per requests. A valid page_size ranges from 0 to 20 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 20, it will be coerced down to 20. Note + * that a call might return fewer results than the requested page size. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous + * ListCustomClasses google.cloud.speech.v2.Speech.ListCustomClasses call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ListCustomClasses google.cloud.speech.v2.Speech.ListCustomClasses must + * match the call that provided the page token. + */ + // const pageToken = 'abc123' + /** + * Whether, or not, to show resources that have been deleted. + */ + // const showDeleted = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callListCustomClasses() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listCustomClassesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCustomClasses(); + // [END speech_v2_generated_Speech_ListCustomClasses_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.list_phrase_sets.js b/packages/google-cloud-speech/samples/generated/v2/speech.list_phrase_sets.js new file mode 100644 index 00000000000..0a54a64a42c --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.list_phrase_sets.js @@ -0,0 +1,83 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v2_generated_Speech_ListPhraseSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 20 PhraseSets will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous + * ListPhraseSets google.cloud.speech.v2.Speech.ListPhraseSets call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ListPhraseSets google.cloud.speech.v2.Speech.ListPhraseSets must match + * the call that provided the page token. + */ + // const pageToken = 'abc123' + /** + * Whether, or not, to show resources that have been deleted. + */ + // const showDeleted = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callListPhraseSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listPhraseSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPhraseSets(); + // [END speech_v2_generated_Speech_ListPhraseSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.list_recognizers.js b/packages/google-cloud-speech/samples/generated/v2/speech.list_recognizers.js new file mode 100644 index 00000000000..7ce62ed5b19 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.list_recognizers.js @@ -0,0 +1,83 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v2_generated_Speech_ListRecognizers_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 20 Recognizers will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous + * ListRecognizers google.cloud.speech.v2.Speech.ListRecognizers call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ListRecognizers google.cloud.speech.v2.Speech.ListRecognizers must match + * the call that provided the page token. + */ + // const pageToken = 'abc123' + /** + * Whether, or not, to show resources that have been deleted. + */ + // const showDeleted = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callListRecognizers() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listRecognizersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRecognizers(); + // [END speech_v2_generated_Speech_ListRecognizers_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.recognize.js b/packages/google-cloud-speech/samples/generated/v2/speech.recognize.js new file mode 100644 index 00000000000..7a4c0bd1bdb --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.recognize.js @@ -0,0 +1,106 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(recognizer) { + // [START speech_v2_generated_Speech_Recognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Recognizer to use during recognition. The + * expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. + */ + // const recognizer = 'abc123' + /** + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * config_mask google.cloud.speech.v2.RecognizeRequest.config_mask field + * can be used to override parts of the + * default_recognition_config google.cloud.speech.v2.Recognizer.default_recognition_config + * of the Recognizer resource. + */ + // const config = {} + /** + * The list of fields in + * config google.cloud.speech.v2.RecognizeRequest.config that override the + * values in the + * default_recognition_config google.cloud.speech.v2.Recognizer.default_recognition_config + * of the recognizer during this recognition request. If no mask is provided, + * all non-default valued fields in + * config google.cloud.speech.v2.RecognizeRequest.config override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * config google.cloud.speech.v2.RecognizeRequest.config completely + * overrides and replaces the config in the recognizer for this recognition + * request. + */ + // const configMask = {} + /** + * The audio data bytes encoded as specified in + * RecognitionConfig google.cloud.speech.v2.RecognitionConfig. As + * with all bytes fields, proto buffers use a pure binary representation, + * whereas JSON representations use base64. + */ + // const content = 'Buffer.from('string')' + /** + * URI that points to a file that contains audio data bytes as specified in + * RecognitionConfig google.cloud.speech.v2.RecognitionConfig. The file + * must not be compressed (for example, gzip). Currently, only Google Cloud + * Storage URIs are supported, which must be specified in the following + * format: `gs://bucket_name/object_name` (other URI formats return + * INVALID_ARGUMENT google.rpc.Code.INVALID_ARGUMENT). For more + * information, see Request + * URIs (https://cloud.google.com/storage/docs/reference-uris). + */ + // const uri = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callRecognize() { + // Construct request + const request = { + recognizer, + }; + + // Run request + const response = await speechClient.recognize(request); + console.log(response); + } + + callRecognize(); + // [END speech_v2_generated_Speech_Recognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.streaming_recognize.js b/packages/google-cloud-speech/samples/generated/v2/speech.streaming_recognize.js new file mode 100644 index 00000000000..a774b855f57 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.streaming_recognize.js @@ -0,0 +1,79 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(recognizer) { + // [START speech_v2_generated_Speech_StreamingRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Streaming recognition should start with an initial request having + * a `recognizer`. Subsequent requests carry the audio data to be recognized. + * The initial request with configuration can be omitted if the Recognizer + * being used has a + * default_recognition_config google.cloud.speech.v2.Recognizer.default_recognition_config. + */ + // const recognizer = 'abc123' + /** + * StreamingRecognitionConfig to be used in this recognition attempt. + * If provided, it will override the default RecognitionConfig stored in the + * Recognizer. + */ + // const streamingConfig = {} + /** + * Inline audio bytes to be Recognized. + */ + // const audio = 'Buffer.from('string')' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callStreamingRecognize() { + // Construct request + const request = { + recognizer, + }; + + // Run request + const stream = await speechClient.streamingRecognize(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamingRecognize(); + // [END speech_v2_generated_Speech_StreamingRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.undelete_custom_class.js b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_custom_class.js new file mode 100644 index 00000000000..0abcc642a30 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_custom_class.js @@ -0,0 +1,75 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_UndeleteCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the CustomClass to undelete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the undeleted CustomClass, but do + * not actually undelete it. + */ + // const validateOnly = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUndeleteCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.undeleteCustomClass(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteCustomClass(); + // [END speech_v2_generated_Speech_UndeleteCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.undelete_phrase_set.js b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_phrase_set.js new file mode 100644 index 00000000000..35c4387ae7e --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_phrase_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_UndeletePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the PhraseSet to undelete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the undeleted PhraseSet, but do + * not actually undelete it. + */ + // const validateOnly = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUndeletePhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.undeletePhraseSet(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeletePhraseSet(); + // [END speech_v2_generated_Speech_UndeletePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.undelete_recognizer.js b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_recognizer.js new file mode 100644 index 00000000000..8f361f35e45 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.undelete_recognizer.js @@ -0,0 +1,74 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START speech_v2_generated_Speech_UndeleteRecognizer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Recognizer to undelete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + */ + // const name = 'abc123' + /** + * If set, validate the request and preview the undeleted Recognizer, but do + * not actually undelete it. + */ + // const validateOnly = true + /** + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + */ + // const etag = 'abc123' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUndeleteRecognizer() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await speechClient.undeleteRecognizer(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteRecognizer(); + // [END speech_v2_generated_Speech_UndeleteRecognizer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.update_config.js b/packages/google-cloud-speech/samples/generated/v2/speech.update_config.js new file mode 100644 index 00000000000..ecff3491798 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.update_config.js @@ -0,0 +1,67 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(config) { + // [START speech_v2_generated_Speech_UpdateConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The config to update. + * The config's `name` field is used to identify the config to be updated. + * The expected format is `projects/{project}/locations/{location}/config`. + */ + // const config = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUpdateConfig() { + // Construct request + const request = { + config, + }; + + // Run request + const response = await speechClient.updateConfig(request); + console.log(response); + } + + callUpdateConfig(); + // [END speech_v2_generated_Speech_UpdateConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.update_custom_class.js b/packages/google-cloud-speech/samples/generated/v2/speech.update_custom_class.js new file mode 100644 index 00000000000..bd9d42fd6e7 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.update_custom_class.js @@ -0,0 +1,75 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(customClass) { + // [START speech_v2_generated_Speech_UpdateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The CustomClass to update. + * The CustomClass's `name` field is used to identify the CustomClass to + * update. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + */ + // const customClass = {} + /** + * The list of fields to be updated. If empty, all fields are considered for + * update. + */ + // const updateMask = {} + /** + * If set, validate the request and preview the updated CustomClass, but do + * not actually update it. + */ + // const validateOnly = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUpdateCustomClass() { + // Construct request + const request = { + customClass, + }; + + // Run request + const [operation] = await speechClient.updateCustomClass(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateCustomClass(); + // [END speech_v2_generated_Speech_UpdateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.update_phrase_set.js b/packages/google-cloud-speech/samples/generated/v2/speech.update_phrase_set.js new file mode 100644 index 00000000000..5f4638e03c4 --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.update_phrase_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(phraseSet) { + // [START speech_v2_generated_Speech_UpdatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The PhraseSet to update. + * The PhraseSet's `name` field is used to identify the PhraseSet to update. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + */ + // const phraseSet = {} + /** + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire PhraseSet resource. + */ + // const updateMask = {} + /** + * If set, validate the request and preview the updated PhraseSet, but do not + * actually update it. + */ + // const validateOnly = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUpdatePhraseSet() { + // Construct request + const request = { + phraseSet, + }; + + // Run request + const [operation] = await speechClient.updatePhraseSet(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdatePhraseSet(); + // [END speech_v2_generated_Speech_UpdatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/samples/generated/v2/speech.update_recognizer.js b/packages/google-cloud-speech/samples/generated/v2/speech.update_recognizer.js new file mode 100644 index 00000000000..c455d5811bb --- /dev/null +++ b/packages/google-cloud-speech/samples/generated/v2/speech.update_recognizer.js @@ -0,0 +1,74 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(recognizer) { + // [START speech_v2_generated_Speech_UpdateRecognizer_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Recognizer to update. + * The Recognizer's `name` field is used to identify the Recognizer to update. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. + */ + // const recognizer = {} + /** + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire Recognizer resource. + */ + // const updateMask = {} + /** + * If set, validate the request and preview the updated Recognizer, but do not + * actually update it. + */ + // const validateOnly = true + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v2; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callUpdateRecognizer() { + // Construct request + const request = { + recognizer, + }; + + // Run request + const [operation] = await speechClient.updateRecognizer(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateRecognizer(); + // [END speech_v2_generated_Speech_UpdateRecognizer_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-speech/src/index.ts b/packages/google-cloud-speech/src/index.ts index b835a4d0efc..0e593bbbd96 100644 --- a/packages/google-cloud-speech/src/index.ts +++ b/packages/google-cloud-speech/src/index.ts @@ -15,6 +15,7 @@ import {ImprovedStreamingClient} from './helpers'; import * as v1p1beta1 from './v1p1beta1'; import * as v1 from './v1'; +import * as v2 from './v2'; // The following code is adapted from http://www.typescriptlang.org/docs/handbook/mixins.html // tslint:disable-next-line no-any @@ -34,14 +35,22 @@ Object.defineProperty( 'streamingRecognize' )! ); +Object.defineProperty( + v2.SpeechClient.prototype, + 'streamingRecognize', + Object.getOwnPropertyDescriptor( + ImprovedStreamingClient.prototype, + 'streamingRecognize' + )! +); const SpeechClient = v1.SpeechClient; type SpeechClient = v1.SpeechClient; const AdaptationClient = v1.AdaptationClient; type AdaptationClient = v1.AdaptationClient; -export {v1, v1p1beta1, SpeechClient, AdaptationClient}; +export {v1, v1p1beta1, v2, SpeechClient, AdaptationClient}; // For compatibility with JavaScript libraries we need to provide this default export: // tslint:disable-next-line no-default-export -export default {v1, v1p1beta1, SpeechClient, AdaptationClient}; +export default {v1, v1p1beta1, v2, SpeechClient, AdaptationClient}; import * as protos from '../protos/protos'; export {protos}; diff --git a/packages/google-cloud-speech/src/v2/gapic_metadata.json b/packages/google-cloud-speech/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..9024d779705 --- /dev/null +++ b/packages/google-cloud-speech/src/v2/gapic_metadata.json @@ -0,0 +1,260 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.speech.v2", + "libraryPackage": "@google-cloud/speech", + "services": { + "Speech": { + "clients": { + "grpc": { + "libraryClient": "SpeechClient", + "rpcs": { + "GetRecognizer": { + "methods": [ + "getRecognizer" + ] + }, + "Recognize": { + "methods": [ + "recognize" + ] + }, + "GetConfig": { + "methods": [ + "getConfig" + ] + }, + "UpdateConfig": { + "methods": [ + "updateConfig" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "StreamingRecognize": { + "methods": [ + "streamingRecognize" + ] + }, + "CreateRecognizer": { + "methods": [ + "createRecognizer" + ] + }, + "UpdateRecognizer": { + "methods": [ + "updateRecognizer" + ] + }, + "DeleteRecognizer": { + "methods": [ + "deleteRecognizer" + ] + }, + "UndeleteRecognizer": { + "methods": [ + "undeleteRecognizer" + ] + }, + "BatchRecognize": { + "methods": [ + "batchRecognize" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "UndeleteCustomClass": { + "methods": [ + "undeleteCustomClass" + ] + }, + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "UndeletePhraseSet": { + "methods": [ + "undeletePhraseSet" + ] + }, + "ListRecognizers": { + "methods": [ + "listRecognizers", + "listRecognizersStream", + "listRecognizersAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + }, + "ListPhraseSets": { + "methods": [ + "listPhraseSets", + "listPhraseSetsStream", + "listPhraseSetsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SpeechClient", + "rpcs": { + "GetRecognizer": { + "methods": [ + "getRecognizer" + ] + }, + "Recognize": { + "methods": [ + "recognize" + ] + }, + "GetConfig": { + "methods": [ + "getConfig" + ] + }, + "UpdateConfig": { + "methods": [ + "updateConfig" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "CreateRecognizer": { + "methods": [ + "createRecognizer" + ] + }, + "UpdateRecognizer": { + "methods": [ + "updateRecognizer" + ] + }, + "DeleteRecognizer": { + "methods": [ + "deleteRecognizer" + ] + }, + "UndeleteRecognizer": { + "methods": [ + "undeleteRecognizer" + ] + }, + "BatchRecognize": { + "methods": [ + "batchRecognize" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "UndeleteCustomClass": { + "methods": [ + "undeleteCustomClass" + ] + }, + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "UndeletePhraseSet": { + "methods": [ + "undeletePhraseSet" + ] + }, + "ListRecognizers": { + "methods": [ + "listRecognizers", + "listRecognizersStream", + "listRecognizersAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + }, + "ListPhraseSets": { + "methods": [ + "listPhraseSets", + "listPhraseSetsStream", + "listPhraseSetsAsync" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-speech/src/v2/index.ts b/packages/google-cloud-speech/src/v2/index.ts new file mode 100644 index 00000000000..9e550a1acbb --- /dev/null +++ b/packages/google-cloud-speech/src/v2/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {SpeechClient} from './speech_client'; diff --git a/packages/google-cloud-speech/src/v2/speech_client.ts b/packages/google-cloud-speech/src/v2/speech_client.ts new file mode 100644 index 00000000000..fb4813a3b96 --- /dev/null +++ b/packages/google-cloud-speech/src/v2/speech_client.ts @@ -0,0 +1,4379 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import {Transform, PassThrough} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/speech_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './speech_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Enables speech transcription and resource management. + * @class + * @memberof v2 + */ +export class SpeechClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + 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}>; + + /** + * Construct an instance of SpeechClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SpeechClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SpeechClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // 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 = { + configPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/config' + ), + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + cryptoKeyVersionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}' + ), + customClassPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/customClasses/{custom_class}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + phraseSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + recognizerPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/recognizers/{recognizer}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listRecognizers: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'recognizers' + ), + listCustomClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'customClasses' + ), + listPhraseSets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'phraseSets' + ), + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + streamingRecognize: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + opts.fallback === 'rest' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v2/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const createRecognizerResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.Recognizer' + ) as gax.protobuf.Type; + const createRecognizerMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const updateRecognizerResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.Recognizer' + ) as gax.protobuf.Type; + const updateRecognizerMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const deleteRecognizerResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.Recognizer' + ) as gax.protobuf.Type; + const deleteRecognizerMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const undeleteRecognizerResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.Recognizer' + ) as gax.protobuf.Type; + const undeleteRecognizerMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const batchRecognizeResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.BatchRecognizeResponse' + ) as gax.protobuf.Type; + const batchRecognizeMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const createCustomClassResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.CustomClass' + ) as gax.protobuf.Type; + const createCustomClassMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const updateCustomClassResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.CustomClass' + ) as gax.protobuf.Type; + const updateCustomClassMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const deleteCustomClassResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.CustomClass' + ) as gax.protobuf.Type; + const deleteCustomClassMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const undeleteCustomClassResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.CustomClass' + ) as gax.protobuf.Type; + const undeleteCustomClassMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const createPhraseSetResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.PhraseSet' + ) as gax.protobuf.Type; + const createPhraseSetMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const updatePhraseSetResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.PhraseSet' + ) as gax.protobuf.Type; + const updatePhraseSetMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const deletePhraseSetResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.PhraseSet' + ) as gax.protobuf.Type; + const deletePhraseSetMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + const undeletePhraseSetResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v2.PhraseSet' + ) as gax.protobuf.Type; + const undeletePhraseSetMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v2.OperationMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + createRecognizer: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createRecognizerResponse.decode.bind(createRecognizerResponse), + createRecognizerMetadata.decode.bind(createRecognizerMetadata) + ), + updateRecognizer: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateRecognizerResponse.decode.bind(updateRecognizerResponse), + updateRecognizerMetadata.decode.bind(updateRecognizerMetadata) + ), + deleteRecognizer: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteRecognizerResponse.decode.bind(deleteRecognizerResponse), + deleteRecognizerMetadata.decode.bind(deleteRecognizerMetadata) + ), + undeleteRecognizer: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteRecognizerResponse.decode.bind(undeleteRecognizerResponse), + undeleteRecognizerMetadata.decode.bind(undeleteRecognizerMetadata) + ), + batchRecognize: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchRecognizeResponse.decode.bind(batchRecognizeResponse), + batchRecognizeMetadata.decode.bind(batchRecognizeMetadata) + ), + createCustomClass: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createCustomClassResponse.decode.bind(createCustomClassResponse), + createCustomClassMetadata.decode.bind(createCustomClassMetadata) + ), + updateCustomClass: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateCustomClassResponse.decode.bind(updateCustomClassResponse), + updateCustomClassMetadata.decode.bind(updateCustomClassMetadata) + ), + deleteCustomClass: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteCustomClassResponse.decode.bind(deleteCustomClassResponse), + deleteCustomClassMetadata.decode.bind(deleteCustomClassMetadata) + ), + undeleteCustomClass: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteCustomClassResponse.decode.bind(undeleteCustomClassResponse), + undeleteCustomClassMetadata.decode.bind(undeleteCustomClassMetadata) + ), + createPhraseSet: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createPhraseSetResponse.decode.bind(createPhraseSetResponse), + createPhraseSetMetadata.decode.bind(createPhraseSetMetadata) + ), + updatePhraseSet: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updatePhraseSetResponse.decode.bind(updatePhraseSetResponse), + updatePhraseSetMetadata.decode.bind(updatePhraseSetMetadata) + ), + deletePhraseSet: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deletePhraseSetResponse.decode.bind(deletePhraseSetResponse), + deletePhraseSetMetadata.decode.bind(deletePhraseSetMetadata) + ), + undeletePhraseSet: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeletePhraseSetResponse.decode.bind(undeletePhraseSetResponse), + undeletePhraseSetMetadata.decode.bind(undeletePhraseSetMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.speech.v2.Speech', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.speechStub) { + return this.speechStub; + } + + // Put together the "service stub" for + // google.cloud.speech.v2.Speech. + this.speechStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v2.Speech' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v2.Speech, + this._opts, + this._providedCustomServicePath + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const speechStubMethods = [ + 'createRecognizer', + 'listRecognizers', + 'getRecognizer', + 'updateRecognizer', + 'deleteRecognizer', + 'undeleteRecognizer', + 'recognize', + 'streamingRecognize', + 'batchRecognize', + 'getConfig', + 'updateConfig', + 'createCustomClass', + 'listCustomClasses', + 'getCustomClass', + 'updateCustomClass', + 'deleteCustomClass', + 'undeleteCustomClass', + 'createPhraseSet', + 'listPhraseSets', + 'getPhraseSet', + 'updatePhraseSet', + 'deletePhraseSet', + 'undeletePhraseSet', + ]; + for (const methodName of speechStubMethods) { + const callPromise = this.speechStub.then( + stub => + (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit( + 'error', + new this._gaxModule.GoogleError( + 'The client has already been closed.' + ) + ); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.speechStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'speech.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'speech.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + /** + * Returns the requested + * {@link google.cloud.speech.v2.Recognizer|Recognizer}. Fails with + * {@link google.rpc.Code.NOT_FOUND|NOT_FOUND} if the requested recognizer doesn't + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to retrieve. The expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Recognizer]{@link google.cloud.speech.v2.Recognizer}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.get_recognizer.js + * region_tag:speech_v2_generated_Speech_GetRecognizer_async + */ + getRecognizer( + request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | undefined, + {} | undefined + ] + >; + getRecognizer( + request: protos.google.cloud.speech.v2.IGetRecognizerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + > + ): void; + getRecognizer( + request: protos.google.cloud.speech.v2.IGetRecognizerRequest, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + > + ): void; + getRecognizer( + request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.IRecognizer, + | protos.google.cloud.speech.v2.IGetRecognizerRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRecognizer(request, options, callback); + } + /** + * Performs synchronous Speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.recognizer + * Required. The name of the Recognizer to use during recognition. The + * expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. + * @param {google.cloud.speech.v2.RecognitionConfig} request.config + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * {@link google.cloud.speech.v2.RecognizeRequest.config_mask|config_mask} field + * can be used to override parts of the + * {@link google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the Recognizer resource. + * @param {google.protobuf.FieldMask} request.configMask + * The list of fields in + * {@link google.cloud.speech.v2.RecognizeRequest.config|config} that override the + * values in the + * {@link google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the recognizer during this recognition request. If no mask is provided, + * all non-default valued fields in + * {@link google.cloud.speech.v2.RecognizeRequest.config|config} override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * {@link google.cloud.speech.v2.RecognizeRequest.config|config} completely + * overrides and replaces the config in the recognizer for this recognition + * request. + * @param {Buffer} request.content + * The audio data bytes encoded as specified in + * {@link google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. As + * with all bytes fields, proto buffers use a pure binary representation, + * whereas JSON representations use base64. + * @param {string} request.uri + * URI that points to a file that contains audio data bytes as specified in + * {@link google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. The file + * must not be compressed (for example, gzip). Currently, only Google Cloud + * Storage URIs are supported, which must be specified in the following + * format: `gs://bucket_name/object_name` (other URI formats return + * {@link google.rpc.Code.INVALID_ARGUMENT|INVALID_ARGUMENT}). For more + * information, see [Request + * URIs](https://cloud.google.com/storage/docs/reference-uris). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RecognizeResponse]{@link google.cloud.speech.v2.RecognizeResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.recognize.js + * region_tag:speech_v2_generated_Speech_Recognize_async + */ + recognize( + request?: protos.google.cloud.speech.v2.IRecognizeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | undefined, + {} | undefined + ] + >; + recognize( + request: protos.google.cloud.speech.v2.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + > + ): void; + recognize( + request: protos.google.cloud.speech.v2.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + > + ): void; + recognize( + request?: protos.google.cloud.speech.v2.IRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + recognizer: request.recognizer ?? '', + }); + this.initialize(); + return this.innerApiCalls.recognize(request, options, callback); + } + /** + * Returns the requested {@link google.cloud.speech.v2.Config|Config}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the config to retrieve. There is exactly one config + * resource per project per location. The expected format is + * `projects/{project}/locations/{location}/config`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Config]{@link google.cloud.speech.v2.Config}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.get_config.js + * region_tag:speech_v2_generated_Speech_GetConfig_async + */ + getConfig( + request?: protos.google.cloud.speech.v2.IGetConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | undefined, + {} | undefined + ] + >; + getConfig( + request: protos.google.cloud.speech.v2.IGetConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + getConfig( + request: protos.google.cloud.speech.v2.IGetConfigRequest, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + getConfig( + request?: protos.google.cloud.speech.v2.IGetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getConfig(request, options, callback); + } + /** + * Updates the {@link google.cloud.speech.v2.Config|Config}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Config} request.config + * Required. The config to update. + * + * The config's `name` field is used to identify the config to be updated. + * The expected format is `projects/{project}/locations/{location}/config`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Config]{@link google.cloud.speech.v2.Config}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_config.js + * region_tag:speech_v2_generated_Speech_UpdateConfig_async + */ + updateConfig( + request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | undefined, + {} | undefined + ] + >; + updateConfig( + request: protos.google.cloud.speech.v2.IUpdateConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + updateConfig( + request: protos.google.cloud.speech.v2.IUpdateConfigRequest, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + updateConfig( + request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'config.name': request.config!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateConfig(request, options, callback); + } + /** + * Returns the requested + * {@link google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to retrieve. The expected format is + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CustomClass]{@link google.cloud.speech.v2.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.get_custom_class.js + * region_tag:speech_v2_generated_Speech_GetCustomClass_async + */ + getCustomClass( + request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | undefined, + {} | undefined + ] + >; + getCustomClass( + request: protos.google.cloud.speech.v2.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + > + ): void; + getCustomClass( + request: protos.google.cloud.speech.v2.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + > + ): void; + getCustomClass( + request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.ICustomClass, + | protos.google.cloud.speech.v2.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCustomClass(request, options, callback); + } + /** + * Returns the requested + * {@link google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to retrieve. The expected format is + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PhraseSet]{@link google.cloud.speech.v2.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/speech.get_phrase_set.js + * region_tag:speech_v2_generated_Speech_GetPhraseSet_async + */ + getPhraseSet( + request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | undefined, + {} | undefined + ] + >; + getPhraseSet( + request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + > + ): void; + getPhraseSet( + request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + > + ): void; + getPhraseSet( + request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getPhraseSet(request, options, callback); + } + + /** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v2.StreamingRecognizeRequest} for write() method, and + * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v2.StreamingRecognizeResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v2/speech.streaming_recognize.js + * region_tag:speech_v2_generated_Speech_StreamingRecognize_async + */ + _streamingRecognize(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamingRecognize(null, options); + } + + /** + * Creates a {@link google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Recognizer} request.recognizer + * Required. The Recognizer to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the Recognizer, but do not + * actually create it. + * @param {string} request.recognizerId + * The ID to use for the Recognizer, which will become the final component of + * the Recognizer's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this Recognizer will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_recognizer.js + * region_tag:speech_v2_generated_Speech_CreateRecognizer_async + */ + createRecognizer( + request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createRecognizer( + request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createRecognizer( + request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createRecognizer( + request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createRecognizer(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_recognizer.js + * region_tag:speech_v2_generated_Speech_CreateRecognizer_async + */ + async checkCreateRecognizerProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createRecognizer, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Updates the {@link google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Recognizer} request.recognizer + * Required. The Recognizer to update. + * + * The Recognizer's `name` field is used to identify the Recognizer to update. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire Recognizer resource. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated Recognizer, but do not + * actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_recognizer.js + * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async + */ + updateRecognizer( + request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + updateRecognizer( + request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateRecognizer( + request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateRecognizer( + request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'recognizer.name': request.recognizer!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateRecognizer(request, options, callback); + } + /** + * Check the status of the long running operation returned by `updateRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_recognizer.js + * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async + */ + async checkUpdateRecognizerProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateRecognizer, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Deletes the {@link google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to delete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted Recognizer, but do not + * actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the Recognizer is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_recognizer.js + * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async + */ + deleteRecognizer( + request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + deleteRecognizer( + request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deleteRecognizer( + request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deleteRecognizer( + request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteRecognizer(request, options, callback); + } + /** + * Check the status of the long running operation returned by `deleteRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_recognizer.js + * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async + */ + async checkDeleteRecognizerProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteRecognizer, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Undeletes the {@link google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to undelete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted Recognizer, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_recognizer.js + * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async + */ + undeleteRecognizer( + request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + undeleteRecognizer( + request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeleteRecognizer( + request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeleteRecognizer( + request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeleteRecognizer(request, options, callback); + } + /** + * Check the status of the long running operation returned by `undeleteRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_recognizer.js + * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async + */ + async checkUndeleteRecognizerProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.undeleteRecognizer, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Performs batch asynchronous speech recognition: send a request with N + * audio files and receive a long running operation that can be polled to see + * when the transcriptions are finished. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.recognizer + * Required. Resource name of the recognizer to be used for ASR. + * @param {google.cloud.speech.v2.RecognitionConfig} request.config + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * {@link google.cloud.speech.v2.BatchRecognizeRequest.config_mask|config_mask} + * field can be used to override parts of the + * {@link google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the Recognizer resource. + * @param {google.protobuf.FieldMask} request.configMask + * The list of fields in + * {@link google.cloud.speech.v2.BatchRecognizeRequest.config|config} that override + * the values in the + * {@link google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the recognizer during this recognition request. If no mask is provided, + * all given fields in + * {@link google.cloud.speech.v2.BatchRecognizeRequest.config|config} override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * {@link google.cloud.speech.v2.BatchRecognizeRequest.config|config} completely + * overrides and replaces the config in the recognizer for this recognition + * request. + * @param {number[]} request.files + * Audio files with file metadata for ASR. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.batch_recognize.js + * region_tag:speech_v2_generated_Speech_BatchRecognize_async + */ + batchRecognize( + request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + batchRecognize( + request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + batchRecognize( + request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + batchRecognize( + request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + recognizer: request.recognizer ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchRecognize(request, options, callback); + } + /** + * Check the status of the long running operation returned by `batchRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.batch_recognize.js + * region_tag:speech_v2_generated_Speech_BatchRecognize_async + */ + async checkBatchRecognizeProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.BatchRecognizeResponse, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchRecognize, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.BatchRecognizeResponse, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Creates a {@link google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.CustomClass} request.customClass + * Required. The CustomClass to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the CustomClass, but do not + * actually create it. + * @param {string} request.customClassId + * The ID to use for the CustomClass, which will become the final component of + * the CustomClass's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this CustomClass will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_custom_class.js + * region_tag:speech_v2_generated_Speech_CreateCustomClass_async + */ + createCustomClass( + request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createCustomClass( + request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createCustomClass( + request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createCustomClass( + request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createCustomClass(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_custom_class.js + * region_tag:speech_v2_generated_Speech_CreateCustomClass_async + */ + async checkCreateCustomClassProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCustomClass, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Updates the {@link google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.CustomClass} request.customClass + * Required. The CustomClass to update. + * + * The CustomClass's `name` field is used to identify the CustomClass to + * update. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. If empty, all fields are considered for + * update. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated CustomClass, but do + * not actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_custom_class.js + * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async + */ + updateCustomClass( + request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + updateCustomClass( + request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateCustomClass( + request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updateCustomClass( + request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCustomClass(request, options, callback); + } + /** + * Check the status of the long running operation returned by `updateCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_custom_class.js + * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async + */ + async checkUpdateCustomClassProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateCustomClass, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Deletes the {@link google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to delete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted CustomClass, but do + * not actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the CustomClass is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_custom_class.js + * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async + */ + deleteCustomClass( + request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + deleteCustomClass( + request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deleteCustomClass( + request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deleteCustomClass( + request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteCustomClass(request, options, callback); + } + /** + * Check the status of the long running operation returned by `deleteCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_custom_class.js + * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async + */ + async checkDeleteCustomClassProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCustomClass, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Undeletes the {@link google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to undelete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted CustomClass, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_custom_class.js + * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async + */ + undeleteCustomClass( + request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + undeleteCustomClass( + request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeleteCustomClass( + request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeleteCustomClass( + request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeleteCustomClass(request, options, callback); + } + /** + * Check the status of the long running operation returned by `undeleteCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_custom_class.js + * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async + */ + async checkUndeleteCustomClassProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.undeleteCustomClass, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Creates a {@link google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet + * Required. The PhraseSet to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the PhraseSet, but do not + * actually create it. + * @param {string} request.phraseSetId + * The ID to use for the PhraseSet, which will become the final component of + * the PhraseSet's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this PhraseSet will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_phrase_set.js + * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async + */ + createPhraseSet( + request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createPhraseSet( + request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createPhraseSet( + request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createPhraseSet( + request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createPhraseSet(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createPhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.create_phrase_set.js + * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async + */ + async checkCreatePhraseSetProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createPhraseSet, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Updates the {@link google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet + * Required. The PhraseSet to update. + * + * The PhraseSet's `name` field is used to identify the PhraseSet to update. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire PhraseSet resource. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated PhraseSet, but do not + * actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_phrase_set.js + * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async + */ + updatePhraseSet( + request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + updatePhraseSet( + request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updatePhraseSet( + request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + updatePhraseSet( + request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePhraseSet(request, options, callback); + } + /** + * Check the status of the long running operation returned by `updatePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.update_phrase_set.js + * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async + */ + async checkUpdatePhraseSetProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updatePhraseSet, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Deletes the {@link google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to delete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted PhraseSet, but do not + * actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the PhraseSet is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_phrase_set.js + * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async + */ + deletePhraseSet( + request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + deletePhraseSet( + request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deletePhraseSet( + request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + deletePhraseSet( + request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePhraseSet(request, options, callback); + } + /** + * Check the status of the long running operation returned by `deletePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.delete_phrase_set.js + * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async + */ + async checkDeletePhraseSetProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deletePhraseSet, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Undeletes the {@link google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to undelete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted PhraseSet, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, and delete requests to ensure + * the client has an up-to-date value before proceeding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_phrase_set.js + * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async + */ + undeletePhraseSet( + request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + undeletePhraseSet( + request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeletePhraseSet( + request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + undeletePhraseSet( + request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeletePhraseSet(request, options, callback); + } + /** + * Check the status of the long running operation returned by `undeletePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/speech.undelete_phrase_set.js + * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async + */ + async checkUndeletePhraseSetProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.undeletePhraseSet, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Lists Recognizers. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 20 Recognizers will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Recognizer]{@link google.cloud.speech.v2.Recognizer}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRecognizersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listRecognizers( + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer[], + protos.google.cloud.speech.v2.IListRecognizersRequest | null, + protos.google.cloud.speech.v2.IListRecognizersResponse + ] + >; + listRecognizers( + request: protos.google.cloud.speech.v2.IListRecognizersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + > + ): void; + listRecognizers( + request: protos.google.cloud.speech.v2.IListRecognizersRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + > + ): void; + listRecognizers( + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + | protos.google.cloud.speech.v2.IListRecognizersResponse + | null + | undefined, + protos.google.cloud.speech.v2.IRecognizer + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + > + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer[], + protos.google.cloud.speech.v2.IListRecognizersRequest | null, + protos.google.cloud.speech.v2.IListRecognizersResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRecognizers(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 20 Recognizers will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Recognizer]{@link google.cloud.speech.v2.Recognizer} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRecognizersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listRecognizersStream( + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listRecognizers']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecognizers.createStream( + this.innerApiCalls.listRecognizers as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listRecognizers`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 20 Recognizers will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Recognizer]{@link google.cloud.speech.v2.Recognizer}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/speech.list_recognizers.js + * region_tag:speech_v2_generated_Speech_ListRecognizers_async + */ + listRecognizersAsync( + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listRecognizers']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRecognizers.asyncIterate( + this.innerApiCalls['listRecognizers'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists CustomClasses. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 20 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 20, it will be coerced down to 20. Note + * that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [CustomClass]{@link google.cloud.speech.v2.CustomClass}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCustomClasses( + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass[], + protos.google.cloud.speech.v2.IListCustomClassesRequest | null, + protos.google.cloud.speech.v2.IListCustomClassesResponse + ] + >; + listCustomClasses( + request: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + > + ): void; + listCustomClasses( + request: protos.google.cloud.speech.v2.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + > + ): void; + listCustomClasses( + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + > + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass[], + protos.google.cloud.speech.v2.IListCustomClassesRequest | null, + protos.google.cloud.speech.v2.IListCustomClassesResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listCustomClasses(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 20 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 20, it will be coerced down to 20. Note + * that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [CustomClass]{@link google.cloud.speech.v2.CustomClass} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCustomClassesStream( + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.createStream( + this.innerApiCalls.listCustomClasses as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCustomClasses`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 20 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 20, it will be coerced down to 20. Note + * that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [CustomClass]{@link google.cloud.speech.v2.CustomClass}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/speech.list_custom_classes.js + * region_tag:speech_v2_generated_Speech_ListCustomClasses_async + */ + listCustomClassesAsync( + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.asyncIterate( + this.innerApiCalls['listCustomClasses'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists PhraseSets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 20 PhraseSets will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [PhraseSet]{@link google.cloud.speech.v2.PhraseSet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPhraseSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPhraseSets( + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet[], + protos.google.cloud.speech.v2.IListPhraseSetsRequest | null, + protos.google.cloud.speech.v2.IListPhraseSetsResponse + ] + >; + listPhraseSets( + request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + > + ): void; + listPhraseSets( + request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + > + ): void; + listPhraseSets( + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + | protos.google.cloud.speech.v2.IListPhraseSetsResponse + | null + | undefined, + protos.google.cloud.speech.v2.IPhraseSet + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + > + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet[], + protos.google.cloud.speech.v2.IListPhraseSetsRequest | null, + protos.google.cloud.speech.v2.IListPhraseSetsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPhraseSets(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 20 PhraseSets will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [PhraseSet]{@link google.cloud.speech.v2.PhraseSet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPhraseSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPhraseSetsStream( + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSets.createStream( + this.innerApiCalls.listPhraseSets as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listPhraseSets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 20 PhraseSets will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that have been deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [PhraseSet]{@link google.cloud.speech.v2.PhraseSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/speech.list_phrase_sets.js + * region_tag:speech_v2_generated_Speech_ListPhraseSets_async + */ + listPhraseSetsAsync( + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSets.asyncIterate( + this.innerApiCalls['listPhraseSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified config resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + configPath(project: string, location: string) { + return this.pathTemplates.configPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Config resource. + * + * @param {string} configName + * A fully-qualified path representing Config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromConfigName(configName: string) { + return this.pathTemplates.configPathTemplate.match(configName).project; + } + + /** + * Parse the location from Config resource. + * + * @param {string} configName + * A fully-qualified path representing Config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromConfigName(configName: string) { + return this.pathTemplates.configPathTemplate.match(configName).location; + } + + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string + ) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .crypto_key; + } + + /** + * Return a fully-qualified cryptoKeyVersion resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @param {string} crypto_key_version + * @returns {string} Resource name string. + */ + cryptoKeyVersionPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string + ) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + crypto_key_version: cryptoKeyVersion, + }); + } + + /** + * Parse the project from CryptoKeyVersion resource. + * + * @param {string} cryptoKeyVersionName + * A fully-qualified path representing CryptoKeyVersion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName + ).project; + } + + /** + * Parse the location from CryptoKeyVersion resource. + * + * @param {string} cryptoKeyVersionName + * A fully-qualified path representing CryptoKeyVersion resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName + ).location; + } + + /** + * Parse the key_ring from CryptoKeyVersion resource. + * + * @param {string} cryptoKeyVersionName + * A fully-qualified path representing CryptoKeyVersion resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyVersionName(cryptoKeyVersionName: string) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName + ).key_ring; + } + + /** + * Parse the crypto_key from CryptoKeyVersion resource. + * + * @param {string} cryptoKeyVersionName + * A fully-qualified path representing CryptoKeyVersion resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyVersionName(cryptoKeyVersionName: string) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName + ).crypto_key; + } + + /** + * Parse the crypto_key_version from CryptoKeyVersion resource. + * + * @param {string} cryptoKeyVersionName + * A fully-qualified path representing CryptoKeyVersion resource. + * @returns {string} A string representing the crypto_key_version. + */ + matchCryptoKeyVersionFromCryptoKeyVersionName(cryptoKeyVersionName: string) { + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName + ).crypto_key_version; + } + + /** + * 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 location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * 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; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project: string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified recognizer resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} recognizer + * @returns {string} Resource name string. + */ + recognizerPath(project: string, location: string, recognizer: string) { + return this.pathTemplates.recognizerPathTemplate.render({ + project: project, + location: location, + recognizer: recognizer, + }); + } + + /** + * Parse the project from Recognizer resource. + * + * @param {string} recognizerName + * A fully-qualified path representing Recognizer resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRecognizerName(recognizerName: string) { + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .project; + } + + /** + * Parse the location from Recognizer resource. + * + * @param {string} recognizerName + * A fully-qualified path representing Recognizer resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRecognizerName(recognizerName: string) { + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .location; + } + + /** + * Parse the recognizer from Recognizer resource. + * + * @param {string} recognizerName + * A fully-qualified path representing Recognizer resource. + * @returns {string} A string representing the recognizer. + */ + matchRecognizerFromRecognizerName(recognizerName: string) { + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .recognizer; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.speechStub && !this._terminated) { + return this.speechStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} + +import {ImprovedStreamingClient} from '../helpers'; +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SpeechClient extends ImprovedStreamingClient {} diff --git a/packages/google-cloud-speech/src/v2/speech_client_config.json b/packages/google-cloud-speech/src/v2/speech_client_config.json new file mode 100644 index 00000000000..3809c643739 --- /dev/null +++ b/packages/google-cloud-speech/src/v2/speech_client_config.json @@ -0,0 +1,141 @@ +{ + "interfaces": { + "google.cloud.speech.v2.Speech": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateRecognizer": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListRecognizers": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetRecognizer": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateRecognizer": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteRecognizer": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UndeleteRecognizer": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "Recognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "StreamingRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetConfig": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateConfig": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateCustomClass": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListCustomClasses": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetCustomClass": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateCustomClass": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteCustomClass": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UndeleteCustomClass": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreatePhraseSet": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListPhraseSets": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetPhraseSet": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdatePhraseSet": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeletePhraseSet": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UndeletePhraseSet": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-speech/src/v2/speech_proto_list.json b/packages/google-cloud-speech/src/v2/speech_proto_list.json new file mode 100644 index 00000000000..63bb898cfa4 --- /dev/null +++ b/packages/google-cloud-speech/src/v2/speech_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/speech/v2/cloud_speech.proto" +] diff --git a/packages/google-cloud-speech/test/gapic_speech_v2.ts b/packages/google-cloud-speech/test/gapic_speech_v2.ts new file mode 100644 index 00000000000..168a00b0429 --- /dev/null +++ b/packages/google-cloud-speech/test/gapic_speech_v2.ts @@ -0,0 +1,5381 @@ +// Copyright 2022 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as speechModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.SpeechClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = speechModule.v2.SpeechClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = speechModule.v2.SpeechClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = speechModule.v2.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new speechModule.v2.SpeechClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new speechModule.v2.SpeechClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); + + it('has close method for the initialized client', done => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.speechStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getRecognizer', () => { + it('invokes getRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Recognizer() + ); + client.innerApiCalls.getRecognizer = stubSimpleCall(expectedResponse); + const [response] = await client.getRecognizer(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Recognizer() + ); + client.innerApiCalls.getRecognizer = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecognizer( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizer | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecognizer with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecognizer = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRecognizer with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRecognizer(request), expectedError); + }); + }); + + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeResponse() + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeResponse() + ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizeResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recognize with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recognize with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recognize(request), expectedError); + }); + }); + + describe('getConfig', () => { + it('invokes getConfig without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config() + ); + client.innerApiCalls.getConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getConfig without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config() + ); + client.innerApiCalls.getConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getConfig with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getConfig with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getConfig(request), expectedError); + }); + }); + + describe('updateConfig', () => { + it('invokes updateConfig without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest() + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'] + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config() + ); + client.innerApiCalls.updateConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConfig without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest() + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'] + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config() + ); + client.innerApiCalls.updateConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConfig with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest() + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'] + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConfig with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest() + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'] + ); + request.config.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateConfig(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.CustomClass() + ); + client.innerApiCalls.getCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.ICustomClass | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IPhraseSet | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('createRecognizer', () => { + it('invokes createRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRecognizer = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateRecognizerProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateRecognizerProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateRecognizer', () => { + it('invokes updateRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest() + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'] + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest() + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'] + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest() + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'] + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecognizer = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest() + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'] + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateRecognizerProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdateRecognizerProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteRecognizer', () => { + it('invokes deleteRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRecognizer = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.deleteRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRecognizerProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkDeleteRecognizerProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeleteRecognizer', () => { + it('invokes undeleteRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteRecognizer = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.undeleteRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.undeleteRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeleteRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteRecognizerProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUndeleteRecognizerProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('batchRecognize', () => { + it('invokes batchRecognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.batchRecognize = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRecognize without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.batchRecognize = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchRecognize( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRecognize with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRecognize = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.batchRecognize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRecognize with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'] + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRecognize = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.batchRecognize(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkBatchRecognizeProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchRecognizeProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchRecognizeProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkBatchRecognizeProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateCustomClassProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateCustomClassProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'] + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'] + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'] + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'] + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateCustomClassProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdateCustomClassProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.deleteCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteCustomClassProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkDeleteCustomClassProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeleteCustomClass', () => { + it('invokes undeleteCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteCustomClass = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.undeleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeleteCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.undeleteCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeleteCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteCustomClassProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUndeleteCustomClassProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createPhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createPhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createPhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createPhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreatePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreatePhraseSetProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreatePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreatePhraseSetProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'] + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updatePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updatePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'] + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updatePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'] + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'] + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updatePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdatePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdatePhraseSetProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdatePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdatePhraseSetProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deletePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deletePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deletePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.deletePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeletePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeletePhraseSetProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeletePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkDeletePhraseSetProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeletePhraseSet', () => { + it('invokes undeletePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeletePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeletePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeletePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeletePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeletePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeletePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeletePhraseSet = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.undeletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeletePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeletePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.undeletePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeletePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeletePhraseSetProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeletePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUndeletePhraseSetProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeResponse() + ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v2.StreamingRecognizeResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamingRecognize with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v2.StreamingRecognizeResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + + describe('listRecognizers', () => { + it('invokes listRecognizers without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.innerApiCalls.listRecognizers = stubSimpleCall(expectedResponse); + const [response] = await client.listRecognizers(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecognizers without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.innerApiCalls.listRecognizers = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRecognizers( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizer[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecognizers with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRecognizers = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listRecognizers(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRecognizersStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.descriptors.page.listRecognizers.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRecognizersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.Recognizer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.Recognizer) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRecognizers, request) + ); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRecognizersStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecognizers.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRecognizersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.Recognizer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.Recognizer) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRecognizers, request) + ); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecognizers without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.descriptors.page.listRecognizers.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; + const iterable = client.listRecognizersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRecognizers.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRecognizers with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecognizers.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRecognizersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRecognizers.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.ICustomClass[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClassesStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.CustomClass) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request) + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCustomClassesStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.CustomClass) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request) + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPhraseSets', () => { + it('invokes listPhraseSets without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSets = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSets without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IPhraseSet[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSets with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSets = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listPhraseSets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSetsStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.descriptors.page.listPhraseSets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.PhraseSet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSets, request) + ); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPhraseSetsStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.PhraseSet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSets, request) + ); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSets without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.descriptors.page.listPhraseSets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; + const iterable = client.listPhraseSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSets with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('config', () => { + const fakePath = '/rendered/path/config'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.configPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.configPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('configPath', () => { + const result = client.configPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.configPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromConfigName', () => { + const result = client.matchProjectFromConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.configPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromConfigName', () => { + const result = client.matchLocationFromConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.configPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('cryptoKey', () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('cryptoKeyVersion', () => { + const fakePath = '/rendered/path/cryptoKeyVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cryptoKeyVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cryptoKeyVersionPath', () => { + const result = client.cryptoKeyVersionPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.cryptoKeyVersionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCryptoKeyVersionName', () => { + const result = client.matchProjectFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCryptoKeyVersionName', () => { + const result = client.matchLocationFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchKeyRingFromCryptoKeyVersionName', () => { + const result = client.matchKeyRingFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCryptoKeyFromCryptoKeyVersionName', () => { + const result = client.matchCryptoKeyFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { + const result = + client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('customClass', () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new speechModule.v2.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('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.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.v2.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) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('recognizer', () => { + const fakePath = '/rendered/path/recognizer'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + recognizer: 'recognizerValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.recognizerPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.recognizerPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('recognizerPath', () => { + const result = client.recognizerPath( + 'projectValue', + 'locationValue', + 'recognizerValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.recognizerPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromRecognizerName', () => { + const result = client.matchProjectFromRecognizerName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromRecognizerName', () => { + const result = client.matchLocationFromRecognizerName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchRecognizerFromRecognizerName', () => { + const result = client.matchRecognizerFromRecognizerName(fakePath); + assert.strictEqual(result, 'recognizerValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +});