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

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

Overview

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 client object.

Examples:


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

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

Yields:

  • (config)

    Configure the Speech client.

Yield Parameters:



127
128
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
174
175
176
177
178
179
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 127

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/speech/v2/cloud_speech_services_pb"

  # 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 = 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 = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Speech::V2::Speech::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )

  @location_client = Google::Cloud::Location::Locations::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
  end
end

Instance Attribute Details

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

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

Returns:

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


193
194
195
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 193

def location_client
  @location_client
end

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

Get the associated client for long-running operations.



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

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::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



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

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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1090

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.recognizer
    header_params["recognizer"] = request.recognizer
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :batch_recognize, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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:



97
98
99
100
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 97

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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1372

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :create_custom_class, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1980

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :create_phrase_set, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



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
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 260

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :create_recognizer, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1773
1774
1775
1776
1777
1778
1779
1780
1781
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
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1773

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :delete_custom_class, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2378

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :delete_phrase_set, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 660

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :delete_recognizer, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1178

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :get_config, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1566

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :get_custom_class, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2173

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :get_phrase_set, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 455

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :get_recognizer, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_custom_classes(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass> #list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::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::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::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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
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
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1478

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :list_custom_classes, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @speech_stub, :list_custom_classes, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_phrase_sets(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet> #list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::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::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::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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2085

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :list_phrase_sets, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @speech_stub, :list_phrase_sets, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_recognizers(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer> #list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::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::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::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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 365

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :list_recognizers, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @speech_stub, :list_recognizers, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 886

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.recognizer
    header_params["recognizer"] = request.recognizer
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :recognize, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#streaming_recognize(request, options = nil) {|response, operation| ... } ⇒ ::Enumerable<::Google::Cloud::Speech::V2::StreamingRecognizeResponse>

Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).

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::Client.new

# Create an input stream.
input = Gapic::StreamInput.new

# Call the streaming_recognize method to start streaming.
output = client.streaming_recognize input

# Send requests on the stream. For each request object, set fields by
# passing keyword arguments. Be sure to close the stream when done.
input << Google::Cloud::Speech::V2::StreamingRecognizeRequest.new
input << Google::Cloud::Speech::V2::StreamingRecognizeRequest.new
input.close

# The returned object is a streamed enumerable yielding elements of type
# ::Google::Cloud::Speech::V2::StreamingRecognizeResponse
output.each do |current_response|
  p current_response
end

Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 968

def streaming_recognize request, options = nil
  unless request.is_a? ::Enumerable
    raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
    request = request.to_enum
  end

  request = request.lazy.map do |req|
    ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Speech::V2::StreamingRecognizeRequest
  end

  # 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.streaming_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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

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

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

  @speech_stub.call_rpc :streaming_recognize, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1875
1876
1877
1878
1879
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
1915
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1875

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :undelete_custom_class, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2479

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :undelete_phrase_set, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 761

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :undelete_recognizer, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


107
108
109
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 107

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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1268

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.config&.name
    header_params["config.name"] = request.config.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_config, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
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
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1668

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.custom_class&.name
    header_params["custom_class.name"] = request.custom_class.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_custom_class, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2274

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.phrase_set&.name
    header_params["phrase_set.name"] = request.phrase_set.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_phrase_set, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the RPC is aborted.



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 556

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
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.recognizer&.name
    header_params["recognizer.name"] = request.recognizer.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_recognizer, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end