google-cloud-speech-v1 0.1.3 → 0.2.3
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 +4 -4
- data/AUTHENTICATION.md +6 -6
- data/README.md +5 -1
- data/lib/google/cloud/speech/v1.rb +1 -1
- data/lib/google/cloud/speech/v1/speech.rb +1 -1
- data/lib/google/cloud/speech/v1/speech/client.rb +97 -92
- data/lib/google/cloud/speech/v1/speech/credentials.rb +1 -1
- data/lib/google/cloud/speech/v1/speech/operations.rb +109 -103
- data/lib/google/cloud/speech/v1/version.rb +1 -1
- data/proto_docs/google/api/resource.rb +12 -12
- data/proto_docs/google/cloud/speech/v1/cloud_speech.rb +99 -99
- data/proto_docs/google/longrunning/operations.rb +30 -30
- data/proto_docs/google/protobuf/any.rb +4 -4
- data/proto_docs/google/protobuf/duration.rb +4 -4
- data/proto_docs/google/protobuf/empty.rb +2 -2
- data/proto_docs/google/protobuf/timestamp.rb +4 -4
- data/proto_docs/google/rpc/status.rb +6 -6
- metadata +33 -6
- data/lib/google/cloud/common_resources_pb.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03dd454bfcf963460177c9944eeadcdbed393a80a96676b2a1b8b3867eb9bd6c
|
4
|
+
data.tar.gz: a6208042aecd91d3bc521b8c71ef160ccfba97cc9a7ce7c0d8a2a23dd73dd3f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aaf4e89aea932bda0298e106c1a1309afb114415c89a6bd8a4148e5a6038e459009eb4c3ad2dac23f9969991c7e2137534346aa9250275799721c825c37d833
|
7
|
+
data.tar.gz: f747b50b3617d469fbf6ad1fed336cfe74a085847149ebf071a68296180dc5fc75bbe5237829607408e7ffb164286c6acdaccaad62465e1423e2717473527c9d
|
data/AUTHENTICATION.md
CHANGED
@@ -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
@@ -18,6 +18,7 @@ In order to use this library, you first need to go through the following steps:
|
|
18
18
|
|
19
19
|
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
20
20
|
1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
21
|
+
1. [Enable the API.](https://console.cloud.google.com/apis/library/speech.googleapis.com)
|
21
22
|
1. {file:AUTHENTICATION.md Set up authentication.}
|
22
23
|
|
23
24
|
## Quick Start
|
@@ -25,7 +26,7 @@ In order to use this library, you first need to go through the following steps:
|
|
25
26
|
```ruby
|
26
27
|
require "google/cloud/speech/v1"
|
27
28
|
|
28
|
-
client = Google::Cloud::Speech::V1::Speech::Client.new
|
29
|
+
client = ::Google::Cloud::Speech::V1::Speech::Client.new
|
29
30
|
request = my_create_request
|
30
31
|
response = client.recognize request
|
31
32
|
```
|
@@ -33,6 +34,9 @@ response = client.recognize request
|
|
33
34
|
View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-speech-v1/latest)
|
34
35
|
for class and method documentation.
|
35
36
|
|
37
|
+
See also the [Product Documentation](https://cloud.google.com/speech-to-text)
|
38
|
+
for general usage information.
|
39
|
+
|
36
40
|
## Enabling Logging
|
37
41
|
|
38
42
|
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
@@ -26,7 +26,7 @@ module Google
|
|
26
26
|
# To load this package, including all its services, and instantiate a client:
|
27
27
|
#
|
28
28
|
# require "google/cloud/speech/v1"
|
29
|
-
# client = Google::Cloud::Speech::V1::Speech::Client.new
|
29
|
+
# client = ::Google::Cloud::Speech::V1::Speech::Client.new
|
30
30
|
#
|
31
31
|
module V1
|
32
32
|
end
|
@@ -36,7 +36,7 @@ module Google
|
|
36
36
|
# To load this service and instantiate a client:
|
37
37
|
#
|
38
38
|
# require "google/cloud/speech/v1/speech"
|
39
|
-
# client = Google::Cloud::Speech::V1::Speech::Client.new
|
39
|
+
# client = ::Google::Cloud::Speech::V1::Speech::Client.new
|
40
40
|
#
|
41
41
|
module Speech
|
42
42
|
end
|
@@ -36,15 +36,15 @@ module Google
|
|
36
36
|
##
|
37
37
|
# Configure the Speech Client class.
|
38
38
|
#
|
39
|
-
# See {Google::Cloud::Speech::V1::Speech::Client::Configuration}
|
39
|
+
# See {::Google::Cloud::Speech::V1::Speech::Client::Configuration}
|
40
40
|
# for a description of the configuration fields.
|
41
41
|
#
|
42
42
|
# ## Example
|
43
43
|
#
|
44
44
|
# To modify the configuration for all Speech clients:
|
45
45
|
#
|
46
|
-
# Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
47
|
-
# config.timeout =
|
46
|
+
# ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
47
|
+
# config.timeout = 10.0
|
48
48
|
# end
|
49
49
|
#
|
50
50
|
# @yield [config] Configure the Client client.
|
@@ -94,7 +94,7 @@ module Google
|
|
94
94
|
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
95
95
|
# should be made on {Client.configure}.
|
96
96
|
#
|
97
|
-
# See {Google::Cloud::Speech::V1::Speech::Client::Configuration}
|
97
|
+
# See {::Google::Cloud::Speech::V1::Speech::Client::Configuration}
|
98
98
|
# for a description of the configuration fields.
|
99
99
|
#
|
100
100
|
# @yield [config] Configure the Client client.
|
@@ -115,13 +115,13 @@ module Google
|
|
115
115
|
# To create a new Speech client with the default
|
116
116
|
# configuration:
|
117
117
|
#
|
118
|
-
# client = Google::Cloud::Speech::V1::Speech::Client.new
|
118
|
+
# client = ::Google::Cloud::Speech::V1::Speech::Client.new
|
119
119
|
#
|
120
120
|
# To create a new Speech client with a custom
|
121
121
|
# configuration:
|
122
122
|
#
|
123
|
-
# client = Google::Cloud::Speech::V1::Speech::Client.new do |config|
|
124
|
-
# config.timeout =
|
123
|
+
# client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
|
124
|
+
# config.timeout = 10.0
|
125
125
|
# end
|
126
126
|
#
|
127
127
|
# @yield [config] Configure the Speech client.
|
@@ -146,15 +146,16 @@ module Google
|
|
146
146
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
147
147
|
credentials = Credentials.new credentials, scope: @config.scope
|
148
148
|
end
|
149
|
-
@quota_project_id =
|
149
|
+
@quota_project_id = @config.quota_project
|
150
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
150
151
|
|
151
152
|
@operations_client = Operations.new do |config|
|
152
153
|
config.credentials = credentials
|
153
154
|
config.endpoint = @config.endpoint
|
154
155
|
end
|
155
156
|
|
156
|
-
@speech_stub = Gapic::ServiceStub.new(
|
157
|
-
Google::Cloud::Speech::V1::Speech::Stub,
|
157
|
+
@speech_stub = ::Gapic::ServiceStub.new(
|
158
|
+
::Google::Cloud::Speech::V1::Speech::Stub,
|
158
159
|
credentials: credentials,
|
159
160
|
endpoint: @config.endpoint,
|
160
161
|
channel_args: @config.channel_args,
|
@@ -165,7 +166,7 @@ module Google
|
|
165
166
|
##
|
166
167
|
# Get the associated client for long-running operations.
|
167
168
|
#
|
168
|
-
# @return [Google::Cloud::Speech::V1::Speech::Operations]
|
169
|
+
# @return [::Google::Cloud::Speech::V1::Speech::Operations]
|
169
170
|
#
|
170
171
|
attr_reader :operations_client
|
171
172
|
|
@@ -177,12 +178,12 @@ module Google
|
|
177
178
|
#
|
178
179
|
# @overload recognize(request, options = nil)
|
179
180
|
# Pass arguments to `recognize` via a request object, either of type
|
180
|
-
# {Google::Cloud::Speech::V1::RecognizeRequest} or an equivalent Hash.
|
181
|
+
# {::Google::Cloud::Speech::V1::RecognizeRequest} or an equivalent Hash.
|
181
182
|
#
|
182
|
-
# @param request [Google::Cloud::Speech::V1::RecognizeRequest, Hash]
|
183
|
+
# @param request [::Google::Cloud::Speech::V1::RecognizeRequest, ::Hash]
|
183
184
|
# A request object representing the call parameters. Required. To specify no
|
184
185
|
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
185
|
-
# @param options [Gapic::CallOptions, Hash]
|
186
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
186
187
|
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
187
188
|
#
|
188
189
|
# @overload recognize(config: nil, audio: nil)
|
@@ -190,33 +191,33 @@ module Google
|
|
190
191
|
# least one keyword argument is required. To specify no parameters, or to keep all
|
191
192
|
# the default parameter values, pass an empty Hash as a request object (see above).
|
192
193
|
#
|
193
|
-
# @param config [Google::Cloud::Speech::V1::RecognitionConfig, Hash]
|
194
|
+
# @param config [::Google::Cloud::Speech::V1::RecognitionConfig, ::Hash]
|
194
195
|
# Required. Provides information to the recognizer that specifies how to
|
195
196
|
# process the request.
|
196
|
-
# @param audio [Google::Cloud::Speech::V1::RecognitionAudio, Hash]
|
197
|
+
# @param audio [::Google::Cloud::Speech::V1::RecognitionAudio, ::Hash]
|
197
198
|
# Required. The audio data to be recognized.
|
198
199
|
#
|
199
200
|
# @yield [response, operation] Access the result along with the RPC operation
|
200
|
-
# @yieldparam response [Google::Cloud::Speech::V1::RecognizeResponse]
|
201
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
201
|
+
# @yieldparam response [::Google::Cloud::Speech::V1::RecognizeResponse]
|
202
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
202
203
|
#
|
203
|
-
# @return [Google::Cloud::Speech::V1::RecognizeResponse]
|
204
|
+
# @return [::Google::Cloud::Speech::V1::RecognizeResponse]
|
204
205
|
#
|
205
|
-
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
206
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
206
207
|
#
|
207
208
|
def recognize request, options = nil
|
208
|
-
raise ArgumentError, "request must be provided" if request.nil?
|
209
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
209
210
|
|
210
|
-
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1::RecognizeRequest
|
211
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::RecognizeRequest
|
211
212
|
|
212
213
|
# Converts hash and nil to an options object
|
213
|
-
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
|
214
215
|
|
215
216
|
# Customize the options with defaults
|
216
217
|
metadata = @config.rpcs.recognize.metadata.to_h
|
217
218
|
|
218
219
|
# Set x-goog-api-client and x-goog-user-project headers
|
219
|
-
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
220
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
220
221
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
221
222
|
gapic_version: ::Google::Cloud::Speech::V1::VERSION
|
222
223
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
@@ -231,8 +232,8 @@ module Google
|
|
231
232
|
yield response, operation if block_given?
|
232
233
|
return response
|
233
234
|
end
|
234
|
-
rescue GRPC::BadStatus => e
|
235
|
-
raise Google::Cloud::Error.from_error(e)
|
235
|
+
rescue ::GRPC::BadStatus => e
|
236
|
+
raise ::Google::Cloud::Error.from_error(e)
|
236
237
|
end
|
237
238
|
|
238
239
|
##
|
@@ -245,12 +246,12 @@ module Google
|
|
245
246
|
#
|
246
247
|
# @overload long_running_recognize(request, options = nil)
|
247
248
|
# Pass arguments to `long_running_recognize` via a request object, either of type
|
248
|
-
# {Google::Cloud::Speech::V1::LongRunningRecognizeRequest} or an equivalent Hash.
|
249
|
+
# {::Google::Cloud::Speech::V1::LongRunningRecognizeRequest} or an equivalent Hash.
|
249
250
|
#
|
250
|
-
# @param request [Google::Cloud::Speech::V1::LongRunningRecognizeRequest, Hash]
|
251
|
+
# @param request [::Google::Cloud::Speech::V1::LongRunningRecognizeRequest, ::Hash]
|
251
252
|
# A request object representing the call parameters. Required. To specify no
|
252
253
|
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
253
|
-
# @param options [Gapic::CallOptions, Hash]
|
254
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
254
255
|
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
255
256
|
#
|
256
257
|
# @overload long_running_recognize(config: nil, audio: nil)
|
@@ -258,33 +259,33 @@ module Google
|
|
258
259
|
# least one keyword argument is required. To specify no parameters, or to keep all
|
259
260
|
# the default parameter values, pass an empty Hash as a request object (see above).
|
260
261
|
#
|
261
|
-
# @param config [Google::Cloud::Speech::V1::RecognitionConfig, Hash]
|
262
|
+
# @param config [::Google::Cloud::Speech::V1::RecognitionConfig, ::Hash]
|
262
263
|
# Required. Provides information to the recognizer that specifies how to
|
263
264
|
# process the request.
|
264
|
-
# @param audio [Google::Cloud::Speech::V1::RecognitionAudio, Hash]
|
265
|
+
# @param audio [::Google::Cloud::Speech::V1::RecognitionAudio, ::Hash]
|
265
266
|
# Required. The audio data to be recognized.
|
266
267
|
#
|
267
268
|
# @yield [response, operation] Access the result along with the RPC operation
|
268
|
-
# @yieldparam response [Gapic::Operation]
|
269
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
269
|
+
# @yieldparam response [::Gapic::Operation]
|
270
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
270
271
|
#
|
271
|
-
# @return [Gapic::Operation]
|
272
|
+
# @return [::Gapic::Operation]
|
272
273
|
#
|
273
|
-
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
274
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
274
275
|
#
|
275
276
|
def long_running_recognize request, options = nil
|
276
|
-
raise ArgumentError, "request must be provided" if request.nil?
|
277
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
277
278
|
|
278
|
-
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1::LongRunningRecognizeRequest
|
279
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::LongRunningRecognizeRequest
|
279
280
|
|
280
281
|
# Converts hash and nil to an options object
|
281
|
-
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
|
282
283
|
|
283
284
|
# Customize the options with defaults
|
284
285
|
metadata = @config.rpcs.long_running_recognize.metadata.to_h
|
285
286
|
|
286
287
|
# Set x-goog-api-client and x-goog-user-project headers
|
287
|
-
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
288
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
288
289
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
289
290
|
gapic_version: ::Google::Cloud::Speech::V1::VERSION
|
290
291
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
@@ -296,49 +297,49 @@ module Google
|
|
296
297
|
retry_policy: @config.retry_policy
|
297
298
|
|
298
299
|
@speech_stub.call_rpc :long_running_recognize, request, options: options do |response, operation|
|
299
|
-
response = Gapic::Operation.new response, @operations_client, options: options
|
300
|
+
response = ::Gapic::Operation.new response, @operations_client, options: options
|
300
301
|
yield response, operation if block_given?
|
301
302
|
return response
|
302
303
|
end
|
303
|
-
rescue GRPC::BadStatus => e
|
304
|
-
raise Google::Cloud::Error.from_error(e)
|
304
|
+
rescue ::GRPC::BadStatus => e
|
305
|
+
raise ::Google::Cloud::Error.from_error(e)
|
305
306
|
end
|
306
307
|
|
307
308
|
##
|
308
309
|
# Performs bidirectional streaming speech recognition: receive results while
|
309
310
|
# sending audio. This method is only available via the gRPC API (not REST).
|
310
311
|
#
|
311
|
-
# @param request [Gapic::StreamInput, Enumerable
|
312
|
-
# An enumerable of {Google::Cloud::Speech::V1::StreamingRecognizeRequest} instances.
|
313
|
-
# @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]
|
314
315
|
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
315
316
|
#
|
316
317
|
# @yield [response, operation] Access the result along with the RPC operation
|
317
|
-
# @yieldparam response [Enumerable
|
318
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
318
|
+
# @yieldparam response [::Enumerable<::Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
|
319
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
319
320
|
#
|
320
|
-
# @return [Enumerable
|
321
|
+
# @return [::Enumerable<::Google::Cloud::Speech::V1::StreamingRecognizeResponse>]
|
321
322
|
#
|
322
|
-
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
323
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
323
324
|
#
|
324
325
|
def streaming_recognize request, options = nil
|
325
|
-
unless request.is_a? Enumerable
|
326
|
-
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
|
327
328
|
request = request.to_enum
|
328
329
|
end
|
329
330
|
|
330
331
|
request = request.lazy.map do |req|
|
331
|
-
Gapic::Protobuf.coerce req, to: Google::Cloud::Speech::V1::StreamingRecognizeRequest
|
332
|
+
::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Speech::V1::StreamingRecognizeRequest
|
332
333
|
end
|
333
334
|
|
334
335
|
# Converts hash and nil to an options object
|
335
|
-
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
|
336
337
|
|
337
338
|
# Customize the options with defaults
|
338
339
|
metadata = @config.rpcs.streaming_recognize.metadata.to_h
|
339
340
|
|
340
341
|
# Set x-goog-api-client and x-goog-user-project headers
|
341
|
-
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
342
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
342
343
|
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
343
344
|
gapic_version: ::Google::Cloud::Speech::V1::VERSION
|
344
345
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
@@ -353,8 +354,8 @@ module Google
|
|
353
354
|
yield response, operation if block_given?
|
354
355
|
return response
|
355
356
|
end
|
356
|
-
rescue GRPC::BadStatus => e
|
357
|
-
raise Google::Cloud::Error.from_error(e)
|
357
|
+
rescue ::GRPC::BadStatus => e
|
358
|
+
raise ::Google::Cloud::Error.from_error(e)
|
358
359
|
end
|
359
360
|
|
360
361
|
##
|
@@ -364,7 +365,7 @@ module Google
|
|
364
365
|
# providing control over timeouts, retry behavior, logging, transport
|
365
366
|
# parameters, and other low-level controls. Certain parameters can also be
|
366
367
|
# applied individually to specific RPCs. See
|
367
|
-
# {Google::Cloud::Speech::V1::Speech::Client::Configuration::Rpcs}
|
368
|
+
# {::Google::Cloud::Speech::V1::Speech::Client::Configuration::Rpcs}
|
368
369
|
# for a list of RPCs that can be configured independently.
|
369
370
|
#
|
370
371
|
# Configuration can be applied globally to all clients, or to a single client
|
@@ -375,22 +376,22 @@ module Google
|
|
375
376
|
# To modify the global config, setting the timeout for recognize
|
376
377
|
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
377
378
|
#
|
378
|
-
# Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
379
|
-
# config.timeout =
|
380
|
-
# config.rpcs.recognize.timeout =
|
379
|
+
# ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
380
|
+
# config.timeout = 10.0
|
381
|
+
# config.rpcs.recognize.timeout = 20.0
|
381
382
|
# end
|
382
383
|
#
|
383
384
|
# To apply the above configuration only to a new client:
|
384
385
|
#
|
385
|
-
# client = Google::Cloud::Speech::V1::Speech::Client.new do |config|
|
386
|
-
# config.timeout =
|
387
|
-
# config.rpcs.recognize.timeout =
|
386
|
+
# client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
|
387
|
+
# config.timeout = 10.0
|
388
|
+
# config.rpcs.recognize.timeout = 20.0
|
388
389
|
# end
|
389
390
|
#
|
390
391
|
# @!attribute [rw] endpoint
|
391
392
|
# The hostname or hostname:port of the service endpoint.
|
392
393
|
# Defaults to `"speech.googleapis.com"`.
|
393
|
-
# @return [String]
|
394
|
+
# @return [::String]
|
394
395
|
# @!attribute [rw] credentials
|
395
396
|
# Credentials to send with calls. You may provide any of the following types:
|
396
397
|
# * (`String`) The path to a service account key file in JSON format
|
@@ -402,29 +403,29 @@ module Google
|
|
402
403
|
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
403
404
|
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
404
405
|
# * (`nil`) indicating no credentials
|
405
|
-
# @return [Object]
|
406
|
+
# @return [::Object]
|
406
407
|
# @!attribute [rw] scope
|
407
408
|
# The OAuth scopes
|
408
|
-
# @return [Array
|
409
|
+
# @return [::Array<::String>]
|
409
410
|
# @!attribute [rw] lib_name
|
410
411
|
# The library name as recorded in instrumentation and logging
|
411
|
-
# @return [String]
|
412
|
+
# @return [::String]
|
412
413
|
# @!attribute [rw] lib_version
|
413
414
|
# The library version as recorded in instrumentation and logging
|
414
|
-
# @return [String]
|
415
|
+
# @return [::String]
|
415
416
|
# @!attribute [rw] channel_args
|
416
417
|
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
417
418
|
# `GRPC::Core::Channel` object is provided as the credential.
|
418
|
-
# @return [Hash]
|
419
|
+
# @return [::Hash]
|
419
420
|
# @!attribute [rw] interceptors
|
420
421
|
# An array of interceptors that are run before calls are executed.
|
421
|
-
# @return [Array
|
422
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
422
423
|
# @!attribute [rw] timeout
|
423
|
-
# The call timeout in
|
424
|
-
# @return [Numeric]
|
424
|
+
# The call timeout in seconds.
|
425
|
+
# @return [::Numeric]
|
425
426
|
# @!attribute [rw] metadata
|
426
427
|
# Additional gRPC headers to be sent with the call.
|
427
|
-
# @return [Hash{Symbol
|
428
|
+
# @return [::Hash{::Symbol=>::String}]
|
428
429
|
# @!attribute [rw] retry_policy
|
429
430
|
# The retry policy. The value is a hash with the following keys:
|
430
431
|
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
@@ -432,25 +433,29 @@ module Google
|
|
432
433
|
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
433
434
|
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
434
435
|
# trigger a retry.
|
435
|
-
# @return [Hash]
|
436
|
+
# @return [::Hash]
|
437
|
+
# @!attribute [rw] quota_project
|
438
|
+
# A separate project against which to charge quota.
|
439
|
+
# @return [::String]
|
436
440
|
#
|
437
441
|
class Configuration
|
438
|
-
extend Gapic::Config
|
442
|
+
extend ::Gapic::Config
|
439
443
|
|
440
|
-
config_attr :endpoint,
|
441
|
-
config_attr :credentials,
|
444
|
+
config_attr :endpoint, "speech.googleapis.com", ::String
|
445
|
+
config_attr :credentials, nil do |value|
|
442
446
|
allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
443
447
|
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
444
448
|
allowed.any? { |klass| klass === value }
|
445
449
|
end
|
446
|
-
config_attr :scope,
|
447
|
-
config_attr :lib_name,
|
448
|
-
config_attr :lib_version,
|
449
|
-
config_attr(:channel_args,
|
450
|
-
config_attr :interceptors,
|
451
|
-
config_attr :timeout,
|
452
|
-
config_attr :metadata,
|
453
|
-
config_attr :retry_policy,
|
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
|
454
459
|
|
455
460
|
# @private
|
456
461
|
def initialize parent_config = nil
|
@@ -466,7 +471,7 @@ module Google
|
|
466
471
|
def rpcs
|
467
472
|
@rpcs ||= begin
|
468
473
|
parent_rpcs = nil
|
469
|
-
parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to?
|
474
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
|
470
475
|
Rpcs.new parent_rpcs
|
471
476
|
end
|
472
477
|
end
|
@@ -491,28 +496,28 @@ module Google
|
|
491
496
|
class Rpcs
|
492
497
|
##
|
493
498
|
# RPC-specific configuration for `recognize`
|
494
|
-
# @return [Gapic::Config::Method]
|
499
|
+
# @return [::Gapic::Config::Method]
|
495
500
|
#
|
496
501
|
attr_reader :recognize
|
497
502
|
##
|
498
503
|
# RPC-specific configuration for `long_running_recognize`
|
499
|
-
# @return [Gapic::Config::Method]
|
504
|
+
# @return [::Gapic::Config::Method]
|
500
505
|
#
|
501
506
|
attr_reader :long_running_recognize
|
502
507
|
##
|
503
508
|
# RPC-specific configuration for `streaming_recognize`
|
504
|
-
# @return [Gapic::Config::Method]
|
509
|
+
# @return [::Gapic::Config::Method]
|
505
510
|
#
|
506
511
|
attr_reader :streaming_recognize
|
507
512
|
|
508
513
|
# @private
|
509
514
|
def initialize parent_rpcs = nil
|
510
515
|
recognize_config = parent_rpcs&.recognize if parent_rpcs&.respond_to? :recognize
|
511
|
-
@recognize = Gapic::Config::Method.new recognize_config
|
516
|
+
@recognize = ::Gapic::Config::Method.new recognize_config
|
512
517
|
long_running_recognize_config = parent_rpcs&.long_running_recognize if parent_rpcs&.respond_to? :long_running_recognize
|
513
|
-
@long_running_recognize = Gapic::Config::Method.new long_running_recognize_config
|
518
|
+
@long_running_recognize = ::Gapic::Config::Method.new long_running_recognize_config
|
514
519
|
streaming_recognize_config = parent_rpcs&.streaming_recognize if parent_rpcs&.respond_to? :streaming_recognize
|
515
|
-
@streaming_recognize = Gapic::Config::Method.new streaming_recognize_config
|
520
|
+
@streaming_recognize = ::Gapic::Config::Method.new streaming_recognize_config
|
516
521
|
|
517
522
|
yield self if block_given?
|
518
523
|
end
|