google-cloud-speech-v1 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 224b44e2649f8ed7aefc4d0ab4d363e5da93ee150a99d8ba8b07662379d94dc1
4
- data.tar.gz: c8b981f971e5257037de77a850a6c355543dbe5c4d531164ad6d0bdc0c404803
3
+ metadata.gz: ae5cd36ed8edd0d4b5e609d86646fa7d210985b759d63fd5d476ab64f47d4a5a
4
+ data.tar.gz: c0586b8e9774b33fe2ec0ac60d9a931e0c4329bd297bc9ec79dd853868ede917
5
5
  SHA512:
6
- metadata.gz: a77d4b2d0f91d88514a65f2a0728ee851ef7a791333e1c7d88c468a77bf12bcceabe4ac410ad569b97aabc57549fa328ce14be1c9403c8512f4e235d2f2988da
7
- data.tar.gz: a7ca15ad669561c95c0df4003bfb8d90b30c35eb13798e0e145de5d233748c3e074c078854edd5c3f85a396565e5edced69989b4df9fc03a3c5973a3c63d5e5a
6
+ metadata.gz: 2b15f23fc60018895050c14cb748129504c1e9b1ec00a98e5e11ee55a3df2da6aba84337c3a3cb22e89fc3b651fcebc861b055c1f3680c1f0a6d211a1a16e459
7
+ data.tar.gz: 74263772957dd57c9c65207aebbf71140f25347ea8b7827d11782a8bc51dec97457d9cb6f54cad366b2d91a9301334a8269854c5b8c27a9cda2fdca0e497119c
@@ -27,7 +27,7 @@ export SPEECH_CREDENTIALS=path/to/keyfile.json
27
27
  ```ruby
28
28
  require "google/cloud/speech/v1"
29
29
 
30
- client = Google::Cloud::Speech::V1::Speech::Client.new
30
+ client = ::Google::Cloud::Speech::V1::Speech::Client.new
31
31
  ```
32
32
 
33
33
  ## Credential Lookup
@@ -64,7 +64,7 @@ containers where writing files is difficult or not encouraged.
64
64
 
65
65
  The environment variables that google-cloud-speech-v1
66
66
  checks for credentials are configured on the service Credentials class (such as
67
- {Google::Cloud::Speech::V1::Speech::Credentials}):
67
+ {::Google::Cloud::Speech::V1::Speech::Credentials}):
68
68
 
69
69
  1. `SPEECH_CREDENTIALS` - Path to JSON file, or JSON contents
70
70
  2. `SPEECH_KEYFILE` - Path to JSON file, or JSON contents
@@ -77,7 +77,7 @@ require "google/cloud/speech/v1"
77
77
 
78
78
  ENV["SPEECH_CREDENTIALS"] = "path/to/keyfile.json"
79
79
 
80
- client = Google::Cloud::Speech::V1::Speech::Client.new
80
+ client = ::Google::Cloud::Speech::V1::Speech::Client.new
81
81
  ```
82
82
 
83
83
  ### Configuration
@@ -88,7 +88,7 @@ environment variables. Either on an individual client initialization:
88
88
  ```ruby
89
89
  require "google/cloud/speech/v1"
90
90
 
91
- client = Google::Cloud::Speech::V1::Speech::Client.new do |config|
91
+ client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
92
92
  config.credentials = "path/to/keyfile.json"
93
93
  end
94
94
  ```
@@ -98,11 +98,11 @@ Or configured globally for all clients:
98
98
  ```ruby
99
99
  require "google/cloud/speech/v1"
100
100
 
101
- Google::Cloud::Speech::V1::Speech::Client.configure do |config|
101
+ ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
102
102
  config.credentials = "path/to/keyfile.json"
103
103
  end
104
104
 
105
- client = Google::Cloud::Speech::V1::Speech::Client.new
105
+ client = ::Google::Cloud::Speech::V1::Speech::Client.new
106
106
  ```
107
107
 
108
108
  ### Cloud SDK
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cloud Speech-to-Text V1
1
+ # Ruby Client for the Cloud Speech-to-Text V1 API
2
2
 
3
3
  API Client library for the Cloud Speech-to-Text V1 API
4
4
 
@@ -12,6 +12,53 @@ https://github.com/googleapis/google-cloud-ruby
12
12
  $ gem install google-cloud-speech-v1
13
13
  ```
14
14
 
15
+ ## Before You Begin
16
+
17
+ In order to use this library, you first need to go through the following steps:
18
+
19
+ 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
20
+ 1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
21
+ 1. {file:AUTHENTICATION.md Set up authentication.}
22
+
23
+ ## Quick Start
24
+
25
+ ```ruby
26
+ require "google/cloud/speech/v1"
27
+
28
+ client = ::Google::Cloud::Speech::V1::Speech::Client.new
29
+ request = my_create_request
30
+ response = client.recognize request
31
+ ```
32
+
33
+ View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-speech-v1/latest)
34
+ for class and method documentation.
35
+
36
+ ## Enabling Logging
37
+
38
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
39
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
40
+ or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
41
+ that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
42
+ and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
43
+
44
+ Configuring a Ruby stdlib logger:
45
+
46
+ ```ruby
47
+ require "logger"
48
+
49
+ module MyLogger
50
+ LOGGER = Logger.new $stderr, level: Logger::WARN
51
+ def logger
52
+ LOGGER
53
+ end
54
+ end
55
+
56
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
57
+ module GRPC
58
+ extend MyLogger
59
+ end
60
+ ```
61
+
15
62
  ## Supported Ruby Versions
16
63
 
17
64
  This library is supported on Ruby 2.4+.
@@ -1 +1,21 @@
1
- require "google/cloud/speech/v1/version"
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/speech/v1"
@@ -17,3 +17,19 @@
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
19
  require "google/cloud/speech/v1/speech"
20
+ require "google/cloud/speech/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Speech
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/speech/v1"
29
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new
30
+ #
31
+ module V1
32
+ end
33
+ end
34
+ end
35
+ end
@@ -16,6 +16,34 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "google/cloud/speech/v1/speech/client"
20
- require "google/cloud/speech/v1/speech/operations"
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/speech/v1/version"
24
+
21
25
  require "google/cloud/speech/v1/speech/credentials"
26
+ require "google/cloud/speech/v1/speech/operations"
27
+ require "google/cloud/speech/v1/speech/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Speech
32
+ module V1
33
+ ##
34
+ # Service that implements Google Cloud Speech API.
35
+ #
36
+ # To load this service and instantiate a client:
37
+ #
38
+ # require "google/cloud/speech/v1/speech"
39
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new
40
+ #
41
+ module Speech
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ helper_path = ::File.join __dir__, "speech", "helpers.rb"
49
+ require "google/cloud/speech/v1/speech/helpers" if ::File.file? helper_path
@@ -16,15 +16,8 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "gapic/common"
20
- require "gapic/config"
21
- require "gapic/config/method"
22
-
23
19
  require "google/cloud/errors"
24
- require "google/cloud/speech/v1/version"
25
20
  require "google/cloud/speech/v1/cloud_speech_pb"
26
- require "google/cloud/speech/v1/speech/credentials"
27
- require "google/cloud/speech/v1/speech/operations"
28
21
 
29
22
  module Google
30
23
  module Cloud
@@ -43,15 +36,15 @@ module Google
43
36
  ##
44
37
  # Configure the Speech Client class.
45
38
  #
46
- # See {Google::Cloud::Speech::V1::Speech::Client::Configuration}
39
+ # See {::Google::Cloud::Speech::V1::Speech::Client::Configuration}
47
40
  # for a description of the configuration fields.
48
41
  #
49
42
  # ## Example
50
43
  #
51
44
  # To modify the configuration for all Speech clients:
52
45
  #
53
- # Google::Cloud::Speech::V1::Speech::Client.configure do |config|
54
- # config.timeout = 10_000
46
+ # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
47
+ # config.timeout = 10.0
55
48
  # end
56
49
  #
57
50
  # @yield [config] Configure the Client client.
@@ -101,7 +94,7 @@ module Google
101
94
  # but structural changes (adding new fields, etc.) are not allowed. Structural changes
102
95
  # should be made on {Client.configure}.
103
96
  #
104
- # See {Google::Cloud::Speech::V1::Speech::Client::Configuration}
97
+ # See {::Google::Cloud::Speech::V1::Speech::Client::Configuration}
105
98
  # for a description of the configuration fields.
106
99
  #
107
100
  # @yield [config] Configure the Client client.
@@ -122,13 +115,13 @@ module Google
122
115
  # To create a new Speech client with the default
123
116
  # configuration:
124
117
  #
125
- # client = Google::Cloud::Speech::V1::Speech::Client.new
118
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new
126
119
  #
127
120
  # To create a new Speech client with a custom
128
121
  # configuration:
129
122
  #
130
- # client = Google::Cloud::Speech::V1::Speech::Client.new do |config|
131
- # config.timeout = 10_000
123
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
124
+ # config.timeout = 10.0
132
125
  # end
133
126
  #
134
127
  # @yield [config] Configure the Speech client.
@@ -153,14 +146,16 @@ module Google
153
146
  if credentials.is_a?(String) || credentials.is_a?(Hash)
154
147
  credentials = Credentials.new credentials, scope: @config.scope
155
148
  end
156
- @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
149
+ @quota_project_id = @config.quota_project
150
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
157
151
 
158
152
  @operations_client = Operations.new do |config|
159
153
  config.credentials = credentials
154
+ config.endpoint = @config.endpoint
160
155
  end
161
156
 
162
- @speech_stub = Gapic::ServiceStub.new(
163
- Google::Cloud::Speech::V1::Speech::Stub,
157
+ @speech_stub = ::Gapic::ServiceStub.new(
158
+ ::Google::Cloud::Speech::V1::Speech::Stub,
164
159
  credentials: credentials,
165
160
  endpoint: @config.endpoint,
166
161
  channel_args: @config.channel_args,
@@ -168,6 +163,13 @@ module Google
168
163
  )
169
164
  end
170
165
 
166
+ ##
167
+ # Get the associated client for long-running operations.
168
+ #
169
+ # @return [::Google::Cloud::Speech::V1::Speech::Operations]
170
+ #
171
+ attr_reader :operations_client
172
+
171
173
  # Service calls
172
174
 
173
175
  ##
@@ -175,41 +177,47 @@ module Google
175
177
  # has been sent and processed.
176
178
  #
177
179
  # @overload recognize(request, options = nil)
178
- # @param request [Google::Cloud::Speech::V1::RecognizeRequest | Hash]
179
- # Performs synchronous speech recognition: receive results after all audio
180
- # has been sent and processed.
181
- # @param options [Gapic::CallOptions, Hash]
180
+ # Pass arguments to `recognize` via a request object, either of type
181
+ # {::Google::Cloud::Speech::V1::RecognizeRequest} or an equivalent Hash.
182
+ #
183
+ # @param request [::Google::Cloud::Speech::V1::RecognizeRequest, ::Hash]
184
+ # A request object representing the call parameters. Required. To specify no
185
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
186
+ # @param options [::Gapic::CallOptions, ::Hash]
182
187
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
183
188
  #
184
189
  # @overload recognize(config: nil, audio: nil)
185
- # @param config [Google::Cloud::Speech::V1::RecognitionConfig | Hash]
190
+ # Pass arguments to `recognize` via keyword arguments. Note that at
191
+ # least one keyword argument is required. To specify no parameters, or to keep all
192
+ # the default parameter values, pass an empty Hash as a request object (see above).
193
+ #
194
+ # @param config [::Google::Cloud::Speech::V1::RecognitionConfig, ::Hash]
186
195
  # Required. Provides information to the recognizer that specifies how to
187
196
  # process the request.
188
- # @param audio [Google::Cloud::Speech::V1::RecognitionAudio | Hash]
197
+ # @param audio [::Google::Cloud::Speech::V1::RecognitionAudio, ::Hash]
189
198
  # Required. The audio data to be recognized.
190
199
  #
191
- #
192
200
  # @yield [response, operation] Access the result along with the RPC operation
193
- # @yieldparam response [Google::Cloud::Speech::V1::RecognizeResponse]
194
- # @yieldparam operation [GRPC::ActiveCall::Operation]
201
+ # @yieldparam response [::Google::Cloud::Speech::V1::RecognizeResponse]
202
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
195
203
  #
196
- # @return [Google::Cloud::Speech::V1::RecognizeResponse]
204
+ # @return [::Google::Cloud::Speech::V1::RecognizeResponse]
197
205
  #
198
- # @raise [Google::Cloud::Error] if the RPC is aborted.
206
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
199
207
  #
200
208
  def recognize request, options = nil
201
- raise ArgumentError, "request must be provided" if request.nil?
209
+ raise ::ArgumentError, "request must be provided" if request.nil?
202
210
 
203
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1::RecognizeRequest
211
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::RecognizeRequest
204
212
 
205
213
  # Converts hash and nil to an options object
206
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
214
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
207
215
 
208
216
  # Customize the options with defaults
209
217
  metadata = @config.rpcs.recognize.metadata.to_h
210
218
 
211
219
  # Set x-goog-api-client and x-goog-user-project headers
212
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
220
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
213
221
  lib_name: @config.lib_name, lib_version: @config.lib_version,
214
222
  gapic_version: ::Google::Cloud::Speech::V1::VERSION
215
223
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -224,8 +232,8 @@ module Google
224
232
  yield response, operation if block_given?
225
233
  return response
226
234
  end
227
- rescue GRPC::BadStatus => e
228
- raise Google::Cloud::Error.from_error(e)
235
+ rescue ::GRPC::BadStatus => e
236
+ raise ::Google::Cloud::Error.from_error(e)
229
237
  end
230
238
 
231
239
  ##
@@ -237,45 +245,47 @@ module Google
237
245
  # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
238
246
  #
239
247
  # @overload long_running_recognize(request, options = nil)
240
- # @param request [Google::Cloud::Speech::V1::LongRunningRecognizeRequest | Hash]
241
- # Performs asynchronous speech recognition: receive results via the
242
- # google.longrunning.Operations interface. Returns either an
243
- # `Operation.error` or an `Operation.response` which contains
244
- # a `LongRunningRecognizeResponse` message.
245
- # For more information on asynchronous speech recognition, see the
246
- # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
247
- # @param options [Gapic::CallOptions, Hash]
248
+ # Pass arguments to `long_running_recognize` via a request object, either of type
249
+ # {::Google::Cloud::Speech::V1::LongRunningRecognizeRequest} or an equivalent Hash.
250
+ #
251
+ # @param request [::Google::Cloud::Speech::V1::LongRunningRecognizeRequest, ::Hash]
252
+ # A request object representing the call parameters. Required. To specify no
253
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
254
+ # @param options [::Gapic::CallOptions, ::Hash]
248
255
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
249
256
  #
250
257
  # @overload long_running_recognize(config: nil, audio: nil)
251
- # @param config [Google::Cloud::Speech::V1::RecognitionConfig | Hash]
258
+ # Pass arguments to `long_running_recognize` via keyword arguments. Note that at
259
+ # least one keyword argument is required. To specify no parameters, or to keep all
260
+ # the default parameter values, pass an empty Hash as a request object (see above).
261
+ #
262
+ # @param config [::Google::Cloud::Speech::V1::RecognitionConfig, ::Hash]
252
263
  # Required. Provides information to the recognizer that specifies how to
253
264
  # process the request.
254
- # @param audio [Google::Cloud::Speech::V1::RecognitionAudio | Hash]
265
+ # @param audio [::Google::Cloud::Speech::V1::RecognitionAudio, ::Hash]
255
266
  # Required. The audio data to be recognized.
256
267
  #
257
- #
258
268
  # @yield [response, operation] Access the result along with the RPC operation
259
- # @yieldparam response [Gapic::Operation]
260
- # @yieldparam operation [GRPC::ActiveCall::Operation]
269
+ # @yieldparam response [::Gapic::Operation]
270
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
261
271
  #
262
- # @return [Gapic::Operation]
272
+ # @return [::Gapic::Operation]
263
273
  #
264
- # @raise [Google::Cloud::Error] if the RPC is aborted.
274
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
265
275
  #
266
276
  def long_running_recognize request, options = nil
267
- raise ArgumentError, "request must be provided" if request.nil?
277
+ raise ::ArgumentError, "request must be provided" if request.nil?
268
278
 
269
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1::LongRunningRecognizeRequest
279
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::LongRunningRecognizeRequest
270
280
 
271
281
  # Converts hash and nil to an options object
272
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
282
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
273
283
 
274
284
  # Customize the options with defaults
275
285
  metadata = @config.rpcs.long_running_recognize.metadata.to_h
276
286
 
277
287
  # Set x-goog-api-client and x-goog-user-project headers
278
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
288
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
279
289
  lib_name: @config.lib_name, lib_version: @config.lib_version,
280
290
  gapic_version: ::Google::Cloud::Speech::V1::VERSION
281
291
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -287,49 +297,49 @@ module Google
287
297
  retry_policy: @config.retry_policy
288
298
 
289
299
  @speech_stub.call_rpc :long_running_recognize, request, options: options do |response, operation|
290
- response = Gapic::Operation.new response, @operations_client, options: options
300
+ response = ::Gapic::Operation.new response, @operations_client, options: options
291
301
  yield response, operation if block_given?
292
302
  return response
293
303
  end
294
- rescue GRPC::BadStatus => e
295
- raise Google::Cloud::Error.from_error(e)
304
+ rescue ::GRPC::BadStatus => e
305
+ raise ::Google::Cloud::Error.from_error(e)
296
306
  end
297
307
 
298
308
  ##
299
309
  # Performs bidirectional streaming speech recognition: receive results while
300
310
  # sending audio. This method is only available via the gRPC API (not REST).
301
311
  #
302
- # @param request [Gapic::StreamInput, Enumerable<Google::Cloud::Speech::V1::StreamingRecognizeRequest | Hash>]
303
- # An enumerable of {Google::Cloud::Speech::V1::StreamingRecognizeRequest} instances.
304
- # @param options [Gapic::CallOptions, Hash]
312
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Speech::V1::StreamingRecognizeRequest, ::Hash>]
313
+ # An enumerable of {::Google::Cloud::Speech::V1::StreamingRecognizeRequest} instances.
314
+ # @param options [::Gapic::CallOptions, ::Hash]
305
315
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
306
316
  #
307
317
  # @yield [response, operation] Access the result along with the RPC operation
308
- # @yieldparam response [Enumerable<Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
309
- # @yieldparam operation [GRPC::ActiveCall::Operation]
318
+ # @yieldparam response [::Enumerable<::Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
319
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
310
320
  #
311
- # @return [Enumerable<Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
321
+ # @return [::Enumerable<::Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
312
322
  #
313
- # @raise [Google::Cloud::Error] if the RPC is aborted.
323
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
314
324
  #
315
325
  def streaming_recognize request, options = nil
316
- unless request.is_a? Enumerable
317
- raise ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
326
+ unless request.is_a? ::Enumerable
327
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
318
328
  request = request.to_enum
319
329
  end
320
330
 
321
331
  request = request.lazy.map do |req|
322
- Gapic::Protobuf.coerce req, to: Google::Cloud::Speech::V1::StreamingRecognizeRequest
332
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Speech::V1::StreamingRecognizeRequest
323
333
  end
324
334
 
325
335
  # Converts hash and nil to an options object
326
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
336
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
327
337
 
328
338
  # Customize the options with defaults
329
339
  metadata = @config.rpcs.streaming_recognize.metadata.to_h
330
340
 
331
341
  # Set x-goog-api-client and x-goog-user-project headers
332
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
342
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
333
343
  lib_name: @config.lib_name, lib_version: @config.lib_version,
334
344
  gapic_version: ::Google::Cloud::Speech::V1::VERSION
335
345
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -344,8 +354,8 @@ module Google
344
354
  yield response, operation if block_given?
345
355
  return response
346
356
  end
347
- rescue GRPC::BadStatus => e
348
- raise Google::Cloud::Error.from_error(e)
357
+ rescue ::GRPC::BadStatus => e
358
+ raise ::Google::Cloud::Error.from_error(e)
349
359
  end
350
360
 
351
361
  ##
@@ -355,7 +365,7 @@ module Google
355
365
  # providing control over timeouts, retry behavior, logging, transport
356
366
  # parameters, and other low-level controls. Certain parameters can also be
357
367
  # applied individually to specific RPCs. See
358
- # {Google::Cloud::Speech::V1::Speech::Client::Configuration::Rpcs}
368
+ # {::Google::Cloud::Speech::V1::Speech::Client::Configuration::Rpcs}
359
369
  # for a list of RPCs that can be configured independently.
360
370
  #
361
371
  # Configuration can be applied globally to all clients, or to a single client
@@ -366,22 +376,22 @@ module Google
366
376
  # To modify the global config, setting the timeout for recognize
367
377
  # to 20 seconds, and all remaining timeouts to 10 seconds:
368
378
  #
369
- # Google::Cloud::Speech::V1::Speech::Client.configure do |config|
370
- # config.timeout = 10_000
371
- # config.rpcs.recognize.timeout = 20_000
379
+ # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
380
+ # config.timeout = 10.0
381
+ # config.rpcs.recognize.timeout = 20.0
372
382
  # end
373
383
  #
374
384
  # To apply the above configuration only to a new client:
375
385
  #
376
- # client = Google::Cloud::Speech::V1::Speech::Client.new do |config|
377
- # config.timeout = 10_000
378
- # config.rpcs.recognize.timeout = 20_000
386
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
387
+ # config.timeout = 10.0
388
+ # config.rpcs.recognize.timeout = 20.0
379
389
  # end
380
390
  #
381
391
  # @!attribute [rw] endpoint
382
392
  # The hostname or hostname:port of the service endpoint.
383
393
  # Defaults to `"speech.googleapis.com"`.
384
- # @return [String]
394
+ # @return [::String]
385
395
  # @!attribute [rw] credentials
386
396
  # Credentials to send with calls. You may provide any of the following types:
387
397
  # * (`String`) The path to a service account key file in JSON format
@@ -393,29 +403,29 @@ module Google
393
403
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
394
404
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
395
405
  # * (`nil`) indicating no credentials
396
- # @return [Object]
406
+ # @return [::Object]
397
407
  # @!attribute [rw] scope
398
408
  # The OAuth scopes
399
- # @return [Array<String>]
409
+ # @return [::Array<::String>]
400
410
  # @!attribute [rw] lib_name
401
411
  # The library name as recorded in instrumentation and logging
402
- # @return [String]
412
+ # @return [::String]
403
413
  # @!attribute [rw] lib_version
404
414
  # The library version as recorded in instrumentation and logging
405
- # @return [String]
415
+ # @return [::String]
406
416
  # @!attribute [rw] channel_args
407
417
  # Extra parameters passed to the gRPC channel. Note: this is ignored if a
408
418
  # `GRPC::Core::Channel` object is provided as the credential.
409
- # @return [Hash]
419
+ # @return [::Hash]
410
420
  # @!attribute [rw] interceptors
411
421
  # An array of interceptors that are run before calls are executed.
412
- # @return [Array<GRPC::ClientInterceptor>]
422
+ # @return [::Array<::GRPC::ClientInterceptor>]
413
423
  # @!attribute [rw] timeout
414
- # The call timeout in milliseconds.
415
- # @return [Numeric]
424
+ # The call timeout in seconds.
425
+ # @return [::Numeric]
416
426
  # @!attribute [rw] metadata
417
427
  # Additional gRPC headers to be sent with the call.
418
- # @return [Hash{Symbol=>String}]
428
+ # @return [::Hash{::Symbol=>::String}]
419
429
  # @!attribute [rw] retry_policy
420
430
  # The retry policy. The value is a hash with the following keys:
421
431
  # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
@@ -423,25 +433,29 @@ module Google
423
433
  # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
424
434
  # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
425
435
  # trigger a retry.
426
- # @return [Hash]
436
+ # @return [::Hash]
437
+ # @!attribute [rw] quota_project
438
+ # A separate project against which to charge quota.
439
+ # @return [::String]
427
440
  #
428
441
  class Configuration
429
- extend Gapic::Config
442
+ extend ::Gapic::Config
430
443
 
431
- config_attr :endpoint, "speech.googleapis.com", String
432
- config_attr :credentials, nil do |value|
444
+ config_attr :endpoint, "speech.googleapis.com", ::String
445
+ config_attr :credentials, nil do |value|
433
446
  allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
434
447
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
435
448
  allowed.any? { |klass| klass === value }
436
449
  end
437
- config_attr :scope, nil, String, Array, nil
438
- config_attr :lib_name, nil, String, nil
439
- config_attr :lib_version, nil, String, nil
440
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
441
- config_attr :interceptors, nil, Array, nil
442
- config_attr :timeout, nil, Numeric, nil
443
- config_attr :metadata, nil, Hash, nil
444
- config_attr :retry_policy, nil, Hash, Proc, nil
450
+ config_attr :scope, nil, ::String, ::Array, nil
451
+ config_attr :lib_name, nil, ::String, nil
452
+ config_attr :lib_version, nil, ::String, nil
453
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
454
+ config_attr :interceptors, nil, ::Array, nil
455
+ config_attr :timeout, nil, ::Numeric, nil
456
+ config_attr :metadata, nil, ::Hash, nil
457
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
458
+ config_attr :quota_project, nil, ::String, nil
445
459
 
446
460
  # @private
447
461
  def initialize parent_config = nil
@@ -482,28 +496,28 @@ module Google
482
496
  class Rpcs
483
497
  ##
484
498
  # RPC-specific configuration for `recognize`
485
- # @return [Gapic::Config::Method]
499
+ # @return [::Gapic::Config::Method]
486
500
  #
487
501
  attr_reader :recognize
488
502
  ##
489
503
  # RPC-specific configuration for `long_running_recognize`
490
- # @return [Gapic::Config::Method]
504
+ # @return [::Gapic::Config::Method]
491
505
  #
492
506
  attr_reader :long_running_recognize
493
507
  ##
494
508
  # RPC-specific configuration for `streaming_recognize`
495
- # @return [Gapic::Config::Method]
509
+ # @return [::Gapic::Config::Method]
496
510
  #
497
511
  attr_reader :streaming_recognize
498
512
 
499
513
  # @private
500
514
  def initialize parent_rpcs = nil
501
515
  recognize_config = parent_rpcs&.recognize if parent_rpcs&.respond_to? :recognize
502
- @recognize = Gapic::Config::Method.new recognize_config
516
+ @recognize = ::Gapic::Config::Method.new recognize_config
503
517
  long_running_recognize_config = parent_rpcs&.long_running_recognize if parent_rpcs&.respond_to? :long_running_recognize
504
- @long_running_recognize = Gapic::Config::Method.new long_running_recognize_config
518
+ @long_running_recognize = ::Gapic::Config::Method.new long_running_recognize_config
505
519
  streaming_recognize_config = parent_rpcs&.streaming_recognize if parent_rpcs&.respond_to? :streaming_recognize
506
- @streaming_recognize = Gapic::Config::Method.new streaming_recognize_config
520
+ @streaming_recognize = ::Gapic::Config::Method.new streaming_recognize_config
507
521
 
508
522
  yield self if block_given?
509
523
  end
@@ -515,13 +529,3 @@ module Google
515
529
  end
516
530
  end
517
531
  end
518
-
519
- # rubocop:disable Lint/HandleExceptions
520
-
521
- # Once client is loaded, load helpers.rb if it exists.
522
- begin
523
- require "google/cloud/speech/v1/speech/helpers"
524
- rescue LoadError
525
- end
526
-
527
- # rubocop:enable Lint/HandleExceptions