Class: Google::Cloud::Speech::V2::Speech::Rest::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/speech/v2/speech/rest/client.rb

Overview

REST client for the Speech service.

Enables speech transcription and resource management.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#config_path, #crypto_key_path, #crypto_key_version_path, #custom_class_path, #location_path, #phrase_set_path, #recognizer_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new Speech REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Speech::V2::Speech::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Speech client.

Yield Parameters:



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 129

def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = ::Google::Cloud::Speech::V2::Speech::Rest::Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @speech_stub = ::Google::Cloud::Speech::V2::Speech::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @speech_stub.endpoint
    config.universe_domain = @speech_stub.universe_domain
    config.bindings_override = @config.bindings_override
  end
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Rest::Client (readonly)

Get the associated client for mix-in of the Locations.

Returns:

  • (Google::Cloud::Location::Locations::Rest::Client)


187
188
189
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 187

def location_client
  @location_client
end

#operations_client::Google::Cloud::Speech::V2::Speech::Rest::Operations (readonly)

Get the associated client for long-running operations.



180
181
182
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 180

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the Speech Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all Speech clients
::Google::Cloud::Speech::V2::Speech::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 62

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Speech", "V2"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 5000.0
    default_config.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#batch_recognize(request, options = nil) ⇒ ::Gapic::Operation #batch_recognize(recognizer: nil, config: nil, config_mask: nil, files: nil, recognition_output_config: nil, processing_strategy: nil) ⇒ ::Gapic::Operation

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.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::BatchRecognizeRequest.new

# Call the batch_recognize method.
result = client.batch_recognize request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #batch_recognize(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_recognize via a request object, either of type BatchRecognizeRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::BatchRecognizeRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #batch_recognize(recognizer: nil, config: nil, config_mask: nil, files: nil, recognition_output_config: nil, processing_strategy: nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_recognize via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • recognizer (::String) (defaults to: nil)

      Required. The name of the Recognizer to use during recognition. The expected format is projects/{project}/locations/{location}/recognizers/{recognizer}. The {recognizer} segment may be set to _ to use an empty implicit Recognizer.

    • config (::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash) (defaults to: nil)

      Features and audio metadata to use for the Automatic Speech Recognition. This field in combination with the config_mask field can be used to override parts of the default_recognition_config of the Recognizer resource.

    • config_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields in config that override the values in the default_recognition_config of the recognizer during this recognition request. If no mask is provided, all given fields in 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 completely overrides and replaces the config in the recognizer for this recognition request.

    • files (::Array<::Google::Cloud::Speech::V2::BatchRecognizeFileMetadata, ::Hash>) (defaults to: nil)

      Audio files with file metadata for ASR. The maximum number of files allowed to be specified is 5.

    • recognition_output_config (::Google::Cloud::Speech::V2::RecognitionOutputConfig, ::Hash) (defaults to: nil)

      Configuration options for where to output the transcripts of each file.

    • processing_strategy (::Google::Cloud::Speech::V2::BatchRecognizeRequest::ProcessingStrategy) (defaults to: nil)

      Processing strategy to use for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 955

def batch_recognize request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::BatchRecognizeRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.batch_recognize..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.batch_recognize.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.batch_recognize.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.batch_recognize request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the Speech Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



99
100
101
102
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 99

def configure
  yield @config if block_given?
  @config
end

#create_custom_class(request, options = nil) ⇒ ::Gapic::Operation #create_custom_class(custom_class: nil, validate_only: nil, custom_class_id: nil, parent: nil) ⇒ ::Gapic::Operation

Creates a CustomClass.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::CreateCustomClassRequest.new

# Call the create_custom_class method.
result = client.create_custom_class request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_custom_class(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_custom_class via a request object, either of type CreateCustomClassRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::CreateCustomClassRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_custom_class(custom_class: nil, validate_only: nil, custom_class_id: nil, parent: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_custom_class via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • custom_class (::Google::Cloud::Speech::V2::CustomClass, ::Hash) (defaults to: nil)

      Required. The CustomClass to create.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the CustomClass, but do not actually create it.

    • custom_class_id (::String) (defaults to: nil)

      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]-/.

    • parent (::String) (defaults to: nil)

      Required. The project and location where this CustomClass will be created. The expected format is projects/{project}/locations/{location}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1216

def create_custom_class request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateCustomClassRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_custom_class..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_custom_class.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_custom_class.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.create_custom_class request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #create_phrase_set(phrase_set: nil, validate_only: nil, phrase_set_id: nil, parent: nil) ⇒ ::Gapic::Operation

Creates a PhraseSet.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::CreatePhraseSetRequest.new

# Call the create_phrase_set method.
result = client.create_phrase_set request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_phrase_set(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_phrase_set via a request object, either of type CreatePhraseSetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::CreatePhraseSetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_phrase_set(phrase_set: nil, validate_only: nil, phrase_set_id: nil, parent: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_phrase_set via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • phrase_set (::Google::Cloud::Speech::V2::PhraseSet, ::Hash) (defaults to: nil)

      Required. The PhraseSet to create.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the PhraseSet, but do not actually create it.

    • phrase_set_id (::String) (defaults to: nil)

      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]-/.

    • parent (::String) (defaults to: nil)

      Required. The project and location where this PhraseSet will be created. The expected format is projects/{project}/locations/{location}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1782

def create_phrase_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreatePhraseSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_phrase_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_phrase_set.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_phrase_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.create_phrase_set request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_recognizer(request, options = nil) ⇒ ::Gapic::Operation #create_recognizer(recognizer: nil, validate_only: nil, recognizer_id: nil, parent: nil) ⇒ ::Gapic::Operation

Creates a Recognizer.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::CreateRecognizerRequest.new

# Call the create_recognizer method.
result = client.create_recognizer request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_recognizer(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_recognizer via a request object, either of type CreateRecognizerRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::CreateRecognizerRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_recognizer(recognizer: nil, validate_only: nil, recognizer_id: nil, parent: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_recognizer via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • recognizer (::Google::Cloud::Speech::V2::Recognizer, ::Hash) (defaults to: nil)

      Required. The Recognizer to create.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the Recognizer, but do not actually create it.

    • recognizer_id (::String) (defaults to: nil)

      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]-/.

    • parent (::String) (defaults to: nil)

      Required. The project and location where this Recognizer will be created. The expected format is projects/{project}/locations/{location}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 253

def create_recognizer request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateRecognizerRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_recognizer..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_recognizer.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_recognizer.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.create_recognizer request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_custom_class(request, options = nil) ⇒ ::Gapic::Operation #delete_custom_class(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

Deletes the CustomClass.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::DeleteCustomClassRequest.new

# Call the delete_custom_class method.
result = client.delete_custom_class request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_custom_class(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_custom_class via a request object, either of type DeleteCustomClassRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::DeleteCustomClassRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_custom_class(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_custom_class via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the CustomClass to delete. Format: projects/{project}/locations/{location}/customClasses/{custom_class}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the deleted CustomClass, but do not actually delete it.

    • allow_missing (::Boolean) (defaults to: nil)

      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).

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1589

def delete_custom_class request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteCustomClassRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_custom_class..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.delete_custom_class.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_custom_class.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.delete_custom_class request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #delete_phrase_set(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

Deletes the PhraseSet.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::DeletePhraseSetRequest.new

# Call the delete_phrase_set method.
result = client.delete_phrase_set request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_phrase_set via a request object, either of type DeletePhraseSetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::DeletePhraseSetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_phrase_set(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_phrase_set via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the PhraseSet to delete. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the deleted PhraseSet, but do not actually delete it.

    • allow_missing (::Boolean) (defaults to: nil)

      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).

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2152

def delete_phrase_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeletePhraseSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_phrase_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.delete_phrase_set.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_phrase_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.delete_phrase_set request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_recognizer(request, options = nil) ⇒ ::Gapic::Operation #delete_recognizer(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

Deletes the Recognizer.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::DeleteRecognizerRequest.new

# Call the delete_recognizer method.
result = client.delete_recognizer request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_recognizer(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_recognizer via a request object, either of type DeleteRecognizerRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::DeleteRecognizerRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_recognizer(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_recognizer via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the Recognizer to delete. Format: projects/{project}/locations/{location}/recognizers/{recognizer}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the deleted Recognizer, but do not actually delete it.

    • allow_missing (::Boolean) (defaults to: nil)

      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).

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 625

def delete_recognizer request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteRecognizerRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_recognizer..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.delete_recognizer.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_recognizer.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.delete_recognizer request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config #get_config(name: nil) ⇒ ::Google::Cloud::Speech::V2::Config

Returns the requested Config.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::GetConfigRequest.new

# Call the get_config method.
result = client.get_config request

# The returned object is of type Google::Cloud::Speech::V2::Config.
p result

Overloads:

  • #get_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config

    Pass arguments to get_config via a request object, either of type GetConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::GetConfigRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_config(name: nil) ⇒ ::Google::Cloud::Speech::V2::Config

    Pass arguments to get_config via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1036

def get_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_config..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.get_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_custom_class(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass #get_custom_class(name: nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass

Returns the requested CustomClass.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::GetCustomClassRequest.new

# Call the get_custom_class method.
result = client.get_custom_class request

# The returned object is of type Google::Cloud::Speech::V2::CustomClass.
p result

Overloads:

  • #get_custom_class(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass

    Pass arguments to get_custom_class via a request object, either of type GetCustomClassRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::GetCustomClassRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_custom_class(name: nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass

    Pass arguments to get_custom_class via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the CustomClass to retrieve. The expected format is projects/{project}/locations/{location}/customClasses/{custom_class}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1396

def get_custom_class request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetCustomClassRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_custom_class..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_custom_class.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_custom_class.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.get_custom_class request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_phrase_set(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet #get_phrase_set(name: nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet

Returns the requested PhraseSet.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::GetPhraseSetRequest.new

# Call the get_phrase_set method.
result = client.get_phrase_set request

# The returned object is of type Google::Cloud::Speech::V2::PhraseSet.
p result

Overloads:

  • #get_phrase_set(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet

    Pass arguments to get_phrase_set via a request object, either of type GetPhraseSetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::GetPhraseSetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_phrase_set(name: nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet

    Pass arguments to get_phrase_set via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the PhraseSet to retrieve. The expected format is projects/{project}/locations/{location}/phraseSets/{phrase_set}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1961

def get_phrase_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetPhraseSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_phrase_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_phrase_set.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_phrase_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.get_phrase_set request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_recognizer(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer #get_recognizer(name: nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer

Returns the requested Recognizer. Fails with [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't exist.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::GetRecognizerRequest.new

# Call the get_recognizer method.
result = client.get_recognizer request

# The returned object is of type Google::Cloud::Speech::V2::Recognizer.
p result

Overloads:

  • #get_recognizer(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer

    Pass arguments to get_recognizer via a request object, either of type GetRecognizerRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::GetRecognizerRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_recognizer(name: nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer

    Pass arguments to get_recognizer via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the Recognizer to retrieve. The expected format is projects/{project}/locations/{location}/recognizers/{recognizer}.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 434

def get_recognizer request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetRecognizerRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_recognizer..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_recognizer.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_recognizer.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.get_recognizer request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_custom_classes(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass> #list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>

Lists CustomClasses.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::ListCustomClassesRequest.new

# Call the list_custom_classes method.
result = client.list_custom_classes request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Speech::V2::CustomClass.
  p item
end

Overloads:

  • #list_custom_classes(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>

    Pass arguments to list_custom_classes via a request object, either of type ListCustomClassesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::ListCustomClassesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>

    Pass arguments to list_custom_classes via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The project and location of CustomClass resources to list. The expected format is projects/{project}/locations/{location}.

    • page_size (::Integer) (defaults to: nil)

      Number of results per requests. A valid page_size ranges from 0 to 100 inclusive. If the page_size is zero or unspecified, a page size of 5 will be chosen. If the page size exceeds 100, it will be coerced down to 100. Note that a call might return fewer results than the requested page size.

    • page_token (::String) (defaults to: nil)

      A page token, received from a previous ListCustomClasses call. Provide this to retrieve the subsequent page.

      When paginating, all other parameters provided to ListCustomClasses must match the call that provided the page token.

    • show_deleted (::Boolean) (defaults to: nil)

      Whether, or not, to show resources that have been deleted.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1315

def list_custom_classes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListCustomClassesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_custom_classes..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_custom_classes.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_custom_classes.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.list_custom_classes request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_custom_classes, "custom_classes", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_phrase_sets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet> #list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>

Lists PhraseSets.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::ListPhraseSetsRequest.new

# Call the list_phrase_sets method.
result = client.list_phrase_sets request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Speech::V2::PhraseSet.
  p item
end

Overloads:

  • #list_phrase_sets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>

    Pass arguments to list_phrase_sets via a request object, either of type ListPhraseSetsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::ListPhraseSetsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>

    Pass arguments to list_phrase_sets via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The project and location of PhraseSet resources to list. The expected format is projects/{project}/locations/{location}.

    • page_size (::Integer) (defaults to: nil)

      The maximum number of PhraseSets to return. The service may return fewer than this value. If unspecified, at most 5 PhraseSets will be returned. The maximum value is 100; values above 100 will be coerced to 100.

    • page_token (::String) (defaults to: nil)

      A page token, received from a previous ListPhraseSets call. Provide this to retrieve the subsequent page.

      When paginating, all other parameters provided to ListPhraseSets must match the call that provided the page token.

    • show_deleted (::Boolean) (defaults to: nil)

      Whether, or not, to show resources that have been deleted.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1880

def list_phrase_sets request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListPhraseSetsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_phrase_sets..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_phrase_sets.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_phrase_sets.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.list_phrase_sets request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_phrase_sets, "phrase_sets", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_recognizers(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer> #list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>

Lists Recognizers.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::ListRecognizersRequest.new

# Call the list_recognizers method.
result = client.list_recognizers request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Speech::V2::Recognizer.
  p item
end

Overloads:

  • #list_recognizers(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>

    Pass arguments to list_recognizers via a request object, either of type ListRecognizersRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::ListRecognizersRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>

    Pass arguments to list_recognizers via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The project and location of Recognizers to list. The expected format is projects/{project}/locations/{location}.

    • page_size (::Integer) (defaults to: nil)

      The maximum number of Recognizers to return. The service may return fewer than this value. If unspecified, at most 5 Recognizers will be returned. The maximum value is 100; values above 100 will be coerced to 100.

    • page_token (::String) (defaults to: nil)

      A page token, received from a previous ListRecognizers call. Provide this to retrieve the subsequent page.

      When paginating, all other parameters provided to ListRecognizers must match the call that provided the page token.

    • show_deleted (::Boolean) (defaults to: nil)

      Whether, or not, to show resources that have been deleted.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 351

def list_recognizers request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListRecognizersRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_recognizers..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_recognizers.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_recognizers.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.list_recognizers request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_recognizers, "recognizers", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#recognize(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse #recognize(recognizer: nil, config: nil, config_mask: nil, content: nil, uri: nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse

Performs synchronous Speech recognition: receive results after all audio has been sent and processed.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::RecognizeRequest.new

# Call the recognize method.
result = client.recognize request

# The returned object is of type Google::Cloud::Speech::V2::RecognizeResponse.
p result

Overloads:

  • #recognize(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse

    Pass arguments to recognize via a request object, either of type RecognizeRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::RecognizeRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #recognize(recognizer: nil, config: nil, config_mask: nil, content: nil, uri: nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse

    Pass arguments to recognize via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • recognizer (::String) (defaults to: nil)

      Required. The name of the Recognizer to use during recognition. The expected format is projects/{project}/locations/{location}/recognizers/{recognizer}. The {recognizer} segment may be set to _ to use an empty implicit Recognizer.

    • config (::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash) (defaults to: nil)

      Features and audio metadata to use for the Automatic Speech Recognition. This field in combination with the config_mask field can be used to override parts of the default_recognition_config of the Recognizer resource.

    • config_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields in config that override the values in the default_recognition_config of the recognizer during this recognition request. If no mask is provided, all non-default valued fields in 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 completely overrides and replaces the config in the recognizer for this recognition request.

    • content (::String) (defaults to: nil)

      The audio data bytes encoded as specified in RecognitionConfig. As with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64.

    • uri (::String) (defaults to: nil)

      URI that points to a file that contains audio data bytes as specified in 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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 837

def recognize request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::RecognizeRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.recognize..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.recognize.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.recognize.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.recognize request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#undelete_custom_class(request, options = nil) ⇒ ::Gapic::Operation #undelete_custom_class(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

Undeletes the CustomClass.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UndeleteCustomClassRequest.new

# Call the undelete_custom_class method.
result = client.undelete_custom_class request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #undelete_custom_class(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_custom_class via a request object, either of type UndeleteCustomClassRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UndeleteCustomClassRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #undelete_custom_class(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_custom_class via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the CustomClass to undelete. Format: projects/{project}/locations/{location}/customClasses/{custom_class}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the undeleted CustomClass, but do not actually undelete it.

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1684

def undelete_custom_class request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteCustomClassRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.undelete_custom_class..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.undelete_custom_class.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.undelete_custom_class.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.undelete_custom_class request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#undelete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #undelete_phrase_set(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

Undeletes the PhraseSet.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UndeletePhraseSetRequest.new

# Call the undelete_phrase_set method.
result = client.undelete_phrase_set request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #undelete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_phrase_set via a request object, either of type UndeletePhraseSetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UndeletePhraseSetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #undelete_phrase_set(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_phrase_set via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the PhraseSet to undelete. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the undeleted PhraseSet, but do not actually undelete it.

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2246

def undelete_phrase_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeletePhraseSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.undelete_phrase_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.undelete_phrase_set.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.undelete_phrase_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.undelete_phrase_set request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#undelete_recognizer(request, options = nil) ⇒ ::Gapic::Operation #undelete_recognizer(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

Undeletes the Recognizer.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UndeleteRecognizerRequest.new

# Call the undelete_recognizer method.
result = client.undelete_recognizer request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #undelete_recognizer(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_recognizer via a request object, either of type UndeleteRecognizerRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UndeleteRecognizerRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #undelete_recognizer(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation

    Pass arguments to undelete_recognizer via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the Recognizer to undelete. Format: projects/{project}/locations/{location}/recognizers/{recognizer}

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the undeleted Recognizer, but do not actually undelete it.

    • etag (::String) (defaults to: nil)

      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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 719

def undelete_recognizer request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteRecognizerRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.undelete_recognizer..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.undelete_recognizer.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.undelete_recognizer.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.undelete_recognizer request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


109
110
111
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 109

def universe_domain
  @speech_stub.universe_domain
end

#update_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config #update_config(config: nil, update_mask: nil) ⇒ ::Google::Cloud::Speech::V2::Config

Updates the Config.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UpdateConfigRequest.new

# Call the update_config method.
result = client.update_config request

# The returned object is of type Google::Cloud::Speech::V2::Config.
p result

Overloads:

  • #update_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config

    Pass arguments to update_config via a request object, either of type UpdateConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UpdateConfigRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_config(config: nil, update_mask: nil) ⇒ ::Google::Cloud::Speech::V2::Config

    Pass arguments to update_config via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • config (::Google::Cloud::Speech::V2::Config, ::Hash) (defaults to: nil)

      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.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields to be updated.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1119

def update_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_config..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.update_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_custom_class(request, options = nil) ⇒ ::Gapic::Operation #update_custom_class(custom_class: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

Updates the CustomClass.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UpdateCustomClassRequest.new

# Call the update_custom_class method.
result = client.update_custom_class request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #update_custom_class(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_custom_class via a request object, either of type UpdateCustomClassRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UpdateCustomClassRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_custom_class(custom_class: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_custom_class via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • custom_class (::Google::Cloud::Speech::V2::CustomClass, ::Hash) (defaults to: nil)

      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}.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields to be updated. If empty, all fields are considered for update.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the updated CustomClass, but do not actually update it.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1491

def update_custom_class request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateCustomClassRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_custom_class..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_custom_class.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_custom_class.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.update_custom_class request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #update_phrase_set(phrase_set: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

Updates the PhraseSet.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UpdatePhraseSetRequest.new

# Call the update_phrase_set method.
result = client.update_phrase_set request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #update_phrase_set(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_phrase_set via a request object, either of type UpdatePhraseSetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UpdatePhraseSetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_phrase_set(phrase_set: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_phrase_set via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • phrase_set (::Google::Cloud::Speech::V2::PhraseSet, ::Hash) (defaults to: nil)

      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}.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields to update. If empty, all non-default valued fields are considered for update. Use * to update the entire PhraseSet resource.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the updated PhraseSet, but do not actually update it.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2055

def update_phrase_set request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdatePhraseSetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_phrase_set..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_phrase_set.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_phrase_set.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.update_phrase_set request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_recognizer(request, options = nil) ⇒ ::Gapic::Operation #update_recognizer(recognizer: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

Updates the Recognizer.

Examples:

Basic example

require "google/cloud/speech/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Speech::V2::Speech::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Speech::V2::UpdateRecognizerRequest.new

# Call the update_recognizer method.
result = client.update_recognizer request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #update_recognizer(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_recognizer via a request object, either of type UpdateRecognizerRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Speech::V2::UpdateRecognizerRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_recognizer(recognizer: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_recognizer via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • recognizer (::Google::Cloud::Speech::V2::Recognizer, ::Hash) (defaults to: nil)

      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}.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The list of fields to update. If empty, all non-default valued fields are considered for update. Use * to update the entire Recognizer resource.

    • validate_only (::Boolean) (defaults to: nil)

      If set, validate the request and preview the updated Recognizer, but do not actually update it.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 528

def update_recognizer request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateRecognizerRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_recognizer..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Speech::V2::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_recognizer.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_recognizer.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @speech_stub.update_recognizer request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end