google-cloud-speech 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e04f1437ef7d4bf55b73907f431f1195623a774d
4
- data.tar.gz: 8dcd89edcce66e99b857b2191ae31a3ef7790561
3
+ metadata.gz: 36b97feadc80ff3fb73b37650feeb33ac875030f
4
+ data.tar.gz: 653975eca064e0e00a4d42c42b5296bdf5efd073
5
5
  SHA512:
6
- metadata.gz: df413efa7c50545f37b0606e6015b446c6e4e9a940868fb16561b6d352bf9ba7d69a560bc4898ec5f5e145b94f5727183fc01ddc46e06066ec0c9d4a3e6bb58a
7
- data.tar.gz: 39c89287e80db4ee918f14e20f89c3caff7d2b332881644b77a6838b7e41dadead53f7d44ae7d7f6c727d9ed78a93f8754c12fad1a3a52a8c7994dfe68ede62f
6
+ metadata.gz: e07b99125ff4f79b79a5676ebe0ba321a46d26ef7f27fe0f779a4676f91176520820ae5328c3e9f56324918745f95fa1399cab16b142bbc24aab06f1b1005b70
7
+ data.tar.gz: 5708a7d8aff0e3152179315ce5be6bb18bd04d0df5538f24ed822bfcd28e719aee436eaaea7dde3289f505f8136b7ae5a9232b9eafdd1e221b3b16565767eb0e
data/.yardopts CHANGED
@@ -1,7 +1,5 @@
1
1
  --no-private
2
2
  --title=Google Cloud Speech
3
- --exclude lib/google/cloud/speech/v1beta1
4
- --exclude lib/google/cloud/speech/v1beta1.rb
5
3
  --markup markdown
6
4
 
7
5
  ./lib/**/*.rb
data/README.md CHANGED
@@ -26,9 +26,11 @@ require "google/cloud/speech"
26
26
  speech = Google::Cloud::Speech.new
27
27
 
28
28
  audio = speech.audio "path/to/audio.raw",
29
- encoding: :raw, sample_rate: 16000
30
- results = audio.recognize
29
+ encoding: :raw,
30
+ language: "en-US",
31
+ sample_rate: 16000
31
32
 
33
+ results = audio.recognize
32
34
  result = results.first
33
35
  result.transcript #=> "how old is the Brooklyn Bridge"
34
36
  result.confidence #=> 0.9826789498329163
@@ -51,7 +51,9 @@ module Google
51
51
  # speech = gcloud.speech
52
52
  #
53
53
  # audio = speech.audio "path/to/audio.raw",
54
- # encoding: :raw, sample_rate: 16000
54
+ # encoding: :raw,
55
+ # language: "en-US",
56
+ # sample_rate: 16000
55
57
  #
56
58
  # @example The default scope can be overridden with the `scope` option:
57
59
  # require "google/cloud"
@@ -97,7 +99,9 @@ module Google
97
99
  # speech = Google::Cloud.speech
98
100
  #
99
101
  # audio = speech.audio "path/to/audio.raw",
100
- # encoding: :raw, sample_rate: 16000
102
+ # encoding: :raw,
103
+ # language: "en-US",
104
+ # sample_rate: 16000
101
105
  #
102
106
  def self.speech project = nil, keyfile = nil, scope: nil, timeout: nil,
103
107
  client_config: nil
@@ -56,7 +56,9 @@ module Google
56
56
  # speech = Google::Cloud::Speech.new
57
57
  #
58
58
  # audio = speech.audio "path/to/audio.raw",
59
- # encoding: :raw, sample_rate: 16000
59
+ # encoding: :raw,
60
+ # language: "en-US",
61
+ # sample_rate: 16000
60
62
  # ```
61
63
  #
62
64
  # Or, you can initialize the audio instance with a Google Cloud Storage URI:
@@ -67,7 +69,9 @@ module Google
67
69
  # speech = Google::Cloud::Speech.new
68
70
  #
69
71
  # audio = speech.audio "gs://bucket-name/path/to/audio.raw",
70
- # encoding: :raw, sample_rate: 16000
72
+ # encoding: :raw,
73
+ # language: "en-US",
74
+ # sample_rate: 16000
71
75
  # ```
72
76
  #
73
77
  # Or, with a Google Cloud Storage File object:
@@ -84,7 +88,10 @@ module Google
84
88
  #
85
89
  # speech = Google::Cloud::Speech.new
86
90
  #
87
- # audio = speech.audio file, encoding: :raw, sample_rate: 16000
91
+ # audio = speech.audio file,
92
+ # encoding: :raw,
93
+ # language: "en-US",
94
+ # sample_rate: 16000
88
95
  # ```
89
96
  #
90
97
  # ## Recognizing speech
@@ -105,17 +112,19 @@ module Google
105
112
  # speech = Google::Cloud::Speech.new
106
113
  #
107
114
  # audio = speech.audio "path/to/audio.raw",
108
- # encoding: :raw, sample_rate: 16000
109
- # results = audio.recognize
115
+ # encoding: :raw,
116
+ # language: "en-US",
117
+ # sample_rate: 16000
110
118
  #
119
+ # results = audio.recognize
111
120
  # result = results.first
112
121
  # result.transcript #=> "how old is the Brooklyn Bridge"
113
122
  # result.confidence #=> 0.9826789498329163
114
123
  # ```
115
124
  #
116
- # Use {Speech::Audio#recognize_job} for asynchronous speech recognition,
117
- # in which a {Speech::Job} is returned immediately after the audio data has
118
- # been sent. The job can be refreshed to retrieve {Speech::Result} objects
125
+ # Use {Speech::Audio#process} for asynchronous speech recognition, in which
126
+ # a {Speech::Operation} is returned immediately after the audio data has
127
+ # been sent. The op can be refreshed to retrieve {Speech::Result} objects
119
128
  # once the audio data has been processed.
120
129
  #
121
130
  # ```ruby
@@ -124,13 +133,15 @@ module Google
124
133
  # speech = Google::Cloud::Speech.new
125
134
  #
126
135
  # audio = speech.audio "path/to/audio.raw",
127
- # encoding: :raw, sample_rate: 16000
128
- # job = audio.recognize_job
136
+ # encoding: :raw,
137
+ # language: "en-US",
138
+ # sample_rate: 16000
129
139
  #
130
- # job.done? #=> false
131
- # job.reload!
132
- # job.done? #=> true
133
- # results = job.results
140
+ # op = audio.process
141
+ # op.done? #=> false
142
+ # op.wait_until_done!
143
+ # op.done? #=> true
144
+ # results = op.results
134
145
  #
135
146
  # result = results.first
136
147
  # result.transcript #=> "how old is the Brooklyn Bridge"
@@ -149,14 +160,9 @@ module Google
149
160
  #
150
161
  # audio = speech.audio "path/to/audio.raw"
151
162
  #
152
- # stream = audio.stream encoding: :raw, sample_rate: 16000
153
- #
154
- # # register callback for when a result is returned
155
- # stream.on_result do |results|
156
- # result = results.first
157
- # result.transcript #=> "how old is the Brooklyn Bridge"
158
- # result.confidence #=> 0.9826789498329163
159
- # end
163
+ # stream = audio.stream encoding: :raw,
164
+ # language: "en-US",
165
+ # sample_rate: 16000
160
166
  #
161
167
  # # Stream 5 seconds of audio from the microphone
162
168
  # # Actual implementation of microphone input varies by platform
@@ -165,6 +171,12 @@ module Google
165
171
  # end
166
172
  #
167
173
  # stream.stop
174
+ # stream.wait_until_complete!
175
+ #
176
+ # results = stream.results
177
+ # result = results.first
178
+ # result.transcript #=> "how old is the Brooklyn Bridge"
179
+ # result.confidence #=> 0.9826789498329163
168
180
  # ```
169
181
  #
170
182
  # Obtaining audio data from input sources such as a Microphone is outside
@@ -203,7 +215,9 @@ module Google
203
215
  # speech = Google::Cloud::Speech.new
204
216
  #
205
217
  # audio = speech.audio "path/to/audio.raw",
206
- # encoding: :raw, sample_rate: 16000
218
+ # encoding: :raw,
219
+ # language: "en-US",
220
+ # sample_rate: 16000
207
221
  #
208
222
  def self.new project: nil, keyfile: nil, scope: nil, timeout: nil,
209
223
  client_config: nil
@@ -39,15 +39,17 @@ module Google
39
39
  # speech = Google::Cloud::Speech.new
40
40
  #
41
41
  # audio = speech.audio "path/to/audio.raw",
42
- # encoding: :raw, sample_rate: 16000
43
- # results = audio.recognize
42
+ # encoding: :raw,
43
+ # language: "en-US",
44
+ # sample_rate: 16000
44
45
  #
46
+ # results = audio.recognize
45
47
  # result = results.first
46
48
  # result.transcript #=> "how old is the Brooklyn Bridge"
47
49
  # result.confidence #=> 0.9826789498329163
48
50
  #
49
51
  class Audio
50
- # @private The V1beta1::RecognitionAudio object.
52
+ # @private The V1::RecognitionAudio object.
51
53
  attr_reader :grpc
52
54
  # @private The Project object.
53
55
  attr_reader :speech
@@ -69,6 +71,15 @@ module Google
69
71
  # be 8000 Hz.) (AMR)
70
72
  # * `amr_wb` - Adaptive Multi-Rate Wideband codec. (`sample_rate` must
71
73
  # be 16000 Hz.) (AMR_WB)
74
+ # * `ogg_opus` - Ogg Mapping for Opus. (OGG_OPUS)
75
+ #
76
+ # Lossy codecs do not recommend, as they result in a lower-quality
77
+ # speech transcription.
78
+ # * `speex` - Speex with header byte. (SPEEX_WITH_HEADER_BYTE)
79
+ #
80
+ # Lossy codecs do not recommend, as they result in a lower-quality
81
+ # speech transcription. If you must use a low-bitrate encoder,
82
+ # OGG_OPUS is preferred.
72
83
  #
73
84
  # @return [String,Symbol]
74
85
  #
@@ -78,17 +89,23 @@ module Google
78
89
  # speech = Google::Cloud::Speech.new
79
90
  #
80
91
  # audio = speech.audio "path/to/audio.raw",
81
- # encoding: :raw, sample_rate: 16000
92
+ # language: "en-US",
93
+ # sample_rate: 16000
94
+ #
95
+ # audio.encoding = :raw
96
+ # audio.encoding #=> :raw
82
97
  #
83
98
  attr_accessor :encoding
84
99
 
85
100
  ##
86
- # Sample rate in Hertz of the audio data to be recognized. Valid values
87
- # are: 8000-48000. 16000 is optimal. For best results, set the sampling
88
- # rate of the audio source to 16000 Hz. If that's not possible, use the
89
- # native sample rate of the audio source (instead of re-sampling).
101
+ # The language of the supplied audio as a
102
+ # [BCP-47](https://tools.ietf.org/html/bcp47) language code. e.g.
103
+ # "en-US" for English (United States), "en-GB" for English (United
104
+ # Kingdom), "fr-FR" for French (France). See [Language
105
+ # Support](https://cloud.google.com/speech/docs/languages) for a list of
106
+ # the currently supported language codes.
90
107
  #
91
- # @return [Integer]
108
+ # @return [String,Symbol]
92
109
  #
93
110
  # @example
94
111
  # require "google/cloud/speech"
@@ -96,18 +113,21 @@ module Google
96
113
  # speech = Google::Cloud::Speech.new
97
114
  #
98
115
  # audio = speech.audio "path/to/audio.raw",
99
- # encoding: :raw, sample_rate: 16000
116
+ # encoding: :raw,
117
+ # sample_rate: 16000
100
118
  #
101
- attr_accessor :sample_rate
119
+ # audio.language = "en-US"
120
+ # audio.language #=> "en-US"
121
+ #
122
+ attr_accessor :language
102
123
 
103
124
  ##
104
- # The language of the supplied audio as a
105
- # [BCP-47](https://tools.ietf.org/html/bcp47) language code.
106
- # If not specified, the language defaults to "en-US". See [Language
107
- # Support](https://cloud.google.com/speech/docs/languages)
108
- # for a list of the currently supported language codes.
125
+ # Sample rate in Hertz of the audio data to be recognized. Valid values
126
+ # are: 8000-48000. 16000 is optimal. For best results, set the sampling
127
+ # rate of the audio source to 16000 Hz. If that's not possible, use the
128
+ # native sample rate of the audio source (instead of re-sampling).
109
129
  #
110
- # @return [String,Symbol]
130
+ # @return [Integer]
111
131
  #
112
132
  # @example
113
133
  # require "google/cloud/speech"
@@ -115,15 +135,18 @@ module Google
115
135
  # speech = Google::Cloud::Speech.new
116
136
  #
117
137
  # audio = speech.audio "path/to/audio.raw",
118
- # encoding: :raw, sample_rate: 16000,
119
- # language: :en
138
+ # encoding: :raw,
139
+ # language: "en-US"
120
140
  #
121
- attr_accessor :language
141
+ # audio.sample_rate = 16000
142
+ # audio.sample_rate #=> 16000
143
+ #
144
+ attr_accessor :sample_rate
122
145
 
123
146
  ##
124
147
  # @private Creates a new Audio instance.
125
148
  def initialize
126
- @grpc = V1beta1::RecognitionAudio.new
149
+ @grpc = V1::RecognitionAudio.new
127
150
  end
128
151
 
129
152
  ##
@@ -177,9 +200,11 @@ module Google
177
200
  # speech = Google::Cloud::Speech.new
178
201
  #
179
202
  # audio = speech.audio "path/to/audio.raw",
180
- # encoding: :raw, sample_rate: 16000
181
- # results = audio.recognize
203
+ # encoding: :raw,
204
+ # language: "en-US",
205
+ # sample_rate: 16000
182
206
  #
207
+ # results = audio.recognize
183
208
  # result = results.first
184
209
  # result.transcript #=> "how old is the Brooklyn Bridge"
185
210
  # result.confidence #=> 0.9826789498329163
@@ -196,9 +221,9 @@ module Google
196
221
 
197
222
  ##
198
223
  # Performs asynchronous speech recognition. Requests are processed
199
- # asynchronously, meaning a Job is returned once the audio data has been
200
- # sent, and can be refreshed to retrieve recognition results once the
201
- # audio data has been processed.
224
+ # asynchronously, meaning a Operation is returned once the audio data
225
+ # has been sent, and can be refreshed to retrieve recognition results
226
+ # once the audio data has been processed.
202
227
  #
203
228
  # @see https://cloud.google.com/speech/docs/basics#async-responses
204
229
  # Asynchronous Speech API Responses
@@ -215,8 +240,8 @@ module Google
215
240
  # recognize them. See [usage
216
241
  # limits](https://cloud.google.com/speech/limits#content). Optional.
217
242
  #
218
- # @return [Job] A resource represents the long-running, asynchronous
219
- # processing of a speech-recognition operation.
243
+ # @return [Operation] A resource represents the long-running,
244
+ # asynchronous processing of a speech-recognition operation.
220
245
  #
221
246
  # @example
222
247
  # require "google/cloud/speech"
@@ -224,25 +249,29 @@ module Google
224
249
  # speech = Google::Cloud::Speech.new
225
250
  #
226
251
  # audio = speech.audio "path/to/audio.raw",
227
- # encoding: :raw, sample_rate: 16000
228
- # job = audio.recognize_job
229
- #
230
- # job.done? #=> false
231
- # job.reload!
232
- # job.done? #=> true
233
- # results = job.results
234
- #
235
- def recognize_job max_alternatives: nil, profanity_filter: nil,
236
- phrases: nil
252
+ # encoding: :raw,
253
+ # language: "en-US",
254
+ # sample_rate: 16000
255
+ #
256
+ # op = audio.process
257
+ # op.done? #=> false
258
+ # op.reload!
259
+ # op.done? #=> true
260
+ # results = op.results
261
+ #
262
+ def process max_alternatives: nil, profanity_filter: nil,
263
+ phrases: nil
237
264
  ensure_speech!
238
265
 
239
- speech.recognize_job self, encoding: encoding,
240
- sample_rate: sample_rate,
241
- language: language,
242
- max_alternatives: max_alternatives,
243
- profanity_filter: profanity_filter,
244
- phrases: phrases
266
+ speech.process self, encoding: encoding,
267
+ sample_rate: sample_rate,
268
+ language: language,
269
+ max_alternatives: max_alternatives,
270
+ profanity_filter: profanity_filter,
271
+ phrases: phrases
245
272
  end
273
+ alias_method :long_running_recognize, :process
274
+ alias_method :recognize_job, :process
246
275
 
247
276
  ##
248
277
  # @private The Google API Client object for the Audio.
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  require "google/cloud/credentials"
17
- require "google/cloud/speech/v1beta1"
17
+ require "google/cloud/speech/v1"
18
18
 
19
19
  module Google
20
20
  module Cloud
@@ -22,7 +22,7 @@ module Google
22
22
  ##
23
23
  # @private Represents the OAuth 2.0 signing logic for Speech.
24
24
  class Credentials < Google::Cloud::Credentials
25
- SCOPE = V1beta1::SpeechClient::ALL_SCOPES
25
+ SCOPE = V1::SpeechClient::ALL_SCOPES
26
26
  PATH_ENV_VARS = %w(SPEECH_KEYFILE GOOGLE_CLOUD_KEYFILE GCLOUD_KEYFILE)
27
27
  JSON_ENV_VARS = %w(SPEECH_KEYFILE_JSON GOOGLE_CLOUD_KEYFILE_JSON
28
28
  GCLOUD_KEYFILE_JSON)
@@ -0,0 +1,262 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
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
+ # http://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
+ require "google/cloud/speech/v1"
17
+ require "google/cloud/errors"
18
+
19
+ module Google
20
+ module Cloud
21
+ module Speech
22
+ ##
23
+ # # Operation
24
+ #
25
+ # A resource represents the long-running, asynchronous processing of a
26
+ # speech-recognition operation. The op can be refreshed to retrieve
27
+ # recognition results once the audio data has been processed.
28
+ #
29
+ # See {Project#process} and {Audio#process}.
30
+ #
31
+ # @see https://cloud.google.com/speech/docs/basics#async-responses
32
+ # Asynchronous Speech API Responses
33
+ # @see https://cloud.google.com/speech/reference/rpc/google.longrunning#google.longrunning.Operations
34
+ # Long-running Operation
35
+ #
36
+ # @example
37
+ # require "google/cloud/speech"
38
+ #
39
+ # speech = Google::Cloud::Speech.new
40
+ #
41
+ # op = speech.process "path/to/audio.raw",
42
+ # encoding: :raw,
43
+ # language: "en-US",
44
+ # sample_rate: 16000
45
+ #
46
+ # op.done? #=> false
47
+ # op.reload! # API call
48
+ # op.done? #=> true
49
+ # results = op.results
50
+ #
51
+ class Operation
52
+ ##
53
+ # @private The Google::Gax::Operation gRPC object.
54
+ attr_accessor :grpc
55
+
56
+ ##
57
+ # @private Creates a new Job instance.
58
+ def initialize
59
+ @grpc = nil
60
+ end
61
+
62
+ ##
63
+ # The unique identifier for the long running operation.
64
+ #
65
+ # @return [String] The unique identifier for the long running operation.
66
+ #
67
+ # @example
68
+ # require "google/cloud/speech"
69
+ #
70
+ # speech = Google::Cloud::Speech.new
71
+ #
72
+ # op = speech.process "path/to/audio.raw",
73
+ # encoding: :raw,
74
+ # language: "en-US",
75
+ # sample_rate: 16000
76
+ #
77
+ # op.id #=> "1234567890"
78
+ #
79
+ def id
80
+ @grpc.name
81
+ end
82
+
83
+ ##
84
+ # Checks if the speech-recognition processing of the audio data is
85
+ # complete.
86
+ #
87
+ # @return [boolean] `true` when complete, `false` otherwise.
88
+ #
89
+ # @example
90
+ # require "google/cloud/speech"
91
+ #
92
+ # speech = Google::Cloud::Speech.new
93
+ #
94
+ # op = speech.process "path/to/audio.raw",
95
+ # encoding: :raw,
96
+ # language: "en-US",
97
+ # sample_rate: 16000
98
+ #
99
+ # op.done? #=> false
100
+ #
101
+ def done?
102
+ @grpc.done?
103
+ end
104
+
105
+ ##
106
+ # A speech recognition result corresponding to a portion of the audio.
107
+ #
108
+ # @return [Array<Result>] The transcribed text of audio recognized. If
109
+ # the op is not done this will return `nil`.
110
+ #
111
+ # @example
112
+ # require "google/cloud/speech"
113
+ #
114
+ # speech = Google::Cloud::Speech.new
115
+ #
116
+ # op = speech.process "path/to/audio.raw",
117
+ # encoding: :raw,
118
+ # language: "en-US",
119
+ # sample_rate: 16000
120
+ #
121
+ # op.done? #=> true
122
+ # op.results? #=> true
123
+ # results = op.results
124
+ #
125
+ def results
126
+ return nil unless results?
127
+ @grpc.response.results.map do |result_grpc|
128
+ Result.from_grpc result_grpc
129
+ end
130
+ end
131
+
132
+ ##
133
+ # Checks if the speech-recognition processing of the audio data is
134
+ # complete.
135
+ #
136
+ # @return [boolean] `true` when complete, `false` otherwise.
137
+ #
138
+ # @example
139
+ # require "google/cloud/speech"
140
+ #
141
+ # speech = Google::Cloud::Speech.new
142
+ #
143
+ # op = speech.process "path/to/audio.raw",
144
+ # encoding: :raw,
145
+ # language: "en-US",
146
+ # sample_rate: 16000
147
+ #
148
+ # op.done? #=> true
149
+ # op.results? #=> true
150
+ # results = op.results
151
+ #
152
+ def results?
153
+ @grpc.response?
154
+ end
155
+
156
+ ##
157
+ # The error information if the speech-recognition processing of the
158
+ # audio data has returned an error.
159
+ #
160
+ # @return [Google::Cloud::Error] The error.
161
+ #
162
+ # @example
163
+ # require "google/cloud/speech"
164
+ #
165
+ # speech = Google::Cloud::Speech.new
166
+ #
167
+ # op = speech.process "path/to/audio.raw",
168
+ # encoding: :raw,
169
+ # language: "en-US",
170
+ # sample_rate: 16000
171
+ #
172
+ # op.done? #=> true
173
+ # op.error? #=> true
174
+ # error = op.error
175
+ #
176
+ def error
177
+ return nil unless error?
178
+ Google::Cloud::Error.from_error @grpc.error
179
+ end
180
+
181
+ ##
182
+ # Checks if the speech-recognition processing of the audio data has
183
+ # returned an error.
184
+ #
185
+ # @return [boolean] `true` when errored, `false` otherwise.
186
+ #
187
+ # @example
188
+ # require "google/cloud/speech"
189
+ #
190
+ # speech = Google::Cloud::Speech.new
191
+ #
192
+ # op = speech.process "path/to/audio.raw",
193
+ # encoding: :raw,
194
+ # language: "en-US",
195
+ # sample_rate: 16000
196
+ #
197
+ # op.done? #=> true
198
+ # op.error? #=> true
199
+ # error = op.error
200
+ #
201
+ def error?
202
+ @grpc.error?
203
+ end
204
+
205
+ ##
206
+ # Reloads the op with current data from the long-running, asynchronous
207
+ # processing of a speech-recognition operation.
208
+ #
209
+ # @example
210
+ # require "google/cloud/speech"
211
+ #
212
+ # speech = Google::Cloud::Speech.new
213
+ #
214
+ # op = speech.process "path/to/audio.raw",
215
+ # encoding: :raw,
216
+ # language: "en-US",
217
+ # sample_rate: 16000
218
+ #
219
+ # op.done? #=> false
220
+ # op.reload! # API call
221
+ # op.done? #=> true
222
+ #
223
+ def reload!
224
+ @grpc.reload!
225
+ self
226
+ end
227
+ alias_method :refresh!, :reload!
228
+
229
+ ##
230
+ # Reloads the op until the operation is complete. The delay between
231
+ # reloads will incrementally increase.
232
+ #
233
+ # @example
234
+ # require "google/cloud/speech"
235
+ #
236
+ # speech = Google::Cloud::Speech.new
237
+ #
238
+ # op = speech.process "path/to/audio.raw",
239
+ # encoding: :raw,
240
+ # language: "en-US",
241
+ # sample_rate: 16000
242
+ #
243
+ # op.done? #=> false
244
+ # op.wait_until_done!
245
+ # op.done? #=> true
246
+ #
247
+ def wait_until_done!
248
+ @grpc.wait_until_done!
249
+ end
250
+
251
+ ##
252
+ # @private New Result::Job from a Google::Gax::Operation
253
+ # object.
254
+ def self.from_grpc grpc
255
+ new.tap do |job|
256
+ job.instance_variable_set :@grpc, grpc
257
+ end
258
+ end
259
+ end
260
+ end
261
+ end
262
+ end