google-cloud-text_to_speech-v1beta1 0.9.1 → 0.10.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 +4 -4
- data/lib/google/cloud/text_to_speech/v1beta1/rest.rb +38 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech/rest/client.rb +432 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech/rest/service_stub.rb +163 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech/rest.rb +52 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech.rb +7 -1
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/client.rb +4 -4
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/operations.rb +12 -14
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/rest/client.rb +371 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/rest/operations.rb +793 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/rest/service_stub.rb +108 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/rest.rb +53 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize.rb +7 -1
- data/lib/google/cloud/text_to_speech/v1beta1/version.rb +1 -1
- data/lib/google/cloud/text_to_speech/v1beta1.rb +7 -2
- metadata +15 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79423f3eaaf00100692df98dfe6cd05ae070991f321816a2f32a92f10f74f04f
|
4
|
+
data.tar.gz: 171ce3c1ca428274b574f2cea039485c96364e135247ea7ff236c05f34e88ef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528e08a437e59496cf6ddf8807d1ae72ed6ebeeaeb9e7c40513f452c806b0f2dfa67b79fd9e4803ca86eb513fb371e973eafd33443fb3ab377cf06dfca0f9bd1
|
7
|
+
data.tar.gz: e90323f8046b939516d34a3bf4926c202cf0917f48facd36413e4aa4e19d0896beee8e5beb6674335515d5cefe771c77f258104911cb9cdeba06b9805ca5af76
|
@@ -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/v1beta1/text_to_speech/rest"
|
20
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech_long_audio_synthesize/rest"
|
21
|
+
require "google/cloud/text_to_speech/v1beta1/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/v1beta1/rest"
|
32
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client.new
|
33
|
+
#
|
34
|
+
module V1beta1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,432 @@
|
|
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/v1beta1/cloud_tts_pb"
|
21
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module TextToSpeech
|
26
|
+
module V1beta1
|
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::V1beta1::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::V1beta1::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", "V1beta1"]
|
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::V1beta1::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::V1beta1::TextToSpeech::Rest::Client.new
|
107
|
+
#
|
108
|
+
# # Create a client using a custom configuration
|
109
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::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::V1beta1::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::V1beta1::ListVoicesRequest} or an equivalent Hash.
|
149
|
+
#
|
150
|
+
# @param request [::Google::Cloud::TextToSpeech::V1beta1::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::V1beta1::ListVoicesResponse]
|
172
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
173
|
+
#
|
174
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::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::V1beta1::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::V1beta1::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::V1beta1::SynthesizeSpeechRequest} or an equivalent Hash.
|
219
|
+
#
|
220
|
+
# @param request [::Google::Cloud::TextToSpeech::V1beta1::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, enable_time_pointing: 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::V1beta1::SynthesisInput, ::Hash]
|
232
|
+
# Required. The Synthesizer requires either plain text or SSML as input.
|
233
|
+
# @param voice [::Google::Cloud::TextToSpeech::V1beta1::VoiceSelectionParams, ::Hash]
|
234
|
+
# Required. The desired voice of the synthesized audio.
|
235
|
+
# @param audio_config [::Google::Cloud::TextToSpeech::V1beta1::AudioConfig, ::Hash]
|
236
|
+
# Required. The configuration of the synthesized audio.
|
237
|
+
# @param enable_time_pointing [::Array<::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest::TimepointType>]
|
238
|
+
# Whether and what timepoints are returned in the response.
|
239
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
240
|
+
# @yieldparam result [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
|
241
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
242
|
+
#
|
243
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
|
244
|
+
#
|
245
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
246
|
+
def synthesize_speech request, options = nil
|
247
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
248
|
+
|
249
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest
|
250
|
+
|
251
|
+
# Converts hash and nil to an options object
|
252
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
253
|
+
|
254
|
+
# Customize the options with defaults
|
255
|
+
call_metadata = @config.rpcs.synthesize_speech.metadata.to_h
|
256
|
+
|
257
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
258
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
259
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
260
|
+
gapic_version: ::Google::Cloud::TextToSpeech::V1beta1::VERSION,
|
261
|
+
transports_version_send: [:rest]
|
262
|
+
|
263
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
264
|
+
|
265
|
+
options.apply_defaults timeout: @config.rpcs.synthesize_speech.timeout,
|
266
|
+
metadata: call_metadata,
|
267
|
+
retry_policy: @config.rpcs.synthesize_speech.retry_policy
|
268
|
+
|
269
|
+
options.apply_defaults timeout: @config.timeout,
|
270
|
+
metadata: @config.metadata,
|
271
|
+
retry_policy: @config.retry_policy
|
272
|
+
|
273
|
+
@text_to_speech_stub.synthesize_speech request, options do |result, operation|
|
274
|
+
yield result, operation if block_given?
|
275
|
+
return result
|
276
|
+
end
|
277
|
+
rescue ::Gapic::Rest::Error => e
|
278
|
+
raise ::Google::Cloud::Error.from_error(e)
|
279
|
+
end
|
280
|
+
|
281
|
+
##
|
282
|
+
# Configuration class for the TextToSpeech REST API.
|
283
|
+
#
|
284
|
+
# This class represents the configuration for TextToSpeech REST,
|
285
|
+
# providing control over timeouts, retry behavior, logging, transport
|
286
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
287
|
+
# applied individually to specific RPCs. See
|
288
|
+
# {::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client::Configuration::Rpcs}
|
289
|
+
# for a list of RPCs that can be configured independently.
|
290
|
+
#
|
291
|
+
# Configuration can be applied globally to all clients, or to a single client
|
292
|
+
# on construction.
|
293
|
+
#
|
294
|
+
# @example
|
295
|
+
#
|
296
|
+
# # Modify the global config, setting the timeout for
|
297
|
+
# # list_voices to 20 seconds,
|
298
|
+
# # and all remaining timeouts to 10 seconds.
|
299
|
+
# ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client.configure do |config|
|
300
|
+
# config.timeout = 10.0
|
301
|
+
# config.rpcs.list_voices.timeout = 20.0
|
302
|
+
# end
|
303
|
+
#
|
304
|
+
# # Apply the above configuration only to a new client.
|
305
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client.new do |config|
|
306
|
+
# config.timeout = 10.0
|
307
|
+
# config.rpcs.list_voices.timeout = 20.0
|
308
|
+
# end
|
309
|
+
#
|
310
|
+
# @!attribute [rw] endpoint
|
311
|
+
# The hostname or hostname:port of the service endpoint.
|
312
|
+
# Defaults to `"texttospeech.googleapis.com"`.
|
313
|
+
# @return [::String]
|
314
|
+
# @!attribute [rw] credentials
|
315
|
+
# Credentials to send with calls. You may provide any of the following types:
|
316
|
+
# * (`String`) The path to a service account key file in JSON format
|
317
|
+
# * (`Hash`) A service account key as a Hash
|
318
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
319
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
320
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
321
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
322
|
+
# * (`nil`) indicating no credentials
|
323
|
+
# @return [::Object]
|
324
|
+
# @!attribute [rw] scope
|
325
|
+
# The OAuth scopes
|
326
|
+
# @return [::Array<::String>]
|
327
|
+
# @!attribute [rw] lib_name
|
328
|
+
# The library name as recorded in instrumentation and logging
|
329
|
+
# @return [::String]
|
330
|
+
# @!attribute [rw] lib_version
|
331
|
+
# The library version as recorded in instrumentation and logging
|
332
|
+
# @return [::String]
|
333
|
+
# @!attribute [rw] timeout
|
334
|
+
# The call timeout in seconds.
|
335
|
+
# @return [::Numeric]
|
336
|
+
# @!attribute [rw] metadata
|
337
|
+
# Additional headers to be sent with the call.
|
338
|
+
# @return [::Hash{::Symbol=>::String}]
|
339
|
+
# @!attribute [rw] retry_policy
|
340
|
+
# The retry policy. The value is a hash with the following keys:
|
341
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
342
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
343
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
344
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
345
|
+
# trigger a retry.
|
346
|
+
# @return [::Hash]
|
347
|
+
# @!attribute [rw] quota_project
|
348
|
+
# A separate project against which to charge quota.
|
349
|
+
# @return [::String]
|
350
|
+
#
|
351
|
+
class Configuration
|
352
|
+
extend ::Gapic::Config
|
353
|
+
|
354
|
+
config_attr :endpoint, "texttospeech.googleapis.com", ::String
|
355
|
+
config_attr :credentials, nil do |value|
|
356
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
357
|
+
allowed.any? { |klass| klass === value }
|
358
|
+
end
|
359
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
360
|
+
config_attr :lib_name, nil, ::String, nil
|
361
|
+
config_attr :lib_version, nil, ::String, nil
|
362
|
+
config_attr :timeout, nil, ::Numeric, nil
|
363
|
+
config_attr :metadata, nil, ::Hash, nil
|
364
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
365
|
+
config_attr :quota_project, nil, ::String, nil
|
366
|
+
|
367
|
+
# @private
|
368
|
+
def initialize parent_config = nil
|
369
|
+
@parent_config = parent_config unless parent_config.nil?
|
370
|
+
|
371
|
+
yield self if block_given?
|
372
|
+
end
|
373
|
+
|
374
|
+
##
|
375
|
+
# Configurations for individual RPCs
|
376
|
+
# @return [Rpcs]
|
377
|
+
#
|
378
|
+
def rpcs
|
379
|
+
@rpcs ||= begin
|
380
|
+
parent_rpcs = nil
|
381
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
382
|
+
Rpcs.new parent_rpcs
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
##
|
387
|
+
# Configuration RPC class for the TextToSpeech API.
|
388
|
+
#
|
389
|
+
# Includes fields providing the configuration for each RPC in this service.
|
390
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
391
|
+
# the following configuration fields:
|
392
|
+
#
|
393
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
394
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
395
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
396
|
+
# include the following keys:
|
397
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
398
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
399
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
400
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
401
|
+
# trigger a retry.
|
402
|
+
#
|
403
|
+
class Rpcs
|
404
|
+
##
|
405
|
+
# RPC-specific configuration for `list_voices`
|
406
|
+
# @return [::Gapic::Config::Method]
|
407
|
+
#
|
408
|
+
attr_reader :list_voices
|
409
|
+
##
|
410
|
+
# RPC-specific configuration for `synthesize_speech`
|
411
|
+
# @return [::Gapic::Config::Method]
|
412
|
+
#
|
413
|
+
attr_reader :synthesize_speech
|
414
|
+
|
415
|
+
# @private
|
416
|
+
def initialize parent_rpcs = nil
|
417
|
+
list_voices_config = parent_rpcs.list_voices if parent_rpcs.respond_to? :list_voices
|
418
|
+
@list_voices = ::Gapic::Config::Method.new list_voices_config
|
419
|
+
synthesize_speech_config = parent_rpcs.synthesize_speech if parent_rpcs.respond_to? :synthesize_speech
|
420
|
+
@synthesize_speech = ::Gapic::Config::Method.new synthesize_speech_config
|
421
|
+
|
422
|
+
yield self if block_given?
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
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/v1beta1/cloud_tts_pb"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
module TextToSpeech
|
24
|
+
module V1beta1
|
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::V1beta1::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::V1beta1::ListVoicesResponse]
|
53
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
54
|
+
#
|
55
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::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::V1beta1::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::V1beta1::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::V1beta1::SynthesizeSpeechResponse]
|
91
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
92
|
+
#
|
93
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::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::V1beta1::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::V1beta1::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: "/v1beta1/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::V1beta1::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: "/v1beta1/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
|