google-cloud-text_to_speech-v1 0.8.0 → 0.9.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
  SHA256:
3
- metadata.gz: 2a26603c5266100cd978172a0bd3c6e210304d5ac58e73d3936841d01bdb46a4
4
- data.tar.gz: 980ace6d8946af0c63184e87839a4848675dc76a970e953f7f92eb2cb8766e1b
3
+ metadata.gz: 4fd95d54458f65d190aa5732ec178bb797780a28f4d0a9e41c00520aaed6c204
4
+ data.tar.gz: 07a553d4e8d5685e7fe59aa9f3a1759cc0029ccb9446ebe2c4c56a4b1102c575
5
5
  SHA512:
6
- metadata.gz: c227f9511923e9cd9f7ae684fcfa88328fcd6426b38b5dbf6163bb3cab856e45e1d984ac0f31792a0de25633a5355f1ddbe22217b464741dedc1c6cffc3523ea
7
- data.tar.gz: b524e13efe9f8f02acfe0d4fce9bfb19ba39858fb5e2f0289ee29159aa505edc97d28553cf808b6731115e88cfcdee0b188aac12d1c67b9828de4c8f31ceb3dc
6
+ metadata.gz: adb3f3449f576aadf3d6f2788fd0865d2edc2dc891a08f755714160aa46879dec0ef361bf6c6aa2327644b136c1dc923c061aef10abd6f1d65920dfa969a3806
7
+ data.tar.gz: 543b4eb177c797fc364730e6d7977a0eff21458cc5606a4686f4348ffe53d0bd650bf0d49c25be8a8b09e9538abbef989a63228a9e9ca2e1e1344d3ac11b7672
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/text_to_speech/v1/text_to_speech/rest"
20
+ require "google/cloud/text_to_speech/v1/text_to_speech_long_audio_synthesize/rest"
21
+ require "google/cloud/text_to_speech/v1/version"
22
+
23
+ module Google
24
+ module Cloud
25
+ module TextToSpeech
26
+ ##
27
+ # To load just the REST part of this package, including all its services, and instantiate a REST client:
28
+ #
29
+ # @example
30
+ #
31
+ # require "google/cloud/text_to_speech/v1/rest"
32
+ # client = ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.new
33
+ #
34
+ module V1
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,430 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/errors"
20
+ require "google/cloud/texttospeech/v1/cloud_tts_pb"
21
+ require "google/cloud/text_to_speech/v1/text_to_speech/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module TextToSpeech
26
+ module V1
27
+ module TextToSpeech
28
+ module Rest
29
+ ##
30
+ # REST client for the TextToSpeech service.
31
+ #
32
+ # Service that implements Google Cloud Text-to-Speech API.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :text_to_speech_stub
39
+
40
+ ##
41
+ # Configure the TextToSpeech Client class.
42
+ #
43
+ # See {::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all TextToSpeech clients
49
+ # ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "TextToSpeech", "V1"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.timeout = 300.0
70
+ default_config.retry_policy = {
71
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
72
+ }
73
+
74
+ default_config
75
+ end
76
+ yield @configure if block_given?
77
+ @configure
78
+ end
79
+
80
+ ##
81
+ # Configure the TextToSpeech Client instance.
82
+ #
83
+ # The configuration is set to the derived mode, meaning that values can be changed,
84
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
85
+ # should be made on {Client.configure}.
86
+ #
87
+ # See {::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client::Configuration}
88
+ # for a description of the configuration fields.
89
+ #
90
+ # @yield [config] Configure the Client client.
91
+ # @yieldparam config [Client::Configuration]
92
+ #
93
+ # @return [Client::Configuration]
94
+ #
95
+ def configure
96
+ yield @config if block_given?
97
+ @config
98
+ end
99
+
100
+ ##
101
+ # Create a new TextToSpeech REST client object.
102
+ #
103
+ # @example
104
+ #
105
+ # # Create a client using the default configuration
106
+ # client = ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.new
107
+ #
108
+ # # Create a client using a custom configuration
109
+ # client = ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.new do |config|
110
+ # config.timeout = 10.0
111
+ # end
112
+ #
113
+ # @yield [config] Configure the TextToSpeech client.
114
+ # @yieldparam config [Client::Configuration]
115
+ #
116
+ def initialize
117
+ # Create the configuration object
118
+ @config = Configuration.new Client.configure
119
+
120
+ # Yield the configuration if needed
121
+ yield @config if block_given?
122
+
123
+ # Create credentials
124
+ credentials = @config.credentials
125
+ # Use self-signed JWT if the endpoint is unchanged from default,
126
+ # but only if the default endpoint does not have a region prefix.
127
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
128
+ !@config.endpoint.split(".").first.include?("-")
129
+ credentials ||= Credentials.default scope: @config.scope,
130
+ enable_self_signed_jwt: enable_self_signed_jwt
131
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
132
+ credentials = Credentials.new credentials, scope: @config.scope
133
+ end
134
+
135
+ @quota_project_id = @config.quota_project
136
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
137
+
138
+ @text_to_speech_stub = ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
139
+ end
140
+
141
+ # Service calls
142
+
143
+ ##
144
+ # Returns a list of Voice supported for synthesis.
145
+ #
146
+ # @overload list_voices(request, options = nil)
147
+ # Pass arguments to `list_voices` via a request object, either of type
148
+ # {::Google::Cloud::TextToSpeech::V1::ListVoicesRequest} or an equivalent Hash.
149
+ #
150
+ # @param request [::Google::Cloud::TextToSpeech::V1::ListVoicesRequest, ::Hash]
151
+ # A request object representing the call parameters. Required. To specify no
152
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
153
+ # @param options [::Gapic::CallOptions, ::Hash]
154
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
155
+ #
156
+ # @overload list_voices(language_code: nil)
157
+ # Pass arguments to `list_voices` via keyword arguments. Note that at
158
+ # least one keyword argument is required. To specify no parameters, or to keep all
159
+ # the default parameter values, pass an empty Hash as a request object (see above).
160
+ #
161
+ # @param language_code [::String]
162
+ # Optional. Recommended.
163
+ # [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
164
+ # If not specified, the API will return all supported voices.
165
+ # If specified, the ListVoices call will only return voices that can be used
166
+ # to synthesize this language_code. For example, if you specify `"en-NZ"`,
167
+ # all `"en-NZ"` voices will be returned. If you specify `"no"`, both
168
+ # `"no-\*"` (Norwegian) and `"nb-\*"` (Norwegian Bokmal) voices will be
169
+ # returned.
170
+ # @yield [result, operation] Access the result along with the TransportOperation object
171
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1::ListVoicesResponse]
172
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
173
+ #
174
+ # @return [::Google::Cloud::TextToSpeech::V1::ListVoicesResponse]
175
+ #
176
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
177
+ def list_voices request, options = nil
178
+ raise ::ArgumentError, "request must be provided" if request.nil?
179
+
180
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::TextToSpeech::V1::ListVoicesRequest
181
+
182
+ # Converts hash and nil to an options object
183
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
184
+
185
+ # Customize the options with defaults
186
+ call_metadata = @config.rpcs.list_voices.metadata.to_h
187
+
188
+ # Set x-goog-api-client and x-goog-user-project headers
189
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
190
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
191
+ gapic_version: ::Google::Cloud::TextToSpeech::V1::VERSION,
192
+ transports_version_send: [:rest]
193
+
194
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
195
+
196
+ options.apply_defaults timeout: @config.rpcs.list_voices.timeout,
197
+ metadata: call_metadata,
198
+ retry_policy: @config.rpcs.list_voices.retry_policy
199
+
200
+ options.apply_defaults timeout: @config.timeout,
201
+ metadata: @config.metadata,
202
+ retry_policy: @config.retry_policy
203
+
204
+ @text_to_speech_stub.list_voices request, options do |result, operation|
205
+ yield result, operation if block_given?
206
+ return result
207
+ end
208
+ rescue ::Gapic::Rest::Error => e
209
+ raise ::Google::Cloud::Error.from_error(e)
210
+ end
211
+
212
+ ##
213
+ # Synthesizes speech synchronously: receive results after all text input
214
+ # has been processed.
215
+ #
216
+ # @overload synthesize_speech(request, options = nil)
217
+ # Pass arguments to `synthesize_speech` via a request object, either of type
218
+ # {::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechRequest} or an equivalent Hash.
219
+ #
220
+ # @param request [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechRequest, ::Hash]
221
+ # A request object representing the call parameters. Required. To specify no
222
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
223
+ # @param options [::Gapic::CallOptions, ::Hash]
224
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
225
+ #
226
+ # @overload synthesize_speech(input: nil, voice: nil, audio_config: nil)
227
+ # Pass arguments to `synthesize_speech` via keyword arguments. Note that at
228
+ # least one keyword argument is required. To specify no parameters, or to keep all
229
+ # the default parameter values, pass an empty Hash as a request object (see above).
230
+ #
231
+ # @param input [::Google::Cloud::TextToSpeech::V1::SynthesisInput, ::Hash]
232
+ # Required. The Synthesizer requires either plain text or SSML as input.
233
+ # @param voice [::Google::Cloud::TextToSpeech::V1::VoiceSelectionParams, ::Hash]
234
+ # Required. The desired voice of the synthesized audio.
235
+ # @param audio_config [::Google::Cloud::TextToSpeech::V1::AudioConfig, ::Hash]
236
+ # Required. The configuration of the synthesized audio.
237
+ # @yield [result, operation] Access the result along with the TransportOperation object
238
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechResponse]
239
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
240
+ #
241
+ # @return [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechResponse]
242
+ #
243
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
244
+ def synthesize_speech request, options = nil
245
+ raise ::ArgumentError, "request must be provided" if request.nil?
246
+
247
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechRequest
248
+
249
+ # Converts hash and nil to an options object
250
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
251
+
252
+ # Customize the options with defaults
253
+ call_metadata = @config.rpcs.synthesize_speech.metadata.to_h
254
+
255
+ # Set x-goog-api-client and x-goog-user-project headers
256
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
257
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
258
+ gapic_version: ::Google::Cloud::TextToSpeech::V1::VERSION,
259
+ transports_version_send: [:rest]
260
+
261
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
262
+
263
+ options.apply_defaults timeout: @config.rpcs.synthesize_speech.timeout,
264
+ metadata: call_metadata,
265
+ retry_policy: @config.rpcs.synthesize_speech.retry_policy
266
+
267
+ options.apply_defaults timeout: @config.timeout,
268
+ metadata: @config.metadata,
269
+ retry_policy: @config.retry_policy
270
+
271
+ @text_to_speech_stub.synthesize_speech request, options do |result, operation|
272
+ yield result, operation if block_given?
273
+ return result
274
+ end
275
+ rescue ::Gapic::Rest::Error => e
276
+ raise ::Google::Cloud::Error.from_error(e)
277
+ end
278
+
279
+ ##
280
+ # Configuration class for the TextToSpeech REST API.
281
+ #
282
+ # This class represents the configuration for TextToSpeech REST,
283
+ # providing control over timeouts, retry behavior, logging, transport
284
+ # parameters, and other low-level controls. Certain parameters can also be
285
+ # applied individually to specific RPCs. See
286
+ # {::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client::Configuration::Rpcs}
287
+ # for a list of RPCs that can be configured independently.
288
+ #
289
+ # Configuration can be applied globally to all clients, or to a single client
290
+ # on construction.
291
+ #
292
+ # @example
293
+ #
294
+ # # Modify the global config, setting the timeout for
295
+ # # list_voices to 20 seconds,
296
+ # # and all remaining timeouts to 10 seconds.
297
+ # ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.configure do |config|
298
+ # config.timeout = 10.0
299
+ # config.rpcs.list_voices.timeout = 20.0
300
+ # end
301
+ #
302
+ # # Apply the above configuration only to a new client.
303
+ # client = ::Google::Cloud::TextToSpeech::V1::TextToSpeech::Rest::Client.new do |config|
304
+ # config.timeout = 10.0
305
+ # config.rpcs.list_voices.timeout = 20.0
306
+ # end
307
+ #
308
+ # @!attribute [rw] endpoint
309
+ # The hostname or hostname:port of the service endpoint.
310
+ # Defaults to `"texttospeech.googleapis.com"`.
311
+ # @return [::String]
312
+ # @!attribute [rw] credentials
313
+ # Credentials to send with calls. You may provide any of the following types:
314
+ # * (`String`) The path to a service account key file in JSON format
315
+ # * (`Hash`) A service account key as a Hash
316
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
317
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
318
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
319
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
320
+ # * (`nil`) indicating no credentials
321
+ # @return [::Object]
322
+ # @!attribute [rw] scope
323
+ # The OAuth scopes
324
+ # @return [::Array<::String>]
325
+ # @!attribute [rw] lib_name
326
+ # The library name as recorded in instrumentation and logging
327
+ # @return [::String]
328
+ # @!attribute [rw] lib_version
329
+ # The library version as recorded in instrumentation and logging
330
+ # @return [::String]
331
+ # @!attribute [rw] timeout
332
+ # The call timeout in seconds.
333
+ # @return [::Numeric]
334
+ # @!attribute [rw] metadata
335
+ # Additional headers to be sent with the call.
336
+ # @return [::Hash{::Symbol=>::String}]
337
+ # @!attribute [rw] retry_policy
338
+ # The retry policy. The value is a hash with the following keys:
339
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
340
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
341
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
342
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
343
+ # trigger a retry.
344
+ # @return [::Hash]
345
+ # @!attribute [rw] quota_project
346
+ # A separate project against which to charge quota.
347
+ # @return [::String]
348
+ #
349
+ class Configuration
350
+ extend ::Gapic::Config
351
+
352
+ config_attr :endpoint, "texttospeech.googleapis.com", ::String
353
+ config_attr :credentials, nil do |value|
354
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
355
+ allowed.any? { |klass| klass === value }
356
+ end
357
+ config_attr :scope, nil, ::String, ::Array, nil
358
+ config_attr :lib_name, nil, ::String, nil
359
+ config_attr :lib_version, nil, ::String, nil
360
+ config_attr :timeout, nil, ::Numeric, nil
361
+ config_attr :metadata, nil, ::Hash, nil
362
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
363
+ config_attr :quota_project, nil, ::String, nil
364
+
365
+ # @private
366
+ def initialize parent_config = nil
367
+ @parent_config = parent_config unless parent_config.nil?
368
+
369
+ yield self if block_given?
370
+ end
371
+
372
+ ##
373
+ # Configurations for individual RPCs
374
+ # @return [Rpcs]
375
+ #
376
+ def rpcs
377
+ @rpcs ||= begin
378
+ parent_rpcs = nil
379
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
380
+ Rpcs.new parent_rpcs
381
+ end
382
+ end
383
+
384
+ ##
385
+ # Configuration RPC class for the TextToSpeech API.
386
+ #
387
+ # Includes fields providing the configuration for each RPC in this service.
388
+ # Each configuration object is of type `Gapic::Config::Method` and includes
389
+ # the following configuration fields:
390
+ #
391
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
392
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
393
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
394
+ # include the following keys:
395
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
396
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
397
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
398
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
399
+ # trigger a retry.
400
+ #
401
+ class Rpcs
402
+ ##
403
+ # RPC-specific configuration for `list_voices`
404
+ # @return [::Gapic::Config::Method]
405
+ #
406
+ attr_reader :list_voices
407
+ ##
408
+ # RPC-specific configuration for `synthesize_speech`
409
+ # @return [::Gapic::Config::Method]
410
+ #
411
+ attr_reader :synthesize_speech
412
+
413
+ # @private
414
+ def initialize parent_rpcs = nil
415
+ list_voices_config = parent_rpcs.list_voices if parent_rpcs.respond_to? :list_voices
416
+ @list_voices = ::Gapic::Config::Method.new list_voices_config
417
+ synthesize_speech_config = parent_rpcs.synthesize_speech if parent_rpcs.respond_to? :synthesize_speech
418
+ @synthesize_speech = ::Gapic::Config::Method.new synthesize_speech_config
419
+
420
+ yield self if block_given?
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
427
+ end
428
+ end
429
+ end
430
+ end
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/texttospeech/v1/cloud_tts_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module TextToSpeech
24
+ module V1
25
+ module TextToSpeech
26
+ module Rest
27
+ ##
28
+ # REST service stub for the TextToSpeech service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the list_voices REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1::ListVoicesRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1::ListVoicesResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::TextToSpeech::V1::ListVoicesResponse]
56
+ # A result object deserialized from the server's reply
57
+ def list_voices request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_voices_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::TextToSpeech::V1::ListVoicesResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the synthesize_speech REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechRequest]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechResponse]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechResponse]
94
+ # A result object deserialized from the server's reply
95
+ def synthesize_speech request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_synthesize_speech_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechResponse.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the list_voices REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1::ListVoicesRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_list_voices_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :get,
132
+ uri_template: "/v1/voices",
133
+ matches: []
134
+ )
135
+ transcoder.transcode request_pb
136
+ end
137
+
138
+ ##
139
+ # @private
140
+ #
141
+ # GRPC transcoding helper method for the synthesize_speech REST call
142
+ #
143
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1::SynthesizeSpeechRequest]
144
+ # A request object representing the call parameters. Required.
145
+ # @return [Array(String, [String, nil], Hash{String => String})]
146
+ # Uri, Body, Query string parameters
147
+ def self.transcode_synthesize_speech_request request_pb
148
+ transcoder = Gapic::Rest::GrpcTranscoder.new
149
+ .with_bindings(
150
+ uri_method: :post,
151
+ uri_template: "/v1/text:synthesize",
152
+ body: "*",
153
+ matches: []
154
+ )
155
+ transcoder.transcode request_pb
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end