google-cloud-speech 0.32.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -1
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +201 -0
- data/MIGRATING.md +367 -0
- data/README.md +97 -52
- data/lib/google/cloud/speech/version.rb +22 -0
- data/lib/google/cloud/speech.rb +88 -139
- data/lib/google-cloud-speech.rb +19 -0
- metadata +111 -49
- data/LICENSE +0 -201
- data/lib/google/cloud/speech/v1/cloud_speech_pb.rb +0 -129
- data/lib/google/cloud/speech/v1/cloud_speech_services_pb.rb +0 -56
- data/lib/google/cloud/speech/v1/credentials.rb +0 -41
- data/lib/google/cloud/speech/v1/doc/google/cloud/speech/v1/cloud_speech.rb +0 -482
- data/lib/google/cloud/speech/v1/doc/google/longrunning/operations.rb +0 -93
- data/lib/google/cloud/speech/v1/doc/google/protobuf/any.rb +0 -130
- data/lib/google/cloud/speech/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/speech/v1/doc/google/rpc/status.rb +0 -84
- data/lib/google/cloud/speech/v1/helpers.rb +0 -136
- data/lib/google/cloud/speech/v1/speech_client.rb +0 -331
- data/lib/google/cloud/speech/v1/speech_client_config.json +0 -41
- data/lib/google/cloud/speech/v1/stream.rb +0 -614
- data/lib/google/cloud/speech/v1.rb +0 -157
- data/lib/google/cloud/speech/v1p1beta1/cloud_speech_pb.rb +0 -190
- data/lib/google/cloud/speech/v1p1beta1/cloud_speech_services_pb.rb +0 -56
- data/lib/google/cloud/speech/v1p1beta1/credentials.rb +0 -41
- data/lib/google/cloud/speech/v1p1beta1/doc/google/cloud/speech/v1p1beta1/cloud_speech.rb +0 -719
- data/lib/google/cloud/speech/v1p1beta1/doc/google/longrunning/operations.rb +0 -93
- data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/any.rb +0 -130
- data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/speech/v1p1beta1/doc/google/rpc/status.rb +0 -84
- data/lib/google/cloud/speech/v1p1beta1/helpers.rb +0 -136
- data/lib/google/cloud/speech/v1p1beta1/speech_client.rb +0 -331
- data/lib/google/cloud/speech/v1p1beta1/speech_client_config.json +0 -41
- data/lib/google/cloud/speech/v1p1beta1/stream.rb +0 -614
- data/lib/google/cloud/speech/v1p1beta1.rb +0 -157
data/MIGRATING.md
ADDED
@@ -0,0 +1,367 @@
|
|
1
|
+
## Migrating to google-cloud-speech 1.0
|
2
|
+
|
3
|
+
The 1.0 release of the google-cloud-speech client is a significant upgrade
|
4
|
+
based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
5
|
+
and includes substantial interface changes. Existing code written for earlier
|
6
|
+
versions of this library will likely require updates to use this version.
|
7
|
+
This document describes the changes that have been made, and what you need to
|
8
|
+
do to update your usage.
|
9
|
+
|
10
|
+
To summarize:
|
11
|
+
|
12
|
+
* The library has been broken out into multiple libraries. The new gems
|
13
|
+
`google-cloud-speech-v1` and `google-cloud-speech-v1p1beta1` contain the
|
14
|
+
actual client classes for versions V1 and V1p1beta1 of the Speech service,
|
15
|
+
and the gem `google-cloud-speech` now simply provides a convenience wrapper.
|
16
|
+
See [Library Structure](#library-structure) for more info.
|
17
|
+
* The library uses a new configuration mechanism giving you closer control
|
18
|
+
over endpoint address, network timeouts, and retry. See
|
19
|
+
[Client Configuration](#client-configuration) for more info. Furthermore,
|
20
|
+
when creating a client object, you can customize its configuration in a
|
21
|
+
block rather than passing arguments to the constructor. See
|
22
|
+
[Creating Clients](#creating-clients) for more info.
|
23
|
+
* Previously, positional arguments were used to indicate required arguments.
|
24
|
+
Now, all method arguments are keyword arguments, with documentation that
|
25
|
+
specifies whether they are required or optional. Additionally, you can pass
|
26
|
+
a proto request object instead of separate arguments. See
|
27
|
+
[Passing Arguments](#passing-arguments) for more info.
|
28
|
+
* Previously, the client included a method supporting bidirectional streaming
|
29
|
+
recognition requests, both incremental audio and incremental results. The
|
30
|
+
current client retains this method, but simplifies the interface to match
|
31
|
+
streaming methods in other Ruby clients. See
|
32
|
+
[Streaming Interface](#streaming-interface) for more info.
|
33
|
+
* Previously, clients reported RPC errors by raising instances of
|
34
|
+
`Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
|
35
|
+
`Google::Cloud::Error` and its subclasses. See
|
36
|
+
[Handling Errors](#handling-errors) for more info.
|
37
|
+
* Some classes have moved into different namespaces. See
|
38
|
+
[Class Namespaces](#class-namespaces) for more info.
|
39
|
+
|
40
|
+
### Library Structure
|
41
|
+
|
42
|
+
Older 0.x releases of the `google-cloud-speech` gem were all-in-one gems
|
43
|
+
that included potentially multiple clients for multiple versions of the Speech
|
44
|
+
service. The `Google::Cloud::Speech.new` factory method would
|
45
|
+
return you an instance of a `Google::Cloud::Speech::V1::SpeechClient`
|
46
|
+
object for the V1 version of the service, or a
|
47
|
+
`Google::Cloud::Speech::V1p1beta1::SpeechClient` object for the V1p1beta1
|
48
|
+
version of the service. All these classes were defined in the same gem.
|
49
|
+
|
50
|
+
With the 1.0 release, the `google-cloud-speech` gem still provides factory
|
51
|
+
methods for obtaining clients. (The method signatures will have changed. See
|
52
|
+
[Creating Clients](#creating-clients) for details.) However, the actual client
|
53
|
+
classes have been moved into separate gems, one per service version. The
|
54
|
+
`Google::Cloud::Speech::V1::Speech::Client` class, along with its
|
55
|
+
helpers and data types, is now part of the `google-cloud-speech-v1` gem.
|
56
|
+
Similarly, the `Google::Cloud::Speech::V1p1beta1::Speech::Client`
|
57
|
+
class is part of the `google-cloud-speech-v1p1beta1` gem.
|
58
|
+
|
59
|
+
For normal usage, you can continue to install the `google-cloud-speech` gem
|
60
|
+
(which will bring in the versioned client gems as dependencies) and continue to
|
61
|
+
use factory methods to create clients. However, you may alternatively choose to
|
62
|
+
install only one of the versioned gems. For example, if you know you will only
|
63
|
+
use `V1` of the service, you can install `google-cloud-speech-v1` by
|
64
|
+
itself, and construct instances of the
|
65
|
+
`Google::Cloud::Speech::V1::Speech::Client` client class directly.
|
66
|
+
|
67
|
+
### Client Configuration
|
68
|
+
|
69
|
+
In older releases, if you wanted to customize performance parameters or
|
70
|
+
low-level behavior of the client (such as credentials, timeouts, or
|
71
|
+
instrumentation), you would pass a variety of keyword arguments to the client
|
72
|
+
constructor. It was also extremely difficult to customize the default settings.
|
73
|
+
|
74
|
+
With the 1.0 release, a configuration interface provides control over these
|
75
|
+
parameters, including defaults for all instances of a client, and settings for
|
76
|
+
each specific client instance. For example, to set default credentials and
|
77
|
+
timeout for all Speech V1 clients:
|
78
|
+
|
79
|
+
```
|
80
|
+
Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
81
|
+
config.credentials = "/path/to/credentials.json"
|
82
|
+
config.timeout = 10.0
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
Individual RPCs can also be configured independently. For example, to set the
|
87
|
+
timeout for the `recognize` call:
|
88
|
+
|
89
|
+
```
|
90
|
+
Google::Cloud::Speech::V1::Speech::Client.configure do |config|
|
91
|
+
config.rpcs.recognize.timeout = 20.0
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
Defaults for certain configurations can be set for all Speech versions and
|
96
|
+
services globally:
|
97
|
+
|
98
|
+
```
|
99
|
+
Google::Cloud::Speech.configure do |config|
|
100
|
+
config.credentials = "/path/to/credentials.json"
|
101
|
+
config.timeout = 10.0
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
Finally, you can override the configuration for each client instance. See the
|
106
|
+
next section on [Creating Clients](#creating-clients) for details.
|
107
|
+
|
108
|
+
### Creating Clients
|
109
|
+
|
110
|
+
In older releases, to create a client object, you would use the
|
111
|
+
`Google::Cloud::Speech.new` class method. Keyword arguments were available to
|
112
|
+
select a service version and to configure parameters such as credentials and
|
113
|
+
timeouts.
|
114
|
+
|
115
|
+
With the 1.0 release, use the `Google::Cloud::Speech.speech` class
|
116
|
+
method to create a client object. You may select a service version using the
|
117
|
+
`:version` keyword argument. However, other configuration parameters should be
|
118
|
+
set in a configuration block when you create the client.
|
119
|
+
|
120
|
+
Old:
|
121
|
+
```
|
122
|
+
client = Google::Cloud::Speech.new credentials: "/path/to/credentials.json"
|
123
|
+
```
|
124
|
+
|
125
|
+
New:
|
126
|
+
```
|
127
|
+
client = Google::Cloud::Speech.speech do |config|
|
128
|
+
config.credentials = "/path/to/credentials.json"
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
The configuration block is optional. If you do not provide it, or you do not
|
133
|
+
set some configuration parameters, then the default configuration is used. See
|
134
|
+
[Client Configuration](#client-configuration).
|
135
|
+
|
136
|
+
### Passing Arguments
|
137
|
+
|
138
|
+
In older releases, required arguments would be passed as positional method
|
139
|
+
arguments, while most optional arguments would be passed as keyword arguments.
|
140
|
+
|
141
|
+
With the 1.0 release, all RPC arguments are passed as keyword arguments,
|
142
|
+
regardless of whether they are required or optional. For example:
|
143
|
+
|
144
|
+
Old:
|
145
|
+
```
|
146
|
+
client = Google::Cloud::Speech.new
|
147
|
+
|
148
|
+
config = {
|
149
|
+
language_code: "en-US",
|
150
|
+
sample_rate_hertz: 44_100,
|
151
|
+
encoding: :FLAC
|
152
|
+
}
|
153
|
+
audio = {
|
154
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
155
|
+
}
|
156
|
+
|
157
|
+
# Config and audio are positional arguments
|
158
|
+
response = client.recognize config, audio
|
159
|
+
```
|
160
|
+
|
161
|
+
New:
|
162
|
+
```
|
163
|
+
client = Google::Cloud::Speech.speech
|
164
|
+
|
165
|
+
config = {
|
166
|
+
language_code: "en-US",
|
167
|
+
sample_rate_hertz: 44_100,
|
168
|
+
encoding: :FLAC
|
169
|
+
}
|
170
|
+
audio = {
|
171
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
172
|
+
}
|
173
|
+
|
174
|
+
# Config and audio are keyword arguments
|
175
|
+
response = client.recognize config: config, audio: audio
|
176
|
+
```
|
177
|
+
|
178
|
+
In the 1.0 release, it is also possible to pass a request object, either
|
179
|
+
as a hash or as a protocol buffer.
|
180
|
+
|
181
|
+
New:
|
182
|
+
```
|
183
|
+
client = Google::Cloud::Speech.speech
|
184
|
+
|
185
|
+
request_object = Google::Cloud::Speech::V1::RecognizeRequest.new(
|
186
|
+
config: {
|
187
|
+
language_code: "en-US",
|
188
|
+
sample_rate_hertz: 44_100,
|
189
|
+
encoding: :FLAC
|
190
|
+
},
|
191
|
+
audio: {
|
192
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
193
|
+
}
|
194
|
+
)
|
195
|
+
|
196
|
+
# Pass a request object as a positional argument:
|
197
|
+
response = client.recognize request_object
|
198
|
+
```
|
199
|
+
|
200
|
+
Finally, in older releases, to provide call options, you would pass a
|
201
|
+
`Google::Gax::CallOptions` object with the `:options` keyword argument. In the
|
202
|
+
1.0 release, pass call options using a _second set_ of keyword arguments.
|
203
|
+
|
204
|
+
Old:
|
205
|
+
```
|
206
|
+
client = Google::Cloud::Speech.new
|
207
|
+
|
208
|
+
config = {
|
209
|
+
language_code: "en-US",
|
210
|
+
sample_rate_hertz: 44_100,
|
211
|
+
encoding: :FLAC
|
212
|
+
}
|
213
|
+
audio = {
|
214
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
215
|
+
}
|
216
|
+
|
217
|
+
options = Google::Gax::CallOptions.new timeout: 10.0
|
218
|
+
|
219
|
+
response = client.recognize config, audio, options: options
|
220
|
+
```
|
221
|
+
|
222
|
+
New:
|
223
|
+
```
|
224
|
+
client = Google::Cloud::Speech.speech
|
225
|
+
|
226
|
+
config = {
|
227
|
+
language_code: "en-US",
|
228
|
+
sample_rate_hertz: 44_100,
|
229
|
+
encoding: :FLAC
|
230
|
+
}
|
231
|
+
audio = {
|
232
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
233
|
+
}
|
234
|
+
|
235
|
+
# Use a hash to wrap the normal call arguments (or pass a request object), and
|
236
|
+
# then add further keyword arguments for the call options.
|
237
|
+
response = client.batch_annotate_images(
|
238
|
+
{ config: config, audio: audio },
|
239
|
+
timeout: 10.0)
|
240
|
+
```
|
241
|
+
|
242
|
+
### Streaming Interface
|
243
|
+
|
244
|
+
The client library includes one special streaming method `streaming_recognize`.
|
245
|
+
In the older client, this method employed a streaming interface in which you
|
246
|
+
would register callbacks for different incremental result events. In version
|
247
|
+
1.0, we have standardized the streaming interfaces across the various Ruby
|
248
|
+
client libraries. The `streaming_recognize` call returns a lazy enumerable that
|
249
|
+
you can query for incremental results.
|
250
|
+
|
251
|
+
Old:
|
252
|
+
```
|
253
|
+
client = Google::Cloud::Speech.new
|
254
|
+
|
255
|
+
config = {
|
256
|
+
language_code: "en-US",
|
257
|
+
sample_rate_hertz: 44_100,
|
258
|
+
encoding: :FLAC
|
259
|
+
}
|
260
|
+
stream = client.streaming_recognize config: config
|
261
|
+
|
262
|
+
stream.on_interim { |result| puts "received interim" }
|
263
|
+
stream.on_complete { |result| puts "received complete" }
|
264
|
+
|
265
|
+
stream.send File.read("my_input.flac", mode: "rb")
|
266
|
+
stream.stop
|
267
|
+
|
268
|
+
stream.wait_until_complete!
|
269
|
+
results = stream.results
|
270
|
+
```
|
271
|
+
|
272
|
+
New:
|
273
|
+
```
|
274
|
+
client = Google::Cloud::Speech.speech
|
275
|
+
|
276
|
+
input_stream = Gapic::StreamInput.new
|
277
|
+
output_stream = client.streaming_recognize input_stream
|
278
|
+
|
279
|
+
config = {
|
280
|
+
language_code: "en-US",
|
281
|
+
sample_rate_hertz: 44_100,
|
282
|
+
encoding: :FLAC
|
283
|
+
}
|
284
|
+
streaming_config = { config: config }
|
285
|
+
|
286
|
+
input_stream.push({ streaming_config: streaming_config })
|
287
|
+
input_stream.push({ audio_content: File.read("my_input.flac", mode: "rb") })
|
288
|
+
input_stream.close
|
289
|
+
|
290
|
+
output_stream.each do |response|
|
291
|
+
puts "received: #{response}"
|
292
|
+
end
|
293
|
+
```
|
294
|
+
|
295
|
+
### Handling Errors
|
296
|
+
|
297
|
+
The client reports standard
|
298
|
+
{file:https://github.com/grpc/grpc/blob/master/doc/statuscodes.md gRPC error codes}
|
299
|
+
by raising exceptions. In older releases, these exceptions were located in the
|
300
|
+
`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
|
301
|
+
exception class, defined in the `google-gax` gem. However, these classes were
|
302
|
+
different from the standard exceptions (subclasses of `Google::Cloud::Error`)
|
303
|
+
thrown by other client libraries such as `google-cloud-storage`.
|
304
|
+
|
305
|
+
The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
|
306
|
+
for consistency across all the Google Cloud client libraries. In general, these
|
307
|
+
exceptions have the same name as their counterparts from older releases, but
|
308
|
+
are located in the `Google::Cloud` namespace rather than the `Google::Gax`
|
309
|
+
namespace.
|
310
|
+
|
311
|
+
Old:
|
312
|
+
```
|
313
|
+
client = Google::Cloud::Speech.new
|
314
|
+
|
315
|
+
config = {
|
316
|
+
language_code: "en-US",
|
317
|
+
sample_rate_hertz: 44_100,
|
318
|
+
encoding: :FLAC
|
319
|
+
}
|
320
|
+
audio = {
|
321
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
322
|
+
}
|
323
|
+
|
324
|
+
begin
|
325
|
+
response = client.recognize config, audio
|
326
|
+
rescue Google::Gax::Error => e
|
327
|
+
# Handle exceptions that subclass Google::Gax::Error
|
328
|
+
end
|
329
|
+
```
|
330
|
+
|
331
|
+
New:
|
332
|
+
```
|
333
|
+
client = Google::Cloud::Speech.speech
|
334
|
+
|
335
|
+
config = {
|
336
|
+
language_code: "en-US",
|
337
|
+
sample_rate_hertz: 44_100,
|
338
|
+
encoding: :FLAC
|
339
|
+
}
|
340
|
+
audio = {
|
341
|
+
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.flac"
|
342
|
+
}
|
343
|
+
|
344
|
+
begin
|
345
|
+
response = client.recognize config: config, audio: audio
|
346
|
+
rescue Google::Cloud::Error => e
|
347
|
+
# Handle exceptions that subclass Google::Cloud::Error
|
348
|
+
end
|
349
|
+
```
|
350
|
+
|
351
|
+
### Class Namespaces
|
352
|
+
|
353
|
+
In older releases, the client object was of classes with names like:
|
354
|
+
`Google::Cloud::Speech::V1::SpeechClient`.
|
355
|
+
In the 1.0 release, the client object is of a different class:
|
356
|
+
`Google::Cloud::Speech::V1::Speech::Client`.
|
357
|
+
Note that most users will use the factory methods such as
|
358
|
+
`Google::Cloud::Speech.speech` to create instances of the client object,
|
359
|
+
so you may not need to reference the actual class directly.
|
360
|
+
See [Creating Clients](#creating-clients).
|
361
|
+
|
362
|
+
In older releases, the credentials object was of class
|
363
|
+
`Google::Cloud::Speech::V1::Credentials`.
|
364
|
+
In the 1.0 release, each service has its own credentials class, e.g.
|
365
|
+
`Google::Cloud::Speech::V1::Speech::Credentials`.
|
366
|
+
Again, most users will not need to reference this class directly.
|
367
|
+
See [Client Configuration](#client-configuration).
|
data/README.md
CHANGED
@@ -1,67 +1,54 @@
|
|
1
|
-
# Ruby Client for Cloud Speech API
|
1
|
+
# Ruby Client for the Cloud Speech-to-Text API
|
2
2
|
|
3
|
-
|
4
|
-
Converts audio to text by applying powerful neural network models.
|
5
|
-
- [Client Library Documentation][]
|
6
|
-
- [Product Documentation][]
|
3
|
+
API Client library for the Cloud Speech-to-Text API
|
7
4
|
|
8
|
-
|
9
|
-
In order to use this library, you first need to go through the following
|
10
|
-
steps:
|
5
|
+
Google Speech-to-Text enables developers to convert audio to text by applying powerful neural network models in an easy-to-use API. The API recognizes more than 120 languages and variants to support your global user base. You can enable voice command-and-control, transcribe audio from call centers, and more. It can process real-time streaming or prerecorded audio, using Google's machine learning technology.
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
Actual client classes for the various versions of this API are defined in
|
8
|
+
_versioned_ client gems, with names of the form `google-cloud-speech-v*`.
|
9
|
+
The gem `google-cloud-speech` is the main client library that brings the
|
10
|
+
verisoned gems in as dependencies, and provides high-level methods for
|
11
|
+
constructing clients. More information on versioned clients can be found below
|
12
|
+
in the section titled *Which client should I use?*.
|
13
|
+
|
14
|
+
View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-speech/latest)
|
15
|
+
for this library, google-cloud-speech, to see the convenience methods for
|
16
|
+
constructing client objects. Reference documentation for the client objects
|
17
|
+
themselves can be found in the client library documentation for the versioned
|
18
|
+
client gems:
|
19
|
+
[google-cloud-speech-v1](https://googleapis.dev/ruby/google-cloud-speech-v1/latest),
|
20
|
+
[google-cloud-speech-v1p1beta1](https://googleapis.dev/ruby/google-cloud-speech-v1p1beta1/latest).
|
21
|
+
|
22
|
+
See also the [Product Documentation](https://cloud.google.com/speech-to-text)
|
23
|
+
for more usage information.
|
24
|
+
|
25
|
+
## Quick Start
|
16
26
|
|
17
|
-
### Installation
|
18
27
|
```
|
19
28
|
$ gem install google-cloud-speech
|
20
29
|
```
|
21
30
|
|
22
|
-
|
23
|
-
|
24
|
-
The 0.30.0 release introduced breaking changes relative to the previous release,
|
25
|
-
0.29.0. For more details and instructions to migrate your code, please visit the
|
26
|
-
[migration
|
27
|
-
guide](https://cloud.google.com/speech-to-text/docs/ruby-client-migration).
|
28
|
-
|
29
|
-
### Preview
|
30
|
-
#### SpeechClient
|
31
|
-
```rb
|
32
|
-
require "google/cloud/speech"
|
33
|
-
|
34
|
-
speech_client = Google::Cloud::Speech.new
|
35
|
-
language_code = "en-US"
|
36
|
-
sample_rate_hertz = 44100
|
37
|
-
encoding = :FLAC
|
38
|
-
config = {
|
39
|
-
language_code: language_code,
|
40
|
-
sample_rate_hertz: sample_rate_hertz,
|
41
|
-
encoding: encoding
|
42
|
-
}
|
43
|
-
uri = "gs://gapic-toolkit/hello.flac"
|
44
|
-
audio = { uri: uri }
|
45
|
-
response = speech_client.recognize(config, audio)
|
46
|
-
```
|
31
|
+
In order to use this library, you first need to go through the following steps:
|
47
32
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
to learn more about the product and see How-to Guides.
|
53
|
-
- View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
54
|
-
to see the full list of Cloud APIs that we cover.
|
33
|
+
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
34
|
+
1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
35
|
+
1. [Enable the API.](https://console.cloud.google.com/apis/library/speech.googleapis.com)
|
36
|
+
1. {file:AUTHENTICATION.md Set up authentication.}
|
55
37
|
|
56
|
-
|
57
|
-
|
38
|
+
## Migrating from 0.x versions
|
39
|
+
|
40
|
+
The 1.0 release of the google-cloud-speech client is a significant upgrade
|
41
|
+
based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
42
|
+
and includes substantial interface changes. Existing code written for earlier
|
43
|
+
versions of this library will likely require updates to use this version.
|
44
|
+
See the {file:MIGRATING.md MIGRATING.md} document for more information.
|
58
45
|
|
59
46
|
## Enabling Logging
|
60
47
|
|
61
48
|
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
62
|
-
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib
|
63
|
-
or a [`Google::Cloud::Logging::Logger`](https://googleapis.
|
64
|
-
that will write logs to [
|
49
|
+
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
|
50
|
+
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
51
|
+
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)
|
65
52
|
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
66
53
|
|
67
54
|
Configuring a Ruby stdlib logger:
|
@@ -84,11 +71,69 @@ end
|
|
84
71
|
|
85
72
|
## Supported Ruby Versions
|
86
73
|
|
87
|
-
This library is supported on Ruby 2.
|
74
|
+
This library is supported on Ruby 2.5+.
|
88
75
|
|
89
76
|
Google provides official support for Ruby versions that are actively supported
|
90
77
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
91
|
-
in security maintenance, and not end of life. Currently, this means Ruby 2.
|
78
|
+
in security maintenance, and not end of life. Currently, this means Ruby 2.5
|
92
79
|
and later. Older versions of Ruby _may_ still work, but are unsupported and not
|
93
80
|
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
94
81
|
about the Ruby support schedule.
|
82
|
+
|
83
|
+
## Which client should I use?
|
84
|
+
|
85
|
+
Most modern Ruby client libraries for Google APIs come in two flavors: the main
|
86
|
+
client library with a name such as `google-cloud-speech`,
|
87
|
+
and lower-level _versioned_ client libraries with names such as
|
88
|
+
`google-cloud-speech-v1`.
|
89
|
+
_In most cases, you should install the main client._
|
90
|
+
|
91
|
+
### What's the difference between the main client and a versioned client?
|
92
|
+
|
93
|
+
A _versioned client_ provides a basic set of data types and client classes for
|
94
|
+
a _single version_ of a specific service. (That is, for a service with multiple
|
95
|
+
versions, there might be a separate versioned client for each service version.)
|
96
|
+
Most versioned clients are written and maintained by a code generator.
|
97
|
+
|
98
|
+
The _main client_ is designed to provide you with the _recommended_ client
|
99
|
+
interfaces for the service. There will be only one main client for any given
|
100
|
+
service, even a service with multiple versions. The main client includes
|
101
|
+
factory methods for constructing the client objects we recommend for most
|
102
|
+
users. In some cases, those will be classes provided by an underlying versioned
|
103
|
+
client; in other cases, they will be handwritten higher-level client objects
|
104
|
+
with additional capabilities, convenience methods, or best practices built in.
|
105
|
+
Generally, the main client will default to a recommended service version,
|
106
|
+
although in some cases you can override this if you need to talk to a specific
|
107
|
+
service version.
|
108
|
+
|
109
|
+
### Why would I want to use the main client?
|
110
|
+
|
111
|
+
We recommend that most users install the main client gem for a service. You can
|
112
|
+
identify this gem as the one _without_ a version in its name, e.g.
|
113
|
+
`google-cloud-speech`.
|
114
|
+
The main client is recommended because it will embody the best practices for
|
115
|
+
accessing the service, and may also provide more convenient interfaces or
|
116
|
+
tighter integration into frameworks and third-party libraries. In addition, the
|
117
|
+
documentation and samples published by Google will generally demonstrate use of
|
118
|
+
the main client.
|
119
|
+
|
120
|
+
### Why would I want to use a versioned client?
|
121
|
+
|
122
|
+
You can use a versioned client if you are content with a possibly lower-level
|
123
|
+
class interface, you explicitly want to avoid features provided by the main
|
124
|
+
client, or you want to access a specific service version not be covered by the
|
125
|
+
main client. You can identify versioned client gems because the service version
|
126
|
+
is part of the name, e.g. `google-cloud-speech-v1`.
|
127
|
+
|
128
|
+
### What about the google-apis-<name> clients?
|
129
|
+
|
130
|
+
Client library gems with names that begin with `google-apis-` are based on an
|
131
|
+
older code generation technology. They talk to a REST/JSON backend (whereas
|
132
|
+
most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may
|
133
|
+
not offer the same performance, features, and ease of use provided by more
|
134
|
+
modern clients.
|
135
|
+
|
136
|
+
The `google-apis-` clients have wide coverage across Google services, so you
|
137
|
+
might need to use one if there is no modern client available for the service.
|
138
|
+
However, if a modern client is available, we generally recommend it over the
|
139
|
+
older `google-apis-` clients.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Speech
|
19
|
+
VERSION = "1.2.1".freeze
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|