google-cloud-speech-v1p1beta1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,201 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/speech/v1p1beta1/cloud_speech.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/client_pb'
8
+ require 'google/api/field_behavior_pb'
9
+ require 'google/longrunning/operations_pb'
10
+ require 'google/protobuf/any_pb'
11
+ require 'google/protobuf/duration_pb'
12
+ require 'google/protobuf/timestamp_pb'
13
+ require 'google/rpc/status_pb'
14
+ Google::Protobuf::DescriptorPool.generated_pool.build do
15
+ add_file("google/cloud/speech/v1p1beta1/cloud_speech.proto", :syntax => :proto3) do
16
+ add_message "google.cloud.speech.v1p1beta1.RecognizeRequest" do
17
+ optional :config, :message, 1, "google.cloud.speech.v1p1beta1.RecognitionConfig"
18
+ optional :audio, :message, 2, "google.cloud.speech.v1p1beta1.RecognitionAudio"
19
+ end
20
+ add_message "google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest" do
21
+ optional :config, :message, 1, "google.cloud.speech.v1p1beta1.RecognitionConfig"
22
+ optional :audio, :message, 2, "google.cloud.speech.v1p1beta1.RecognitionAudio"
23
+ end
24
+ add_message "google.cloud.speech.v1p1beta1.StreamingRecognizeRequest" do
25
+ oneof :streaming_request do
26
+ optional :streaming_config, :message, 1, "google.cloud.speech.v1p1beta1.StreamingRecognitionConfig"
27
+ optional :audio_content, :bytes, 2
28
+ end
29
+ end
30
+ add_message "google.cloud.speech.v1p1beta1.StreamingRecognitionConfig" do
31
+ optional :config, :message, 1, "google.cloud.speech.v1p1beta1.RecognitionConfig"
32
+ optional :single_utterance, :bool, 2
33
+ optional :interim_results, :bool, 3
34
+ end
35
+ add_message "google.cloud.speech.v1p1beta1.RecognitionConfig" do
36
+ optional :encoding, :enum, 1, "google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding"
37
+ optional :sample_rate_hertz, :int32, 2
38
+ optional :audio_channel_count, :int32, 7
39
+ optional :enable_separate_recognition_per_channel, :bool, 12
40
+ optional :language_code, :string, 3
41
+ repeated :alternative_language_codes, :string, 18
42
+ optional :max_alternatives, :int32, 4
43
+ optional :profanity_filter, :bool, 5
44
+ repeated :speech_contexts, :message, 6, "google.cloud.speech.v1p1beta1.SpeechContext"
45
+ optional :enable_word_time_offsets, :bool, 8
46
+ optional :enable_word_confidence, :bool, 15
47
+ optional :enable_automatic_punctuation, :bool, 11
48
+ optional :enable_speaker_diarization, :bool, 16
49
+ optional :diarization_speaker_count, :int32, 17
50
+ optional :diarization_config, :message, 19, "google.cloud.speech.v1p1beta1.SpeakerDiarizationConfig"
51
+ optional :metadata, :message, 9, "google.cloud.speech.v1p1beta1.RecognitionMetadata"
52
+ optional :model, :string, 13
53
+ optional :use_enhanced, :bool, 14
54
+ end
55
+ add_enum "google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding" do
56
+ value :ENCODING_UNSPECIFIED, 0
57
+ value :LINEAR16, 1
58
+ value :FLAC, 2
59
+ value :MULAW, 3
60
+ value :AMR, 4
61
+ value :AMR_WB, 5
62
+ value :OGG_OPUS, 6
63
+ value :SPEEX_WITH_HEADER_BYTE, 7
64
+ value :MP3, 8
65
+ end
66
+ add_message "google.cloud.speech.v1p1beta1.SpeakerDiarizationConfig" do
67
+ optional :enable_speaker_diarization, :bool, 1
68
+ optional :min_speaker_count, :int32, 2
69
+ optional :max_speaker_count, :int32, 3
70
+ end
71
+ add_message "google.cloud.speech.v1p1beta1.RecognitionMetadata" do
72
+ optional :interaction_type, :enum, 1, "google.cloud.speech.v1p1beta1.RecognitionMetadata.InteractionType"
73
+ optional :industry_naics_code_of_audio, :uint32, 3
74
+ optional :microphone_distance, :enum, 4, "google.cloud.speech.v1p1beta1.RecognitionMetadata.MicrophoneDistance"
75
+ optional :original_media_type, :enum, 5, "google.cloud.speech.v1p1beta1.RecognitionMetadata.OriginalMediaType"
76
+ optional :recording_device_type, :enum, 6, "google.cloud.speech.v1p1beta1.RecognitionMetadata.RecordingDeviceType"
77
+ optional :recording_device_name, :string, 7
78
+ optional :original_mime_type, :string, 8
79
+ optional :obfuscated_id, :int64, 9
80
+ optional :audio_topic, :string, 10
81
+ end
82
+ add_enum "google.cloud.speech.v1p1beta1.RecognitionMetadata.InteractionType" do
83
+ value :INTERACTION_TYPE_UNSPECIFIED, 0
84
+ value :DISCUSSION, 1
85
+ value :PRESENTATION, 2
86
+ value :PHONE_CALL, 3
87
+ value :VOICEMAIL, 4
88
+ value :PROFESSIONALLY_PRODUCED, 5
89
+ value :VOICE_SEARCH, 6
90
+ value :VOICE_COMMAND, 7
91
+ value :DICTATION, 8
92
+ end
93
+ add_enum "google.cloud.speech.v1p1beta1.RecognitionMetadata.MicrophoneDistance" do
94
+ value :MICROPHONE_DISTANCE_UNSPECIFIED, 0
95
+ value :NEARFIELD, 1
96
+ value :MIDFIELD, 2
97
+ value :FARFIELD, 3
98
+ end
99
+ add_enum "google.cloud.speech.v1p1beta1.RecognitionMetadata.OriginalMediaType" do
100
+ value :ORIGINAL_MEDIA_TYPE_UNSPECIFIED, 0
101
+ value :AUDIO, 1
102
+ value :VIDEO, 2
103
+ end
104
+ add_enum "google.cloud.speech.v1p1beta1.RecognitionMetadata.RecordingDeviceType" do
105
+ value :RECORDING_DEVICE_TYPE_UNSPECIFIED, 0
106
+ value :SMARTPHONE, 1
107
+ value :PC, 2
108
+ value :PHONE_LINE, 3
109
+ value :VEHICLE, 4
110
+ value :OTHER_OUTDOOR_DEVICE, 5
111
+ value :OTHER_INDOOR_DEVICE, 6
112
+ end
113
+ add_message "google.cloud.speech.v1p1beta1.SpeechContext" do
114
+ repeated :phrases, :string, 1
115
+ optional :boost, :float, 4
116
+ end
117
+ add_message "google.cloud.speech.v1p1beta1.RecognitionAudio" do
118
+ oneof :audio_source do
119
+ optional :content, :bytes, 1
120
+ optional :uri, :string, 2
121
+ end
122
+ end
123
+ add_message "google.cloud.speech.v1p1beta1.RecognizeResponse" do
124
+ repeated :results, :message, 2, "google.cloud.speech.v1p1beta1.SpeechRecognitionResult"
125
+ end
126
+ add_message "google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse" do
127
+ repeated :results, :message, 2, "google.cloud.speech.v1p1beta1.SpeechRecognitionResult"
128
+ end
129
+ add_message "google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata" do
130
+ optional :progress_percent, :int32, 1
131
+ optional :start_time, :message, 2, "google.protobuf.Timestamp"
132
+ optional :last_update_time, :message, 3, "google.protobuf.Timestamp"
133
+ end
134
+ add_message "google.cloud.speech.v1p1beta1.StreamingRecognizeResponse" do
135
+ optional :error, :message, 1, "google.rpc.Status"
136
+ repeated :results, :message, 2, "google.cloud.speech.v1p1beta1.StreamingRecognitionResult"
137
+ optional :speech_event_type, :enum, 4, "google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType"
138
+ end
139
+ add_enum "google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType" do
140
+ value :SPEECH_EVENT_UNSPECIFIED, 0
141
+ value :END_OF_SINGLE_UTTERANCE, 1
142
+ end
143
+ add_message "google.cloud.speech.v1p1beta1.StreamingRecognitionResult" do
144
+ repeated :alternatives, :message, 1, "google.cloud.speech.v1p1beta1.SpeechRecognitionAlternative"
145
+ optional :is_final, :bool, 2
146
+ optional :stability, :float, 3
147
+ optional :result_end_time, :message, 4, "google.protobuf.Duration"
148
+ optional :channel_tag, :int32, 5
149
+ optional :language_code, :string, 6
150
+ end
151
+ add_message "google.cloud.speech.v1p1beta1.SpeechRecognitionResult" do
152
+ repeated :alternatives, :message, 1, "google.cloud.speech.v1p1beta1.SpeechRecognitionAlternative"
153
+ optional :channel_tag, :int32, 2
154
+ optional :language_code, :string, 5
155
+ end
156
+ add_message "google.cloud.speech.v1p1beta1.SpeechRecognitionAlternative" do
157
+ optional :transcript, :string, 1
158
+ optional :confidence, :float, 2
159
+ repeated :words, :message, 3, "google.cloud.speech.v1p1beta1.WordInfo"
160
+ end
161
+ add_message "google.cloud.speech.v1p1beta1.WordInfo" do
162
+ optional :start_time, :message, 1, "google.protobuf.Duration"
163
+ optional :end_time, :message, 2, "google.protobuf.Duration"
164
+ optional :word, :string, 3
165
+ optional :confidence, :float, 4
166
+ optional :speaker_tag, :int32, 5
167
+ end
168
+ end
169
+ end
170
+
171
+ module Google
172
+ module Cloud
173
+ module Speech
174
+ module V1p1beta1
175
+ RecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognizeRequest").msgclass
176
+ LongRunningRecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest").msgclass
177
+ StreamingRecognizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.StreamingRecognizeRequest").msgclass
178
+ StreamingRecognitionConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.StreamingRecognitionConfig").msgclass
179
+ RecognitionConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionConfig").msgclass
180
+ RecognitionConfig::AudioEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding").enummodule
181
+ SpeakerDiarizationConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.SpeakerDiarizationConfig").msgclass
182
+ RecognitionMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionMetadata").msgclass
183
+ RecognitionMetadata::InteractionType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionMetadata.InteractionType").enummodule
184
+ RecognitionMetadata::MicrophoneDistance = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionMetadata.MicrophoneDistance").enummodule
185
+ RecognitionMetadata::OriginalMediaType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionMetadata.OriginalMediaType").enummodule
186
+ RecognitionMetadata::RecordingDeviceType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionMetadata.RecordingDeviceType").enummodule
187
+ SpeechContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.SpeechContext").msgclass
188
+ RecognitionAudio = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognitionAudio").msgclass
189
+ RecognizeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.RecognizeResponse").msgclass
190
+ LongRunningRecognizeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse").msgclass
191
+ LongRunningRecognizeMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata").msgclass
192
+ StreamingRecognizeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.StreamingRecognizeResponse").msgclass
193
+ StreamingRecognizeResponse::SpeechEventType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType").enummodule
194
+ StreamingRecognitionResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.StreamingRecognitionResult").msgclass
195
+ SpeechRecognitionResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.SpeechRecognitionResult").msgclass
196
+ SpeechRecognitionAlternative = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.SpeechRecognitionAlternative").msgclass
197
+ WordInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.WordInfo").msgclass
198
+ end
199
+ end
200
+ end
201
+ end
@@ -0,0 +1,57 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/speech/v1p1beta1/cloud_speech.proto for package 'google.cloud.speech.v1p1beta1'
3
+ # Original file comments:
4
+ # Copyright 2019 Google LLC.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ #
19
+
20
+ require 'grpc'
21
+ require 'google/cloud/speech/v1p1beta1/cloud_speech_pb'
22
+
23
+ module Google
24
+ module Cloud
25
+ module Speech
26
+ module V1p1beta1
27
+ module Speech
28
+ # Service that implements Google Cloud Speech API.
29
+ class Service
30
+
31
+ include GRPC::GenericService
32
+
33
+ self.marshal_class_method = :encode
34
+ self.unmarshal_class_method = :decode
35
+ self.service_name = 'google.cloud.speech.v1p1beta1.Speech'
36
+
37
+ # Performs synchronous speech recognition: receive results after all audio
38
+ # has been sent and processed.
39
+ rpc :Recognize, RecognizeRequest, RecognizeResponse
40
+ # Performs asynchronous speech recognition: receive results via the
41
+ # google.longrunning.Operations interface. Returns either an
42
+ # `Operation.error` or an `Operation.response` which contains
43
+ # a `LongRunningRecognizeResponse` message.
44
+ # For more information on asynchronous speech recognition, see the
45
+ # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
46
+ rpc :LongRunningRecognize, LongRunningRecognizeRequest, Google::Longrunning::Operation
47
+ # Performs bidirectional streaming speech recognition: receive results while
48
+ # sending audio. This method is only available via the gRPC API (not REST).
49
+ rpc :StreamingRecognize, stream(StreamingRecognizeRequest), stream(StreamingRecognizeResponse)
50
+ end
51
+
52
+ Stub = Service.rpc_stub_class
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/speech/v1p1beta1/speech/client"
20
+ require "google/cloud/speech/v1p1beta1/speech/operations"
21
+ require "google/cloud/speech/v1p1beta1/speech/credentials"
@@ -0,0 +1,527 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/speech/v1p1beta1/version"
25
+ require "google/cloud/speech/v1p1beta1/cloud_speech_pb"
26
+ require "google/cloud/speech/v1p1beta1/speech/credentials"
27
+ require "google/cloud/speech/v1p1beta1/speech/operations"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Speech
32
+ module V1p1beta1
33
+ module Speech
34
+ ##
35
+ # Client for the Speech service.
36
+ #
37
+ # Service that implements Google Cloud Speech API.
38
+ #
39
+ class Client
40
+ # @private
41
+ attr_reader :speech_stub
42
+
43
+ ##
44
+ # Configure the Speech Client class.
45
+ #
46
+ # See {Google::Cloud::Speech::V1p1beta1::Speech::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # ## Example
50
+ #
51
+ # To modify the configuration for all Speech clients:
52
+ #
53
+ # Google::Cloud::Speech::V1p1beta1::Speech::Client.configure do |config|
54
+ # config.timeout = 10_000
55
+ # end
56
+ #
57
+ # @yield [config] Configure the Client client.
58
+ # @yieldparam config [Client::Configuration]
59
+ #
60
+ # @return [Client::Configuration]
61
+ #
62
+ def self.configure
63
+ @configure ||= begin
64
+ namespace = ["Google", "Cloud", "Speech", "V1p1beta1"]
65
+ parent_config = while namespace.any?
66
+ parent_name = namespace.join "::"
67
+ parent_const = const_get parent_name
68
+ break parent_const.configure if parent_const&.respond_to? :configure
69
+ namespace.pop
70
+ end
71
+ default_config = Client::Configuration.new parent_config
72
+
73
+ default_config.rpcs.recognize.timeout = 5000.0
74
+ default_config.rpcs.recognize.retry_policy = {
75
+ initial_delay: 0.1,
76
+ max_delay: 60.0,
77
+ multiplier: 1.3,
78
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
79
+ }
80
+
81
+ default_config.rpcs.long_running_recognize.timeout = 5000.0
82
+
83
+ default_config.rpcs.streaming_recognize.timeout = 5000.0
84
+ default_config.rpcs.streaming_recognize.retry_policy = {
85
+ initial_delay: 0.1,
86
+ max_delay: 60.0,
87
+ multiplier: 1.3,
88
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
89
+ }
90
+
91
+ default_config
92
+ end
93
+ yield @configure if block_given?
94
+ @configure
95
+ end
96
+
97
+ ##
98
+ # Configure the Speech Client instance.
99
+ #
100
+ # The configuration is set to the derived mode, meaning that values can be changed,
101
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
102
+ # should be made on {Client.configure}.
103
+ #
104
+ # See {Google::Cloud::Speech::V1p1beta1::Speech::Client::Configuration}
105
+ # for a description of the configuration fields.
106
+ #
107
+ # @yield [config] Configure the Client client.
108
+ # @yieldparam config [Client::Configuration]
109
+ #
110
+ # @return [Client::Configuration]
111
+ #
112
+ def configure
113
+ yield @config if block_given?
114
+ @config
115
+ end
116
+
117
+ ##
118
+ # Create a new Speech client object.
119
+ #
120
+ # ## Examples
121
+ #
122
+ # To create a new Speech client with the default
123
+ # configuration:
124
+ #
125
+ # client = Google::Cloud::Speech::V1p1beta1::Speech::Client.new
126
+ #
127
+ # To create a new Speech client with a custom
128
+ # configuration:
129
+ #
130
+ # client = Google::Cloud::Speech::V1p1beta1::Speech::Client.new do |config|
131
+ # config.timeout = 10_000
132
+ # end
133
+ #
134
+ # @yield [config] Configure the Speech client.
135
+ # @yieldparam config [Client::Configuration]
136
+ #
137
+ def initialize
138
+ # These require statements are intentionally placed here to initialize
139
+ # the gRPC module only when it's required.
140
+ # See https://github.com/googleapis/toolkit/issues/446
141
+ require "gapic/grpc"
142
+ require "google/cloud/speech/v1p1beta1/cloud_speech_services_pb"
143
+
144
+ # Create the configuration object
145
+ @config = Configuration.new Client.configure
146
+
147
+ # Yield the configuration if needed
148
+ yield @config if block_given?
149
+
150
+ # Create credentials
151
+ credentials = @config.credentials
152
+ credentials ||= Credentials.default scope: @config.scope
153
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
154
+ credentials = Credentials.new credentials, scope: @config.scope
155
+ end
156
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
157
+
158
+ @operations_client = Operations.new do |config|
159
+ config.credentials = credentials
160
+ end
161
+
162
+ @speech_stub = Gapic::ServiceStub.new(
163
+ Google::Cloud::Speech::V1p1beta1::Speech::Stub,
164
+ credentials: credentials,
165
+ endpoint: @config.endpoint,
166
+ channel_args: @config.channel_args,
167
+ interceptors: @config.interceptors
168
+ )
169
+ end
170
+
171
+ # Service calls
172
+
173
+ ##
174
+ # Performs synchronous speech recognition: receive results after all audio
175
+ # has been sent and processed.
176
+ #
177
+ # @overload recognize(request, options = nil)
178
+ # @param request [Google::Cloud::Speech::V1p1beta1::RecognizeRequest | Hash]
179
+ # Performs synchronous speech recognition: receive results after all audio
180
+ # has been sent and processed.
181
+ # @param options [Gapic::CallOptions, Hash]
182
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
183
+ #
184
+ # @overload recognize(config: nil, audio: nil)
185
+ # @param config [Google::Cloud::Speech::V1p1beta1::RecognitionConfig | Hash]
186
+ # Required. Provides information to the recognizer that specifies how to
187
+ # process the request.
188
+ # @param audio [Google::Cloud::Speech::V1p1beta1::RecognitionAudio | Hash]
189
+ # Required. The audio data to be recognized.
190
+ #
191
+ #
192
+ # @yield [response, operation] Access the result along with the RPC operation
193
+ # @yieldparam response [Google::Cloud::Speech::V1p1beta1::RecognizeResponse]
194
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
195
+ #
196
+ # @return [Google::Cloud::Speech::V1p1beta1::RecognizeResponse]
197
+ #
198
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
199
+ #
200
+ def recognize request, options = nil
201
+ raise ArgumentError, "request must be provided" if request.nil?
202
+
203
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1p1beta1::RecognizeRequest
204
+
205
+ # Converts hash and nil to an options object
206
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
207
+
208
+ # Customize the options with defaults
209
+ metadata = @config.rpcs.recognize.metadata.to_h
210
+
211
+ # Set x-goog-api-client and x-goog-user-project headers
212
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
213
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
214
+ gapic_version: ::Google::Cloud::Speech::V1p1beta1::VERSION
215
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
216
+
217
+ options.apply_defaults timeout: @config.rpcs.recognize.timeout,
218
+ metadata: metadata,
219
+ retry_policy: @config.rpcs.recognize.retry_policy
220
+ options.apply_defaults metadata: @config.metadata,
221
+ retry_policy: @config.retry_policy
222
+
223
+ @speech_stub.call_rpc :recognize, request, options: options do |response, operation|
224
+ yield response, operation if block_given?
225
+ return response
226
+ end
227
+ rescue GRPC::BadStatus => e
228
+ raise Google::Cloud::Error.from_error(e)
229
+ end
230
+
231
+ ##
232
+ # Performs asynchronous speech recognition: receive results via the
233
+ # google.longrunning.Operations interface. Returns either an
234
+ # `Operation.error` or an `Operation.response` which contains
235
+ # a `LongRunningRecognizeResponse` message.
236
+ # For more information on asynchronous speech recognition, see the
237
+ # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
238
+ #
239
+ # @overload long_running_recognize(request, options = nil)
240
+ # @param request [Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest | Hash]
241
+ # Performs asynchronous speech recognition: receive results via the
242
+ # google.longrunning.Operations interface. Returns either an
243
+ # `Operation.error` or an `Operation.response` which contains
244
+ # a `LongRunningRecognizeResponse` message.
245
+ # For more information on asynchronous speech recognition, see the
246
+ # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
247
+ # @param options [Gapic::CallOptions, Hash]
248
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
249
+ #
250
+ # @overload long_running_recognize(config: nil, audio: nil)
251
+ # @param config [Google::Cloud::Speech::V1p1beta1::RecognitionConfig | Hash]
252
+ # Required. Provides information to the recognizer that specifies how to
253
+ # process the request.
254
+ # @param audio [Google::Cloud::Speech::V1p1beta1::RecognitionAudio | Hash]
255
+ # Required. The audio data to be recognized.
256
+ #
257
+ #
258
+ # @yield [response, operation] Access the result along with the RPC operation
259
+ # @yieldparam response [Gapic::Operation]
260
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
261
+ #
262
+ # @return [Gapic::Operation]
263
+ #
264
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
265
+ #
266
+ def long_running_recognize request, options = nil
267
+ raise ArgumentError, "request must be provided" if request.nil?
268
+
269
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest
270
+
271
+ # Converts hash and nil to an options object
272
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
273
+
274
+ # Customize the options with defaults
275
+ metadata = @config.rpcs.long_running_recognize.metadata.to_h
276
+
277
+ # Set x-goog-api-client and x-goog-user-project headers
278
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
279
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
280
+ gapic_version: ::Google::Cloud::Speech::V1p1beta1::VERSION
281
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
282
+
283
+ options.apply_defaults timeout: @config.rpcs.long_running_recognize.timeout,
284
+ metadata: metadata,
285
+ retry_policy: @config.rpcs.long_running_recognize.retry_policy
286
+ options.apply_defaults metadata: @config.metadata,
287
+ retry_policy: @config.retry_policy
288
+
289
+ @speech_stub.call_rpc :long_running_recognize, request, options: options do |response, operation|
290
+ response = Gapic::Operation.new response, @operations_client, options: options
291
+ yield response, operation if block_given?
292
+ return response
293
+ end
294
+ rescue GRPC::BadStatus => e
295
+ raise Google::Cloud::Error.from_error(e)
296
+ end
297
+
298
+ ##
299
+ # Performs bidirectional streaming speech recognition: receive results while
300
+ # sending audio. This method is only available via the gRPC API (not REST).
301
+ #
302
+ # @param request [Gapic::StreamInput, Enumerable<Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest | Hash>]
303
+ # An enumerable of {Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest} instances.
304
+ # @param options [Gapic::CallOptions, Hash]
305
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
306
+ #
307
+ # @yield [response, operation] Access the result along with the RPC operation
308
+ # @yieldparam response [Enumerable<Google::Cloud::Speech::V1p1beta1::StreamingRecognizeResponse>]
309
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
310
+ #
311
+ # @return [Enumerable<Google::Cloud::Speech::V1p1beta1::StreamingRecognizeResponse>]
312
+ #
313
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
314
+ #
315
+ def streaming_recognize request, options = nil
316
+ unless request.is_a? Enumerable
317
+ raise ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
318
+ request = request.to_enum
319
+ end
320
+
321
+ request = request.lazy.map do |req|
322
+ Gapic::Protobuf.coerce req, to: Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest
323
+ end
324
+
325
+ # Converts hash and nil to an options object
326
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
327
+
328
+ # Customize the options with defaults
329
+ metadata = @config.rpcs.streaming_recognize.metadata.to_h
330
+
331
+ # Set x-goog-api-client and x-goog-user-project headers
332
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
333
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
334
+ gapic_version: ::Google::Cloud::Speech::V1p1beta1::VERSION
335
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
336
+
337
+ options.apply_defaults timeout: @config.rpcs.streaming_recognize.timeout,
338
+ metadata: metadata,
339
+ retry_policy: @config.rpcs.streaming_recognize.retry_policy
340
+ options.apply_defaults metadata: @config.metadata,
341
+ retry_policy: @config.retry_policy
342
+
343
+ @speech_stub.call_rpc :streaming_recognize, request, options: options do |response, operation|
344
+ yield response, operation if block_given?
345
+ return response
346
+ end
347
+ rescue GRPC::BadStatus => e
348
+ raise Google::Cloud::Error.from_error(e)
349
+ end
350
+
351
+ ##
352
+ # Configuration class for the Speech API.
353
+ #
354
+ # This class represents the configuration for Speech,
355
+ # providing control over timeouts, retry behavior, logging, transport
356
+ # parameters, and other low-level controls. Certain parameters can also be
357
+ # applied individually to specific RPCs. See
358
+ # {Google::Cloud::Speech::V1p1beta1::Speech::Client::Configuration::Rpcs}
359
+ # for a list of RPCs that can be configured independently.
360
+ #
361
+ # Configuration can be applied globally to all clients, or to a single client
362
+ # on construction.
363
+ #
364
+ # # Examples
365
+ #
366
+ # To modify the global config, setting the timeout for recognize
367
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
368
+ #
369
+ # Google::Cloud::Speech::V1p1beta1::Speech::Client.configure do |config|
370
+ # config.timeout = 10_000
371
+ # config.rpcs.recognize.timeout = 20_000
372
+ # end
373
+ #
374
+ # To apply the above configuration only to a new client:
375
+ #
376
+ # client = Google::Cloud::Speech::V1p1beta1::Speech::Client.new do |config|
377
+ # config.timeout = 10_000
378
+ # config.rpcs.recognize.timeout = 20_000
379
+ # end
380
+ #
381
+ # @!attribute [rw] endpoint
382
+ # The hostname or hostname:port of the service endpoint.
383
+ # Defaults to `"speech.googleapis.com"`.
384
+ # @return [String]
385
+ # @!attribute [rw] credentials
386
+ # Credentials to send with calls. You may provide any of the following types:
387
+ # * (`String`) The path to a service account key file in JSON format
388
+ # * (`Hash`) A service account key as a Hash
389
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
390
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
391
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
392
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
393
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
394
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
395
+ # * (`nil`) indicating no credentials
396
+ # @return [Object]
397
+ # @!attribute [rw] scope
398
+ # The OAuth scopes
399
+ # @return [Array<String>]
400
+ # @!attribute [rw] lib_name
401
+ # The library name as recorded in instrumentation and logging
402
+ # @return [String]
403
+ # @!attribute [rw] lib_version
404
+ # The library version as recorded in instrumentation and logging
405
+ # @return [String]
406
+ # @!attribute [rw] channel_args
407
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
408
+ # `GRPC::Core::Channel` object is provided as the credential.
409
+ # @return [Hash]
410
+ # @!attribute [rw] interceptors
411
+ # An array of interceptors that are run before calls are executed.
412
+ # @return [Array<GRPC::ClientInterceptor>]
413
+ # @!attribute [rw] timeout
414
+ # The call timeout in milliseconds.
415
+ # @return [Numeric]
416
+ # @!attribute [rw] metadata
417
+ # Additional gRPC headers to be sent with the call.
418
+ # @return [Hash{Symbol=>String}]
419
+ # @!attribute [rw] retry_policy
420
+ # The retry policy. The value is a hash with the following keys:
421
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
422
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
423
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
424
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
425
+ # trigger a retry.
426
+ # @return [Hash]
427
+ #
428
+ class Configuration
429
+ extend Gapic::Config
430
+
431
+ config_attr :endpoint, "speech.googleapis.com", String
432
+ config_attr :credentials, nil do |value|
433
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
434
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
435
+ allowed.any? { |klass| klass === value }
436
+ end
437
+ config_attr :scope, nil, String, Array, nil
438
+ config_attr :lib_name, nil, String, nil
439
+ config_attr :lib_version, nil, String, nil
440
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
441
+ config_attr :interceptors, nil, Array, nil
442
+ config_attr :timeout, nil, Numeric, nil
443
+ config_attr :metadata, nil, Hash, nil
444
+ config_attr :retry_policy, nil, Hash, Proc, nil
445
+
446
+ # @private
447
+ def initialize parent_config = nil
448
+ @parent_config = parent_config unless parent_config.nil?
449
+
450
+ yield self if block_given?
451
+ end
452
+
453
+ ##
454
+ # Configurations for individual RPCs
455
+ # @return [Rpcs]
456
+ #
457
+ def rpcs
458
+ @rpcs ||= begin
459
+ parent_rpcs = nil
460
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
461
+ Rpcs.new parent_rpcs
462
+ end
463
+ end
464
+
465
+ ##
466
+ # Configuration RPC class for the Speech API.
467
+ #
468
+ # Includes fields providing the configuration for each RPC in this service.
469
+ # Each configuration object is of type `Gapic::Config::Method` and includes
470
+ # the following configuration fields:
471
+ #
472
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
473
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
474
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
475
+ # include the following keys:
476
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
477
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
478
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
479
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
480
+ # trigger a retry.
481
+ #
482
+ class Rpcs
483
+ ##
484
+ # RPC-specific configuration for `recognize`
485
+ # @return [Gapic::Config::Method]
486
+ #
487
+ attr_reader :recognize
488
+ ##
489
+ # RPC-specific configuration for `long_running_recognize`
490
+ # @return [Gapic::Config::Method]
491
+ #
492
+ attr_reader :long_running_recognize
493
+ ##
494
+ # RPC-specific configuration for `streaming_recognize`
495
+ # @return [Gapic::Config::Method]
496
+ #
497
+ attr_reader :streaming_recognize
498
+
499
+ # @private
500
+ def initialize parent_rpcs = nil
501
+ recognize_config = parent_rpcs&.recognize if parent_rpcs&.respond_to? :recognize
502
+ @recognize = Gapic::Config::Method.new recognize_config
503
+ long_running_recognize_config = parent_rpcs&.long_running_recognize if parent_rpcs&.respond_to? :long_running_recognize
504
+ @long_running_recognize = Gapic::Config::Method.new long_running_recognize_config
505
+ streaming_recognize_config = parent_rpcs&.streaming_recognize if parent_rpcs&.respond_to? :streaming_recognize
506
+ @streaming_recognize = Gapic::Config::Method.new streaming_recognize_config
507
+
508
+ yield self if block_given?
509
+ end
510
+ end
511
+ end
512
+ end
513
+ end
514
+ end
515
+ end
516
+ end
517
+ end
518
+
519
+ # rubocop:disable Lint/HandleExceptions
520
+
521
+ # Once client is loaded, load helpers.rb if it exists.
522
+ begin
523
+ require "google/cloud/speech/v1p1beta1/speech/helpers"
524
+ rescue LoadError
525
+ end
526
+
527
+ # rubocop:enable Lint/HandleExceptions