google-cloud-speech-v1 0.4.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d5316a918da7c2ad7f23c0374171f72052da19f4ebc2c9904dca316d9d61419
4
- data.tar.gz: 6d7470cf60fc24d5955e73a3a4a340201a262bac6bc90ed6b0c39a2aa69f0608
3
+ metadata.gz: 4df4067d98b6dde2049d349aaba7e230db5c79344083061a7836304474c8c7e4
4
+ data.tar.gz: 331c15b79d60c83e8f6f613059765b9c51587e223d7f4cfdf779eb5372661356
5
5
  SHA512:
6
- metadata.gz: 16d09dda5f5cbe83f106bb56de5165a7864a21a175f0f89aa4dd886121321f015d67d11436b928d9b1454979b9689bf9adf08e422a65454683fd50738c0d18b4
7
- data.tar.gz: 97eda913ae53329053ac96837a71384f0e408658bd5c257f6b089be9478d4a43c8904b0c4b09d839b178c926438bb304c24532eecffb7ff1ff1b9dfcad2c8a80
6
+ metadata.gz: d7b43c7650ab17d38e959b078bdf2d9bb339b06befca56f17f11c1c5a7000d560fa7cde22779781c0e1d598e3e0e4faf236fe3f47221456b25e0d5c0b78217e8
7
+ data.tar.gz: 7e24249767948c0e9a766993dc71c67b4c71bca11afcb2620cf1068b65b0d8afed18878d31e925dc7f00a16834f75c30513bfbeddbc3e9195964e9a968e80154
@@ -1,16 +1,18 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/speech/v1/cloud_speech.proto
3
3
 
4
- require 'google/protobuf'
5
-
6
4
  require 'google/api/annotations_pb'
7
5
  require 'google/api/client_pb'
8
6
  require 'google/api/field_behavior_pb'
7
+ require 'google/cloud/speech/v1/resource_pb'
9
8
  require 'google/longrunning/operations_pb'
10
9
  require 'google/protobuf/any_pb'
11
10
  require 'google/protobuf/duration_pb'
12
11
  require 'google/protobuf/timestamp_pb'
12
+ require 'google/protobuf/wrappers_pb'
13
13
  require 'google/rpc/status_pb'
14
+ require 'google/protobuf'
15
+
14
16
  Google::Protobuf::DescriptorPool.generated_pool.build do
15
17
  add_file("google/cloud/speech/v1/cloud_speech.proto", :syntax => :proto3) do
16
18
  add_message "google.cloud.speech.v1.RecognizeRequest" do
@@ -20,6 +22,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
20
22
  add_message "google.cloud.speech.v1.LongRunningRecognizeRequest" do
21
23
  optional :config, :message, 1, "google.cloud.speech.v1.RecognitionConfig"
22
24
  optional :audio, :message, 2, "google.cloud.speech.v1.RecognitionAudio"
25
+ optional :output_config, :message, 4, "google.cloud.speech.v1.TranscriptOutputConfig"
26
+ end
27
+ add_message "google.cloud.speech.v1.TranscriptOutputConfig" do
28
+ oneof :output_type do
29
+ optional :gcs_uri, :string, 1
30
+ end
23
31
  end
24
32
  add_message "google.cloud.speech.v1.StreamingRecognizeRequest" do
25
33
  oneof :streaming_request do
@@ -38,11 +46,16 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
38
46
  optional :audio_channel_count, :int32, 7
39
47
  optional :enable_separate_recognition_per_channel, :bool, 12
40
48
  optional :language_code, :string, 3
49
+ repeated :alternative_language_codes, :string, 18
41
50
  optional :max_alternatives, :int32, 4
42
51
  optional :profanity_filter, :bool, 5
52
+ optional :adaptation, :message, 20, "google.cloud.speech.v1.SpeechAdaptation"
43
53
  repeated :speech_contexts, :message, 6, "google.cloud.speech.v1.SpeechContext"
44
54
  optional :enable_word_time_offsets, :bool, 8
55
+ optional :enable_word_confidence, :bool, 15
45
56
  optional :enable_automatic_punctuation, :bool, 11
57
+ optional :enable_spoken_punctuation, :message, 22, "google.protobuf.BoolValue"
58
+ optional :enable_spoken_emojis, :message, 23, "google.protobuf.BoolValue"
46
59
  optional :diarization_config, :message, 19, "google.cloud.speech.v1.SpeakerDiarizationConfig"
47
60
  optional :metadata, :message, 9, "google.cloud.speech.v1.RecognitionMetadata"
48
61
  optional :model, :string, 13
@@ -57,6 +70,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
57
70
  value :AMR_WB, 5
58
71
  value :OGG_OPUS, 6
59
72
  value :SPEEX_WITH_HEADER_BYTE, 7
73
+ value :WEBM_OPUS, 9
60
74
  end
61
75
  add_message "google.cloud.speech.v1.SpeakerDiarizationConfig" do
62
76
  optional :enable_speaker_diarization, :bool, 1
@@ -107,6 +121,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
107
121
  end
108
122
  add_message "google.cloud.speech.v1.SpeechContext" do
109
123
  repeated :phrases, :string, 1
124
+ optional :boost, :float, 4
110
125
  end
111
126
  add_message "google.cloud.speech.v1.RecognitionAudio" do
112
127
  oneof :audio_source do
@@ -116,19 +131,25 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
116
131
  end
117
132
  add_message "google.cloud.speech.v1.RecognizeResponse" do
118
133
  repeated :results, :message, 2, "google.cloud.speech.v1.SpeechRecognitionResult"
134
+ optional :total_billed_time, :message, 3, "google.protobuf.Duration"
119
135
  end
120
136
  add_message "google.cloud.speech.v1.LongRunningRecognizeResponse" do
121
137
  repeated :results, :message, 2, "google.cloud.speech.v1.SpeechRecognitionResult"
138
+ optional :total_billed_time, :message, 3, "google.protobuf.Duration"
139
+ optional :output_config, :message, 6, "google.cloud.speech.v1.TranscriptOutputConfig"
140
+ optional :output_error, :message, 7, "google.rpc.Status"
122
141
  end
123
142
  add_message "google.cloud.speech.v1.LongRunningRecognizeMetadata" do
124
143
  optional :progress_percent, :int32, 1
125
144
  optional :start_time, :message, 2, "google.protobuf.Timestamp"
126
145
  optional :last_update_time, :message, 3, "google.protobuf.Timestamp"
146
+ optional :uri, :string, 4
127
147
  end
128
148
  add_message "google.cloud.speech.v1.StreamingRecognizeResponse" do
129
149
  optional :error, :message, 1, "google.rpc.Status"
130
150
  repeated :results, :message, 2, "google.cloud.speech.v1.StreamingRecognitionResult"
131
151
  optional :speech_event_type, :enum, 4, "google.cloud.speech.v1.StreamingRecognizeResponse.SpeechEventType"
152
+ optional :total_billed_time, :message, 5, "google.protobuf.Duration"
132
153
  end
133
154
  add_enum "google.cloud.speech.v1.StreamingRecognizeResponse.SpeechEventType" do
134
155
  value :SPEECH_EVENT_UNSPECIFIED, 0
@@ -145,6 +166,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
145
166
  add_message "google.cloud.speech.v1.SpeechRecognitionResult" do
146
167
  repeated :alternatives, :message, 1, "google.cloud.speech.v1.SpeechRecognitionAlternative"
147
168
  optional :channel_tag, :int32, 2
169
+ optional :result_end_time, :message, 4, "google.protobuf.Duration"
170
+ optional :language_code, :string, 5
148
171
  end
149
172
  add_message "google.cloud.speech.v1.SpeechRecognitionAlternative" do
150
173
  optional :transcript, :string, 1
@@ -155,6 +178,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
155
178
  optional :start_time, :message, 1, "google.protobuf.Duration"
156
179
  optional :end_time, :message, 2, "google.protobuf.Duration"
157
180
  optional :word, :string, 3
181
+ optional :confidence, :float, 4
158
182
  optional :speaker_tag, :int32, 5
159
183
  end
160
184
  end
@@ -166,6 +190,7 @@ module Google
166
190
  module V1
167
191
  RecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.RecognizeRequest").msgclass
168
192
  LongRunningRecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.LongRunningRecognizeRequest").msgclass
193
+ TranscriptOutputConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.TranscriptOutputConfig").msgclass
169
194
  StreamingRecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.StreamingRecognizeRequest").msgclass
170
195
  StreamingRecognitionConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.StreamingRecognitionConfig").msgclass
171
196
  RecognitionConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.RecognitionConfig").msgclass
@@ -1,7 +1,7 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: google/cloud/speech/v1/cloud_speech.proto for package 'google.cloud.speech.v1'
3
3
  # Original file comments:
4
- # Copyright 2019 Google LLC.
4
+ # Copyright 2021 Google LLC
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- #
19
18
 
20
19
  require 'grpc'
21
20
  require 'google/cloud/speech/v1/cloud_speech_pb'
@@ -28,7 +27,7 @@ module Google
28
27
  # Service that implements Google Cloud Speech API.
29
28
  class Service
30
29
 
31
- include GRPC::GenericService
30
+ include ::GRPC::GenericService
32
31
 
33
32
  self.marshal_class_method = :encode
34
33
  self.unmarshal_class_method = :decode
@@ -0,0 +1,48 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/speech/v1/resource.proto
3
+
4
+ require 'google/api/resource_pb'
5
+ require 'google/protobuf/timestamp_pb'
6
+ require 'google/api/annotations_pb'
7
+ require 'google/protobuf'
8
+
9
+ Google::Protobuf::DescriptorPool.generated_pool.build do
10
+ add_file("google/cloud/speech/v1/resource.proto", :syntax => :proto3) do
11
+ add_message "google.cloud.speech.v1.CustomClass" do
12
+ optional :name, :string, 1
13
+ optional :custom_class_id, :string, 2
14
+ repeated :items, :message, 3, "google.cloud.speech.v1.CustomClass.ClassItem"
15
+ end
16
+ add_message "google.cloud.speech.v1.CustomClass.ClassItem" do
17
+ optional :value, :string, 1
18
+ end
19
+ add_message "google.cloud.speech.v1.PhraseSet" do
20
+ optional :name, :string, 1
21
+ repeated :phrases, :message, 2, "google.cloud.speech.v1.PhraseSet.Phrase"
22
+ optional :boost, :float, 4
23
+ end
24
+ add_message "google.cloud.speech.v1.PhraseSet.Phrase" do
25
+ optional :value, :string, 1
26
+ optional :boost, :float, 2
27
+ end
28
+ add_message "google.cloud.speech.v1.SpeechAdaptation" do
29
+ repeated :phrase_sets, :message, 1, "google.cloud.speech.v1.PhraseSet"
30
+ repeated :phrase_set_references, :string, 2
31
+ repeated :custom_classes, :message, 3, "google.cloud.speech.v1.CustomClass"
32
+ end
33
+ end
34
+ end
35
+
36
+ module Google
37
+ module Cloud
38
+ module Speech
39
+ module V1
40
+ CustomClass = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.CustomClass").msgclass
41
+ CustomClass::ClassItem = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.CustomClass.ClassItem").msgclass
42
+ PhraseSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.PhraseSet").msgclass
43
+ PhraseSet::Phrase = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.PhraseSet.Phrase").msgclass
44
+ SpeechAdaptation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1.SpeechAdaptation").msgclass
45
+ end
46
+ end
47
+ end
48
+ end
@@ -30,6 +30,8 @@ module Google
30
30
  # Service that implements Google Cloud Speech API.
31
31
  #
32
32
  class Client
33
+ include Paths
34
+
33
35
  # @private
34
36
  attr_reader :speech_stub
35
37
 
@@ -39,13 +41,12 @@ module Google
39
41
  # See {::Google::Cloud::Speech::V1::Speech::Client::Configuration}
40
42
  # for a description of the configuration fields.
41
43
  #
42
- # ## Example
43
- #
44
- # To modify the configuration for all Speech clients:
44
+ # @example
45
45
  #
46
- # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
47
- # config.timeout = 10.0
48
- # end
46
+ # # Modify the configuration for all Speech clients
47
+ # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
49
50
  #
50
51
  # @yield [config] Configure the Client client.
51
52
  # @yieldparam config [Client::Configuration]
@@ -104,19 +105,15 @@ module Google
104
105
  ##
105
106
  # Create a new Speech client object.
106
107
  #
107
- # ## Examples
108
- #
109
- # To create a new Speech client with the default
110
- # configuration:
111
- #
112
- # client = ::Google::Cloud::Speech::V1::Speech::Client.new
108
+ # @example
113
109
  #
114
- # To create a new Speech client with a custom
115
- # configuration:
110
+ # # Create a client using the default configuration
111
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new
116
112
  #
117
- # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
118
- # config.timeout = 10.0
119
- # end
113
+ # # Create a client using a custom configuration
114
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
115
+ # config.timeout = 10.0
116
+ # end
120
117
  #
121
118
  # @yield [config] Configure the Speech client.
122
119
  # @yieldparam config [Client::Configuration]
@@ -136,10 +133,9 @@ module Google
136
133
 
137
134
  # Create credentials
138
135
  credentials = @config.credentials
139
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
136
+ # Use self-signed JWT if the endpoint is unchanged from default,
140
137
  # but only if the default endpoint does not have a region prefix.
141
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
142
- @config.endpoint == Client.configure.endpoint &&
138
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
143
139
  !@config.endpoint.split(".").first.include?("-")
144
140
  credentials ||= Credentials.default scope: @config.scope,
145
141
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -205,6 +201,21 @@ module Google
205
201
  #
206
202
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
207
203
  #
204
+ # @example Basic example
205
+ # require "google/cloud/speech/v1"
206
+ #
207
+ # # Create a client object. The client can be reused for multiple calls.
208
+ # client = Google::Cloud::Speech::V1::Speech::Client.new
209
+ #
210
+ # # Create a request. To set request fields, pass in keyword arguments.
211
+ # request = Google::Cloud::Speech::V1::RecognizeRequest.new
212
+ #
213
+ # # Call the recognize method.
214
+ # result = client.recognize request
215
+ #
216
+ # # The returned object is of type Google::Cloud::Speech::V1::RecognizeResponse.
217
+ # p result
218
+ #
208
219
  def recognize request, options = nil
209
220
  raise ::ArgumentError, "request must be provided" if request.nil?
210
221
 
@@ -225,7 +236,9 @@ module Google
225
236
  options.apply_defaults timeout: @config.rpcs.recognize.timeout,
226
237
  metadata: metadata,
227
238
  retry_policy: @config.rpcs.recognize.retry_policy
228
- options.apply_defaults metadata: @config.metadata,
239
+
240
+ options.apply_defaults timeout: @config.timeout,
241
+ metadata: @config.metadata,
229
242
  retry_policy: @config.retry_policy
230
243
 
231
244
  @speech_stub.call_rpc :recognize, request, options: options do |response, operation|
@@ -254,7 +267,7 @@ module Google
254
267
  # @param options [::Gapic::CallOptions, ::Hash]
255
268
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
256
269
  #
257
- # @overload long_running_recognize(config: nil, audio: nil)
270
+ # @overload long_running_recognize(config: nil, audio: nil, output_config: nil)
258
271
  # Pass arguments to `long_running_recognize` via keyword arguments. Note that at
259
272
  # least one keyword argument is required. To specify no parameters, or to keep all
260
273
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -264,6 +277,8 @@ module Google
264
277
  # process the request.
265
278
  # @param audio [::Google::Cloud::Speech::V1::RecognitionAudio, ::Hash]
266
279
  # Required. The audio data to be recognized.
280
+ # @param output_config [::Google::Cloud::Speech::V1::TranscriptOutputConfig, ::Hash]
281
+ # Optional. Specifies an optional destination for the recognition results.
267
282
  #
268
283
  # @yield [response, operation] Access the result along with the RPC operation
269
284
  # @yieldparam response [::Gapic::Operation]
@@ -273,6 +288,28 @@ module Google
273
288
  #
274
289
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
275
290
  #
291
+ # @example Basic example
292
+ # require "google/cloud/speech/v1"
293
+ #
294
+ # # Create a client object. The client can be reused for multiple calls.
295
+ # client = Google::Cloud::Speech::V1::Speech::Client.new
296
+ #
297
+ # # Create a request. To set request fields, pass in keyword arguments.
298
+ # request = Google::Cloud::Speech::V1::LongRunningRecognizeRequest.new
299
+ #
300
+ # # Call the long_running_recognize method.
301
+ # result = client.long_running_recognize request
302
+ #
303
+ # # The returned object is of type Gapic::Operation. You can use this
304
+ # # object to check the status of an operation, cancel it, or wait
305
+ # # for results. Here is how to block until completion:
306
+ # result.wait_until_done! timeout: 60
307
+ # if result.response?
308
+ # p result.response
309
+ # else
310
+ # puts "Error!"
311
+ # end
312
+ #
276
313
  def long_running_recognize request, options = nil
277
314
  raise ::ArgumentError, "request must be provided" if request.nil?
278
315
 
@@ -293,7 +330,9 @@ module Google
293
330
  options.apply_defaults timeout: @config.rpcs.long_running_recognize.timeout,
294
331
  metadata: metadata,
295
332
  retry_policy: @config.rpcs.long_running_recognize.retry_policy
296
- options.apply_defaults metadata: @config.metadata,
333
+
334
+ options.apply_defaults timeout: @config.timeout,
335
+ metadata: @config.metadata,
297
336
  retry_policy: @config.retry_policy
298
337
 
299
338
  @speech_stub.call_rpc :long_running_recognize, request, options: options do |response, operation|
@@ -322,6 +361,30 @@ module Google
322
361
  #
323
362
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
324
363
  #
364
+ # @example Basic example
365
+ # require "google/cloud/speech/v1"
366
+ #
367
+ # # Create a client object. The client can be reused for multiple calls.
368
+ # client = Google::Cloud::Speech::V1::Speech::Client.new
369
+ #
370
+ # # Create an input stream
371
+ # input = Gapic::StreamInput.new
372
+ #
373
+ # # Call the streaming_recognize method to start streaming.
374
+ # output = client.streaming_recognize input
375
+ #
376
+ # # Send requests on the stream. For each request, pass in keyword
377
+ # # arguments to set fields. Be sure to close the stream when done.
378
+ # input << Google::Cloud::Speech::V1::StreamingRecognizeRequest.new
379
+ # input << Google::Cloud::Speech::V1::StreamingRecognizeRequest.new
380
+ # input.close
381
+ #
382
+ # # Handle streamed responses. These may be interleaved with inputs.
383
+ # # Each response is of type ::Google::Cloud::Speech::V1::StreamingRecognizeResponse.
384
+ # output.each do |response|
385
+ # p response
386
+ # end
387
+ #
325
388
  def streaming_recognize request, options = nil
326
389
  unless request.is_a? ::Enumerable
327
390
  raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
@@ -347,7 +410,9 @@ module Google
347
410
  options.apply_defaults timeout: @config.rpcs.streaming_recognize.timeout,
348
411
  metadata: metadata,
349
412
  retry_policy: @config.rpcs.streaming_recognize.retry_policy
350
- options.apply_defaults metadata: @config.metadata,
413
+
414
+ options.apply_defaults timeout: @config.timeout,
415
+ metadata: @config.metadata,
351
416
  retry_policy: @config.retry_policy
352
417
 
353
418
  @speech_stub.call_rpc :streaming_recognize, request, options: options do |response, operation|
@@ -371,22 +436,21 @@ module Google
371
436
  # Configuration can be applied globally to all clients, or to a single client
372
437
  # on construction.
373
438
  #
374
- # # Examples
375
- #
376
- # To modify the global config, setting the timeout for recognize
377
- # to 20 seconds, and all remaining timeouts to 10 seconds:
378
- #
379
- # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
380
- # config.timeout = 10.0
381
- # config.rpcs.recognize.timeout = 20.0
382
- # end
383
- #
384
- # To apply the above configuration only to a new client:
385
- #
386
- # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
387
- # config.timeout = 10.0
388
- # config.rpcs.recognize.timeout = 20.0
389
- # end
439
+ # @example
440
+ #
441
+ # # Modify the global config, setting the timeout for
442
+ # # recognize to 20 seconds,
443
+ # # and all remaining timeouts to 10 seconds.
444
+ # ::Google::Cloud::Speech::V1::Speech::Client.configure do |config|
445
+ # config.timeout = 10.0
446
+ # config.rpcs.recognize.timeout = 20.0
447
+ # end
448
+ #
449
+ # # Apply the above configuration only to a new client.
450
+ # client = ::Google::Cloud::Speech::V1::Speech::Client.new do |config|
451
+ # config.timeout = 10.0
452
+ # config.rpcs.recognize.timeout = 20.0
453
+ # end
390
454
  #
391
455
  # @!attribute [rw] endpoint
392
456
  # The hostname or hostname:port of the service endpoint.