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