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:



115
116
117
118
119
120
121
122
123
124
125
126
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
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 115

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 == Client.configure.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
  end

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

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


175
176
177
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 175

def location_client
  @location_client
end

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

Get the associated client for long-running operations.



168
169
170
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 168

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:



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

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) ⇒ ::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) ⇒ ::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. Resource name of the recognizer to be used for ASR.

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

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.



1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1066

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:



94
95
96
97
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 94

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.



1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1348

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.



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

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.



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 242

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.



1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1749

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.



2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2354

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.



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 642

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.



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1154

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.



1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1542

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.



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

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.



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 437

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 20 inclusive. If the page_size is zero or unspecified, a page size of 5 will be chosen. If the page size exceeds 20, it will be coerced down to 20. Note that a call might return fewer results than the requested page size.

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



1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1454

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 20 PhraseSets will be returned. The maximum value is 20; values above 20 will be coerced to 20.

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



2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2061

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 20 Recognizers will be returned. The maximum value is 20; values above 20 will be coerced to 20.

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



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

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

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



867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 867

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.



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

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.



1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1851

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.



2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2455

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.



743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 743

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

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



1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1244

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.



1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 1644

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.



2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 2250

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.



538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/google/cloud/speech/v2/speech/client.rb', line 538

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